fix(otel): end all recording spans on non-terminal invocations - #633
fix(otel): end all recording spans on non-terminal invocations#633ayushiahjolia wants to merge 1 commit into
Conversation
This comment has been minimized.
This comment has been minimized.
895352f to
4c2aec6
Compare
This comment has been minimized.
This comment has been minimized.
4c2aec6 to
fcd7317
Compare
This comment has been minimized.
This comment has been minimized.
fcd7317 to
b865c79
Compare
| if (sdkTracerProvider == null) { | ||
| return TraceFlags.getSampled(); |
There was a problem hiding this comment.
Codex AI review
[P1] Do not assume an opaque agent provider is sampled
In the recommended no-arg Java-agent path, the provider is commonly hidden behind a classloader wrapper, making sdkTracerProvider null regardless of its sampler. Marking the synthetic Workflow parent sampled causes ExecutionOtelPlugin operations to export under a parent-based sampler even when the terminal Workflow root is dropped, producing orphan spans. Bridge the actual sampling result through the auto-configuration/classloader boundary and add a wrapped-provider test with a root-dropping sampler.
| var decision = sdkTracerProvider | ||
| .getSampler() | ||
| .shouldSample( | ||
| Context.root(), | ||
| workflowTraceId, | ||
| workflowSpanName, | ||
| SpanKind.INTERNAL, | ||
| Attributes.empty(), | ||
| Collections.emptyList()) | ||
| .getDecision(); | ||
| return decision == SamplingDecision.RECORD_AND_SAMPLE ? TraceFlags.getSampled() : TraceFlags.getDefault(); |
There was a problem hiding this comment.
Codex AI review
[P2] Reuse the Workflow root's exact sampling result
This probe uses empty attributes, while the real Workflow span is sampled with durable.execution.arn; the terminal span also invokes the sampler a second time. Attribute-based or stateful/rate-limiting samplers can therefore give the synthetic context and real root different decisions, and sampler-updated trace state is discarded. Query with the real attributes and preserve the complete SamplingResult through a sampler wrapper/cache so the terminal root reuses it. Add attribute-dependent and stateful sampler tests.
Codex AI reviewTwo sampling-consistency regressions need correction before merge. Current tests cover only visible, deterministic samplers, missing the Java-agent and stateful-sampler failure modes. Reviewed commit |
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Issue Link, if available
#624
Description
Demo/Screenshots
N/A
Checklist
Testing
Unit Tests
Have unit tests been written for these changes? Yes, updated
Integration Tests
Have integration tests been written for these changes? N/A
Examples
Has a new example been added for the change? (if applicable) N/A