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

add withSpan and withTransaction API #2983

Open
trentm opened this issue Oct 13, 2022 · 0 comments
Open

add withSpan and withTransaction API #2983

trentm opened this issue Oct 13, 2022 · 0 comments
Labels
8.9-candidate agent-nodejs Make available for APM Agents project planning.

Comments

@trentm
Copy link
Member

trentm commented Oct 13, 2022

This issue is to add a apm.withSpan(options, fn) API (and similar for withTransaction) that critically takes a function to which the new RunContext is bound. This would avoid the #2611 footgun that startSpan and startTransaction apply. A possible result of that footgun is shown and discussed at #2929.

Adding this API has been considered since the RunContext work.

A good test of this functionality would be whether it could fully or significantly replace the withApmSpan helper in Kibana (see https://github.com/elastic/kibana/blob/main/x-pack/plugins/apm/server/utils/with_apm_span.ts and https://github.com/elastic/kibana/blob/main/packages/kbn-apm-utils/index.ts).

This apm.withSpan() would be the equivalent of OTel JS's tracer.startActiveSpan(). The OTel tracer.startSpan() is already roughly equivalent to our internal createSpan() -- which was added in the RunContext work to cope with the apm.startSpan() footgun.

Eventually I think these APIs should be preferred and startSpan() and startTransaction() APIs should be deprecated.

@github-actions github-actions bot added the agent-nodejs Make available for APM Agents project planning. label Oct 13, 2022
@estolfo estolfo added this to the 8.7 milestone Nov 21, 2022
@trentm trentm removed this from the 8.7 milestone Apr 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.9-candidate agent-nodejs Make available for APM Agents project planning.
Projects
None yet
Development

No branches or pull requests

2 participants