Skip to content
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

Composite propagation doesn't work because the last propagator sets the span, potentially invalid, even if the previous one finds a valid span #2504

Closed
ecourreges-orange opened this issue Jan 23, 2024 · 1 comment · Fixed by #2511
Assignees
Labels
bug Something isn't working triage/accepted Indicates an issue or PR is ready to be actively worked on.

Comments

@ecourreges-orange
Copy link
Contributor

Describe your environment
v1.13.0 using bazel

Steps to reproduce
Remove this line from the unit test:

{"b3", "80f198ee56343ba864fe8b2a57d3eff7-e457b5a2e4d86bd1-1-05e3ac9a4f6e3b90"}};

And you will see that the resulting traceId is 0000000..., whereas it should be the one from the valid traceparent header line 79.

What is the expected behavior?
The composite propagator should only set the active_span in the context to a valid one

What is the actual behavior?
The composite propagator sets the active_span at each propagator in its list, whatever the outcome, so the last one always wins, even if invalid.
You can see here:


and here:

Additional context
I see 3 ways of fixing it.

  • disallow setting invalid spans with SetSpan? But then it might affect many parts of the code?
  • CompositePropagator to do the filtering? Sounds complex because CompositePropagator does not know what is written to the context by the Extractors.
  • I think the best and pretty simple is in all propagators to replace the line that does return trace::SetSpan(context, sp); with these:
    if (span_context.IsValid()) 
    {
      return trace::SetSpan(context, sp);
    } else {
      return context;
    }

If you agree, I will post a PR with that.

@ecourreges-orange ecourreges-orange added the bug Something isn't working label Jan 23, 2024
@github-actions github-actions bot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Jan 23, 2024
@lalitb
Copy link
Member

lalitb commented Jan 24, 2024

@ecourreges-orange Yes, this is a valid issue. The proposal (third option) looks good, feel free to raise a PR for this. Thanks.

@marcalff marcalff added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Jan 24, 2024
ecourreges-orange added a commit to ecourreges-orange/opentelemetry-cpp that referenced this issue Jan 25, 2024
… span with a default invalid span, which is especially useful when used with CompositePropagator (open-telemetry#2504)

Change wrong string "current-span" in unit tests to proper trace:kSpan which is "active_span"
ecourreges-orange added a commit to ecourreges-orange/opentelemetry-cpp that referenced this issue Jan 25, 2024
… active span with a default invalid span, which is especially useful when used with CompositePropagator (open-telemetry#2504)

Change wrong string "current-span" in unit tests to proper trace:kSpan which is "active_span"
ecourreges-orange added a commit to ecourreges-orange/opentelemetry-cpp that referenced this issue Jan 25, 2024
… active span with a default invalid span, which is especially useful when used with CompositePropagator (open-telemetry#2504)

[TEST] Change wrong string "current-span" in unit tests to proper trace:kSpan which is "active_span"
ecourreges-orange added a commit to ecourreges-orange/opentelemetry-cpp that referenced this issue Jan 25, 2024
… active span with a default invalid span, which is especially useful when used with CompositePropagator (open-telemetry#2504)

[TEST] Change wrong string "current-span" in unit tests to proper trace:kSpan which is "active_span"
ecourreges-orange added a commit to ecourreges-orange/opentelemetry-cpp that referenced this issue Jan 25, 2024
… active span with a default invalid span, which is especially useful when used with CompositePropagator (open-telemetry#2504)

[TEST] Change wrong string "current-span" in unit tests to proper trace:kSpan which is "active_span"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
3 participants