Skip to content

Commit

Permalink
cleanup(pubsub): dont link invalid messages (#13649)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbolduc authored Feb 23, 2024
1 parent 13b738f commit ed1212b
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,13 @@ StatusOr<pubsub::PullResponse> EndPullSpan(
/*sc::kMessagingMessageEnvelopeSize=*/"messaging.message.envelope.size",
static_cast<std::int64_t>(MessageSize(message)));

auto current = opentelemetry::context::RuntimeContext::GetCurrent();
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.
if (!(current == context) && producer_span_context.IsSampled() &&
producer_span_context.IsValid()) {
#if OPENTELEMETRY_ABI_VERSION_NO >= 2
span->AddLink(producer_span_context, {});
#else
Expand Down

0 comments on commit ed1212b

Please sign in to comment.