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

Set the scope transaction for Otel transactions #3072

Merged
merged 3 commits into from
Jan 23, 2024
Merged

Conversation

jamescrosswell
Copy link
Collaborator

@jamescrosswell jamescrosswell commented Jan 22, 2024

Resolves #3061

Problem Summary

The SentrySpanProcessor wasn't setting the Scope.Transaction... so when using OpenTelemetry this was returning null:

var transaction = _hub.GetTransactionIfSampled();
if (transaction == null)
{
return;
}

Consequently the integrations weren't able to create DB Spans under the DB Root.

Copy link

codecov bot commented Jan 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (b72b9e7) 76.42% compared to head (3a06c35) 76.45%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3072      +/-   ##
==========================================
+ Coverage   76.42%   76.45%   +0.03%     
==========================================
  Files         351      351              
  Lines       13263    13259       -4     
  Branches     2646     2644       -2     
==========================================
+ Hits        10136    10137       +1     
+ Misses       2450     2446       -4     
+ Partials      677      676       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jamescrosswell jamescrosswell marked this pull request as ready for review January 23, 2024 00:58
@@ -275,14 +275,6 @@ internal TransactionTracer(IHub hub, ITransactionContext context, TimeSpan? idle
internal ISpan StartChild(SpanId? spanId, SpanId parentSpanId, string operation,
Instrumenter instrumenter = Instrumenter.Sentry)
{
if (instrumenter != _instrumenter)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this no longer needed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not sure if it was ever needed to be honest.

If the instrumenter is OpenTelemetry then we don't want our own Asp.NET Core integration also trying to instrument the same requests... so I can see why we might throw if an attempt is made to create a new transaction using the Sentry Hub.

I can't see any reason to prevent adding children to transactions that have already been created however.

I think this code was Matt's originally (I took it over part way through the PR)... so I'm not sure what his original reasoning was (I'm just guessing at it).

The alternative would be for calling methods in our own code to check what the current instrumenter is and pass that in as a parameter so as to sidestep the above check... that seemed like a weird solution. Those spans aren't actually coming from OpenTelemetry (they're coming from a Sentry integration). It seemed more honest just to admit that actually we're going to have Sentry child spans of OpenTelemetry transaction spans.

@bitsandfoxes bitsandfoxes merged commit 947dac4 into main Jan 23, 2024
23 checks passed
@bitsandfoxes bitsandfoxes deleted the query-tracking-3061 branch January 23, 2024 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enabling Open Telemetry Breaks Query Tracking (4.0.0-beta.8)
2 participants