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

cleanup(pubsub): don't link invalid messages #13649

Merged
merged 1 commit into from
Feb 23, 2024
Merged

Conversation

dbolduc
Copy link
Member

@dbolduc dbolduc commented Feb 23, 2024

Unblocks #13627

The propagator used for messages is a no-op if the incoming span is invalid:

https://github.com/open-telemetry/opentelemetry-cpp/blob/4eb99f9e05f45c0ea1461858417e7e52135874c5/api/include/opentelemetry/trace/propagation/http_trace_context.h#L45-L48

In this case, our message receiver does not add a new context to the stack:

https://github.com/open-telemetry/opentelemetry-cpp/blob/4eb99f9e05f45c0ea1461858417e7e52135874c5/api/include/opentelemetry/trace/propagation/http_trace_context.h#L63

The latest update to opentelemetry-cpp copies trace flags from the current context:

https://github.com/open-telemetry/opentelemetry-cpp/blob/423ecacdf62196731d888621e0dfa2e8cc023b4a/sdk/src/trace/tracer.cc#L64

So we should check that the contexts are not equal.


This change is Reviewable

@product-auto-label product-auto-label bot added the api: pubsub Issues related to the Pub/Sub API. label Feb 23, 2024
@alevenberg alevenberg changed the title cleanup(pubsub): dont link invalid messages cleanup(pubsub): don't link invalid messages Feb 23, 2024
auto context = ExtractTraceContext(message, *propagator);
auto producer_span_context =
opentelemetry::trace::GetSpan(context)->GetContext();
if (producer_span_context.IsSampled() && producer_span_context.IsValid()) {
// If the contexts are equal, the message span was invalid.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to self:

I don't think the producer_span_context.IsValid() line checks anything, that's what the check darren is adding will now check.

If the current context is equal to the extracted context, it means that the context was not valid.

@dbolduc dbolduc marked this pull request as ready for review February 23, 2024 00:51
@dbolduc dbolduc requested a review from a team as a code owner February 23, 2024 00:51
@dbolduc dbolduc enabled auto-merge (squash) February 23, 2024 00:52
@dbolduc dbolduc merged commit ed1212b into googleapis:main Feb 23, 2024
62 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: pubsub Issues related to the Pub/Sub API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants