-
-
Notifications
You must be signed in to change notification settings - Fork 226
OpenTelemetry support #2434
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
OpenTelemetry support #2434
Conversation
|
|
@bruno-garcia what did you mean by "Missing a sample project (that is already in the solution filters).."? I assume you saw Samples.AspNetCore.OpenTelemetry/Sentry.Samples.AspNetCore.OpenTelemetry.csproj. |
|
I noticed some I also noticed almost the same in They're slightly different because they're targeting different HttpContext abstractions. var value = context.Request.Headers.Get(BaggageHeader.HttpHeaderName); // AspNet
var value = context.Request.Headers.GetValueOrDefault(BaggageHeader.HttpHeaderName); // AspNetCoreIt turns out, we also need something very similar in the SentryPropagator for Otel. A couple of questions:
|
I'd say rather not take a dependency on AspNetCore. Any use of OTel outside ASP.NET would have that dep and also would add another dependency to deal with versioning and breaking changes. Those two methods seem quite small. I'd say we could be pragmatic and copy them over but if I understand correctly the goal is to get the AspNetCore HTTP context object so we can read from it? If that's the case we need to consider introducing a new package like: That does take dep on
In any regard better to break the work up in parts, if we can do core bits first, we can follow up with AspNetCore after (we can leave AspNet out for the time being, possibly forever)
We've been passing |
Oh, right! I'll check on why it's erroring out on the solution filters then |
I think we could support Otel span processors without any dependency on However, propagation has an inherent dependency on the concept of "Http Headers", since that's how the trace id gets passed around (at least in Sentry's code - I'm not sure how it gets passed into things like DB servers). So I don't think we can include a solution for propagation without a dependency on Options for that:
|
…ntry-dotnet into feat/open-telemetry
The Dynamic Sampling Context ProblemThis is the bit that Matt was wrestling with when I started working on the PR, so probably worth documenting, as it's really not that obvious. The following is an explanation of what's going on in the Java implementation. We may have to get creative to solve in .NET as we don't have the same building blocks to work with that they did in Java. Java implementationIssue: Java SDK basic OTEL Support sentry-java#2327
Extracting.. which indirectly calls this overload, All the And that puts the data in something implementing
Where it does appear to be used is in When creating a new Sentry Span representing a Transaction, if that information is available then it's used to create Injecting DSC.. which eventually translates into: SentryTracer.updateBaggageValues ... and finally into: baggage.setValuesFromTransaction The Dynamic Sampling Context SolutionIn the .NET SDK the equivalent of the It turns out those properties are sufficient for our purposes. Some of the details required to create a DSC come from So we already have everything we need. We simply need to leverage these in |
|
|
||
| var activityContext = new ActivityContext( | ||
| sentryTraceHeader.TraceId.AsActivityTraceId(), | ||
| sentryTraceHeader.SpanId.AsActivitySpanId(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is possibly incorrect. The sentryTraceHeader.SpanId would be the Id of the upstream span right? Should we be using this to set the SpanTracer.ParentSpanId orTransactionTracer.ParentSpanId in the SentrySpanProcessor instead? And then we'd set the ActivityContext.SpanId here to ActivityId.GetRandom()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to be what the Java code is doing though...
final SpanId spanId = new SpanId(traceData.getSpanId());|
@bruno-garcia / @bitsandfoxes I think this is "first draft complete". Keen to get a proper review on this. Also, let me know if you can think of a more comprehensive way of integration testing this. Currently I'm using the following Python script, which makes a call to the import requests
import sentry_sdk
#
sentry_sdk.init(
dsn="yourDsnHere",
traces_sample_rate=1.0,
debug=True
)
def eat_slice(slice):
with sentry_sdk.start_span(description="Eat Slice") as span:
print(f'span.trace_id: {span.trace_id}')
print(f'span.span_id: {span.span_id}')
span.set_tag("slice.topping", slice)
response = requests.get('http://localhost:5092/hello')
print(response.status_code)
def eat_pizza():
while True:
user_input = input("What kind of pizza do you want to eat?")
if user_input.lower() == "quit":
break
else:
with sentry_sdk.start_transaction(op="task", name="Eat Pizza") as transaction:
print(f'transaction.trace_id: {transaction.trace_id}')
eat_slice(user_input)
eat_pizza()The
All of that then shows up in Sentry looks something like this: Maybe instead of calling it's own |
|
@bruno-garcia suggested creating a new PR for this so that I can get a review from him (rather than the other way around)... I'll close this PR and create a new one with all the relevant history/context then. |


PR from work done by Matt
TODO
Not planned
Exception.Datawhen callingRecordExceptionopen-telemetry/opentelemetry-dotnet#2439 (comment).This is something only our Javascript SDK has. None of the other Sentry SDKs support it.
It's not critical as we already capture errors through the normal exception handlers. It would only be an issue if a particular Otel instrumentation decided to not let exceptions bubble up, and only to report them as Otel events.