Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Ability to create not started span or manual assign parent span #5442

Open
mharj opened this issue Feb 10, 2025 · 0 comments
Open

Ability to create not started span or manual assign parent span #5442

mharj opened this issue Feb 10, 2025 · 0 comments

Comments

@mharj
Copy link

mharj commented Feb 10, 2025

Is your feature request related to a problem? Please describe.

I'm implmenting spans to track progress and I think when callback is triggered from outside of scope we loose span hierarcy.
My current hack is to create tracer.startSpan early, but then I can't really see actual call runtime.

Describe the solution you'd like

const abortSpan = tracer.createSpan('abort-callback');

const onAbortCallback = () => {
  abortSpan.start();
  ...
  abortSpan.end();
}
signal.addEventListener('abort', onAbortCallback );

Or alteratively, ability to make manual link to parent Span when starting new span.

const onAbortCallback = () => {
  return tracer.startActiveSpan('abort-callback', {parent: parenSpan}),  (abortSpan) => {
    abortSpan.start();
    ...
    abortSpan.end();
  });
}
signal.addEventListener('abort', onAbortCallback );

Or create some sort ref like SpanRef which can be still ref.startActiveSpan() to keep span ref in scope.

Describe alternatives you've considered

Create tracer.startSpan early, but this loses actualy time used on callback.
Tested also binding callback in many different ways, but this just looses tracer hierarcy if not created before actual call.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

1 participant