Conversation
| dd_start_span(INTERNAL_FUNCTION_PARAM_PASSTHRU); | ||
| } | ||
|
|
||
| /* {{{ proto InferredSpanData\null DDTrace\start_inferred_span(array $headers, SpanData $rootSpan) */ |
There was a problem hiding this comment.
I had the suggestion of getting rid of this function and instead putting the logic into consume_distributed_tracing_headers(). Did this not work out?
There was a problem hiding this comment.
Oops, forgot about it. Will try it out 👍
| if (span->std.ce == ddtrace_ce_root_span_data) { | ||
| ddtrace_root_span_data *root = ROOTSPANDATA(&span->std); | ||
| zval *inferred_span_zv = &root->property_inferred_span; | ||
| if (Z_TYPE_P(inferred_span_zv) == IS_OBJECT) { |
There was a problem hiding this comment.
could you please add a condition that the inferred_span property is actually an instance of ddtrace_ce_inferred_span_data?
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3116 +/- ##
============================================
+ Coverage 52.26% 56.98% +4.71%
Complexity 2883 2883
============================================
Files 114 141 +27
Lines 11438 15844 +4406
Branches 0 1094 +1094
============================================
+ Hits 5978 9028 +3050
- Misses 5460 6243 +783
- Partials 0 573 +573
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
Benchmarks [ tracer ]Benchmark execution time: 2025-03-28 19:58:05 Comparing candidate commit ddc3c19 in PR branch Found 0 performance improvements and 7 performance regressions! Performance is the same for 171 metrics, 0 unstable metrics. scenario:ContextPropagationBench/benchExtractHeaders128Bit
scenario:ContextPropagationBench/benchExtractHeaders128Bit-opcache
scenario:ContextPropagationBench/benchExtractTraceContext128Bit
scenario:ContextPropagationBench/benchExtractTraceContext128Bit-opcache
scenario:ContextPropagationBench/benchExtractTraceContext64Bit
scenario:ContextPropagationBench/benchExtractTraceContext64Bit-opcache
scenario:TraceFlushBench/benchFlushTrace
|
| }) | ||
|
|
||
| if (inferred_span) { | ||
| ddtrace_serialize_span_to_array(inferred_span, array); |
There was a problem hiding this comment.
I would prefer if we could do all the transfer_data calls here (from serialized to inferred serialized), after the serializing step. But I won't insist.
| } | ||
|
|
||
| if (inferred_span) { | ||
| ddtrace_serialize_span_to_array(inferred_span, array); |
There was a problem hiding this comment.
You could make ddtrace_serialize_span_to_array return the inserted array instead of refetching from Z_ARR_P(array).
|
|
||
| add_next_index_zval(array, el); | ||
|
|
||
| return el; |
There was a problem hiding this comment.
noooo :-D
That returns a stack variable.
Use
return zend_hash_next_index_insert(Z_ARR_P(array), el);
(instead of add_next_index_zval)
| ZVAL_OBJ(&root->property_inferred_span, &span->std); | ||
|
|
||
| span->span_id = ddtrace_generate_span_id(); | ||
| ddtrace_set_global_span_properties(span); |
There was a problem hiding this comment.
Move this to the end of this function or e.g. DD_TAGS=stage:1 will lead to a memory leak
| bool is_root_span = span->std.ce == ddtrace_ce_root_span_data; | ||
| zval meta_zv, *meta = &span->property_meta; | ||
| bool is_inferred_span = span->std.ce == ddtrace_ce_inferred_span_data; | ||
| zval meta_zv, *meta = &span->property_meta, *inferred_span_zv = NULL; |
There was a problem hiding this comment.
| zval meta_zv, *meta = &span->property_meta, *inferred_span_zv = NULL; | |
| zval meta_zv, *meta = &span->property_meta; | |
| ddtrace_span_data *inferred_span = NULL; | |
| if (is_root_span) { | |
| inferred_span = ddtrace_get_inferred_span(ROOTSPANDATA(&span->std)); | |
| } |
and then if(inferred_span) ...
Let's check it consistently the same way.
| "resource": "GET /test", | ||
| "trace_id": 0, | ||
| "span_id": 1, | ||
| "parent_id": 3978455880403641907, |
There was a problem hiding this comment.
Can this assert that "error": 1, for the aws api gateway span too?
There was a problem hiding this comment.
That's a crazy catch. I see why.
|
|
||
| read_header((zai_str)ZAI_STRL("X_DD_PROXY_PATH"), "x-dd-proxy-path", &result.path, data); | ||
| read_header((zai_str)ZAI_STRL("X_DD_PROXY_HTTPMETHOD"), "x-dd-proxy-httpmethod", &result.http_method, data); | ||
| read_header((zai_str)ZAI_STRL("X_DD_PROXY_DOMAIN_NAME"), "x-dd-proxy-domain-name", &result.domain, data); |
There was a problem hiding this comment.
What is the value of the service if x-dd-proxy-domain-name is not provided?
There was a problem hiding this comment.
(Asking because it's unclear to me from the test what happens)
There was a problem hiding this comment.
If I read the code correctly, service then is never assigned and falls back to the empty string.
There was a problem hiding this comment.
If there's no fallback we should try to use DD_SERVICE where possible so we don't send the span with an empty service name.
There was a problem hiding this comment.
Modified to fallback to the root span's service name. I can modify it to strictly be DD_SERVICE, but then we'd have to have some special handling when altering DD_SERVICE (+The service is sometimes inferred from the app config - e.g. Laravel).
There was a problem hiding this comment.
I think the new behaviour is perfectly fine.
There was a problem hiding this comment.
Looping in @zarirhamza in case he has other feedback about this!
| transfer_data(serialized_meta, serialized_inferred_span_meta, ZEND_STRL("error"), false); | ||
| transfer_data(serialized_meta, serialized_inferred_span_meta, ZEND_STRL("track_error"), false); | ||
| transfer_data(Z_ARR_P(el), Z_ARR_P(serialized_inferred_span), ZEND_STRL("error"), false); | ||
| transfer_data(Z_ARR_P(el), Z_ARR_P(serialized_inferred_span), ZEND_STRL("track_error"), false); |
There was a problem hiding this comment.
track_error is in meta though, right? Only array is top-level.
There was a problem hiding this comment.
Is it? I looked at the following line, and considering that it is added the same way as error is, I would have assumed that it wasn't
There was a problem hiding this comment.
You are right, but that's because the code adding track_error is wrong :-( Should be on meta...
Could you please fix it over there in this PR?
There was a problem hiding this comment.
Ok 👍 Will do in the next commit
# Conflicts: # ext/configuration.h # ext/ddtrace_arginfo.h # tests/Frameworks/Laravel/Latest/.env # tests/Integrations/CLI/Laravel/Latest/CommonScenariosTest.php # tests/Integrations/Laravel/Latest/CommonScenariosTest.php
Signed-off-by: Bob Weinand <[email protected]>
Signed-off-by: Bob Weinand <[email protected]>
7255612 to
088b3a2
Compare
Signed-off-by: Bob Weinand <[email protected]>
f234ee7 to
553515e
Compare
…DM-548_api-gateway-ter
Description
Based on the following implementation doc: GDoc
Reviewer checklist