Skip to content

Start Span from callback, finish from another #11582

Answered by lforst
ThHareau asked this question in Q&A
Discussion options

You must be logged in to vote

To get this working I recommend using startInactiveSpan, to get a span instance, then wrap your event handler code in withActiveSpan(span, () => { ... }).

Additionally, you will have to store the span instance somewhere to be able to finish it from the other event handler. You could use a WeakMap or pass the events a shared reference that they can write the span to and read the span off of.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@ThHareau
Comment options

@lforst
Comment options

Answer selected by ThHareau
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants