-
Notifications
You must be signed in to change notification settings - Fork 213
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
Export spanFromContext
#452
Conversation
Matches the logic from `TransactionFromContext` and returns nil. This is idiomatic and does what it says on the tin, if the context does not have a span contained within it, I would not expect anything to be returned. An error seems... extra.
Hi @GTB3NW! What are you going to use |
Hey, I'm working on a proof of concept at the moment to present this. At the moment the trace and span are sent over the network to remote systems, that means a new span can be created which links to the previous span. The internals of the sentry sdk then see a parentspan id (without a parent span pointer) and a new transaction can be started. This becomes a problem if your edge is not network based. If I want to create a new transaction linked to an existing one and as a child of a span it's impossible without exposing the trace id & most importantly the span id, this allows me to do it in one fell swoop. As you noted in the todo there's other use cases such as modifying instrumented spans from middleware etc. Once I've got the proof of concept sorted I'll send it over if it helps demonstrate the problem. |
Would be interesting to see more details on the PoC :-)
Trace propagation is done with a
That's right. The "transaction" concept is however so central to Sentry's tracing such that without an associated transaction all span data is garbage collected. In this model, user code can always poke at the spans starting off a transaction. |
Just packaging it up now
Yeah I saw that function but without any way to the data required for the function it's useless. I wouldn't mind adding a function to extract that data from a context as you say. I think my next PR may be a bit more controversial than that change :P
I'll be honest I'm less bothered about that use case, I personally wouldn't be a user of it, however I am working on some middleware which does need the span/traceid, so less about mutation and more about information :) |
Okay, I've created the POC over - https://github.com/GTB3NW/sentry-poc |
I've got an idea for an alternative setup to achieve what I'm trying to do. I'm not as familiar with the internals as you are but in theory I could add a new function to sentry-go which returns a span option which mutates the required fields (which aren't exposed). I don't think we should tack it on to the existing |
Matches the logic from
TransactionFromContext
and returns nil.This is idiomatic and does what it says on the tin, if the context
does not have a span contained within it, I would not expect anything
to be returned. An error seems... extra.