-
Notifications
You must be signed in to change notification settings - Fork 167
impl rfc "APM endpoint resource renaming in the tracers" #3415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
87e685b
to
9222b89
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3415 +/- ##
==========================================
- Coverage 61.90% 61.74% -0.17%
==========================================
Files 141 141
Lines 12481 12481
Branches 1630 1630
==========================================
- Hits 7726 7706 -20
- Misses 4033 4054 +21
+ Partials 722 721 -1 see 3 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
9222b89
to
3ae54d2
Compare
3ae54d2
to
f409ea3
Compare
Benchmarks [ tracer ]Benchmark execution time: 2025-09-18 13:49:12 Comparing candidate commit 98ead20 in PR branch Found 1 performance improvements and 5 performance regressions! Performance is the same for 188 metrics, 0 unstable metrics. scenario:ContextPropagationBench/benchExtractHeaders128Bit
scenario:ContextPropagationBench/benchInject64Bit-opcache
scenario:PDOBench/benchPDOOverhead
scenario:PDOBench/benchPDOOverheadWithDBM
scenario:PHPRedisBench/benchRedisOverhead
scenario:TraceSerializationBench/benchSerializeTrace
|
ext/span.c
Outdated
uintptr_t offset = XtOffsetOf(ddtrace_root_span_data, span); | ||
ddtrace_root_span_data *root_span = (ddtrace_root_span_data *)((char *)span - offset); | ||
ddtrace_maybe_add_guessed_endpoint_tag(root_span); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uintptr_t offset = XtOffsetOf(ddtrace_root_span_data, span); | |
ddtrace_root_span_data *root_span = (ddtrace_root_span_data *)((char *)span - offset); | |
ddtrace_maybe_add_guessed_endpoint_tag(root_span); | |
ddtrace_maybe_add_guessed_endpoint_tag(ROOTSPANDATA(&span->std)); |
ext/span.c
Outdated
if (get_DD_TRACE_RESOURCE_RENAMING_ENABLED() && get_DD_TRACE_SIDECAR_TRACE_SENDER()) { | ||
// the purpose is client-computed stats for /v0.6/stats, so sidecar is required |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Um, in case we don't manually compute, the agent will do that task and should?
Also we don't ever drop that tag when computing - Let's always include the tag, if only for consistency.
if (get_DD_TRACE_RESOURCE_RENAMING_ENABLED() && get_DD_TRACE_SIDECAR_TRACE_SENDER()) { | |
// the purpose is client-computed stats for /v0.6/stats, so sidecar is required | |
if (get_DD_TRACE_RESOURCE_RENAMING_ENABLED()) { |
ext/span.c
Outdated
#include "span.h" | ||
|
||
#include <SAPI.h> | ||
#include <Zend/zend_portability.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#include <Zend/zend_portability.h> |
ext/endpoint_guessing.c
Outdated
|
||
if (zend_hash_str_add(meta, ZEND_STRL("http.endpoint"), &endpoint_zv) == NULL) { | ||
zval_dtor(&endpoint_zv); | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return; |
Nit: redundant
ext/endpoint_guessing.c
Outdated
// handle the first char: is_int does not allow a leading 0 | ||
if (len > 0) { | ||
char c = path[0]; | ||
found_special_char = found_special_char || is_str_special(c); | ||
found_digit = found_digit || is_digit(c); | ||
|
||
uint8_t digit_mask = bool_to_mask(is_digit(c)) & (COMPONENT_IS_INT_ID | COMPONENT_IS_HEX | COMPONENT_IS_HEX_ID); | ||
|
||
// first char for is_int must be 1–9 | ||
uint8_t is_int_mask = bool_to_mask(is_nonzero_digit(c)) & COMPONENT_IS_INT; | ||
|
||
uint8_t hex_alpha_mask = bool_to_mask(is_hex_alpha(c)) & (COMPONENT_IS_HEX | COMPONENT_IS_HEX_ID); | ||
|
||
uint8_t delimiter_mask = bool_to_mask(is_delim(c)) & (COMPONENT_IS_INT_ID | COMPONENT_IS_HEX_ID); | ||
|
||
viable_components &= (digit_mask | is_int_mask | hex_alpha_mask | delimiter_mask | COMPONENT_IS_STR); | ||
} | ||
|
||
// Process remaining characters | ||
for (size_t i = 1; i < len; ++i) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// handle the first char: is_int does not allow a leading 0 | |
if (len > 0) { | |
char c = path[0]; | |
found_special_char = found_special_char || is_str_special(c); | |
found_digit = found_digit || is_digit(c); | |
uint8_t digit_mask = bool_to_mask(is_digit(c)) & (COMPONENT_IS_INT_ID | COMPONENT_IS_HEX | COMPONENT_IS_HEX_ID); | |
// first char for is_int must be 1–9 | |
uint8_t is_int_mask = bool_to_mask(is_nonzero_digit(c)) & COMPONENT_IS_INT; | |
uint8_t hex_alpha_mask = bool_to_mask(is_hex_alpha(c)) & (COMPONENT_IS_HEX | COMPONENT_IS_HEX_ID); | |
uint8_t delimiter_mask = bool_to_mask(is_delim(c)) & (COMPONENT_IS_INT_ID | COMPONENT_IS_HEX_ID); | |
viable_components &= (digit_mask | is_int_mask | hex_alpha_mask | delimiter_mask | COMPONENT_IS_STR); | |
} | |
// Process remaining characters | |
for (size_t i = 1; i < len; ++i) { | |
// first char for is_int must be 1–9 | |
viable_components &= (path[0] != '0') * COMPONENT_IS_INT; | |
for (size_t i = 0; i < len; ++i) { |
Let's avoid the duplication
ext/endpoint_guessing.c
Outdated
|
||
zval endpoint_zv; | ||
|
||
zval *url = zend_hash_str_find(meta, ZEND_STRL("http.url")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
zval *url = zend_hash_str_find(meta, ZEND_STRL("http.url")); | |
zval *url = zend_hash_str_find_deref(meta, ZEND_STRL("http.url")); |
ext/endpoint_guessing.c
Outdated
if (!url || Z_TYPE_P(url) != IS_STRING) { | ||
// "In case the url is not available, a default value of / should be used for the endpoint tag." | ||
ZVAL_STRING(&endpoint_zv, "/"); | ||
} else { | ||
zend_string* endpoint = guess_endpoint(Z_STRVAL_P(url), Z_STRLEN_P(url)); | ||
ZVAL_STR(&endpoint_zv, endpoint); | ||
} | ||
|
||
if (zend_hash_str_add(meta, ZEND_STRL("http.endpoint"), &endpoint_zv) == NULL) { | ||
zval_dtor(&endpoint_zv); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (!url || Z_TYPE_P(url) != IS_STRING) { | |
// "In case the url is not available, a default value of / should be used for the endpoint tag." | |
ZVAL_STRING(&endpoint_zv, "/"); | |
} else { | |
zend_string* endpoint = guess_endpoint(Z_STRVAL_P(url), Z_STRLEN_P(url)); | |
ZVAL_STR(&endpoint_zv, endpoint); | |
} | |
if (zend_hash_str_add(meta, ZEND_STRL("http.endpoint"), &endpoint_zv) == NULL) { | |
zval_dtor(&endpoint_zv); | |
zval *endpoint, endpoint_zv; | |
if ((endpoint = zend_hash_str_add(meta, ZEND_STRL("http.endpoint"), &endpoint_zv))) { | |
if (!url || Z_TYPE_P(url) != IS_STRING) { | |
// "In case the url is not available, a default value of / should be used for the endpoint tag." | |
ZVAL_STRING(endpoint, "/"); | |
} else { | |
ZVAL_STR(endpoint, guess_endpoint(Z_STRVAL_P(url), Z_STRLEN_P(url))); | |
} |
Simple way to only compute when needed, rather than destroying later.
Looks good so far - test failure are due to the sidecar requirement, but I anyway would not make it dependent on the sidecar anyway. |
Thanks @bwoebi I'll apply your changes. Do you think you could look at DataDog/libdatadog#1219 as well? |
@cataphract That's rather something for the data-pipeline team to review than for me. |
fd548e6
to
98ead20
Compare
Description
Implements [RFC-1051] APM endpoint resource renaming. See also DataDog/libdatadog#1219
Reviewer checklist