Mixing manual spans with auto instrumentation (fetch) #2004
-
I've created an end-to-end demo for otel (https://github.com/treactor) with backend/frontend/collector. In the Javascript for web part. I'm having trouble with mixing auto instrumentation and manual spans. In the below code I want to start a manual span and I want to fetch (auto instrumented) to be the child of my manual span. I know the below code is wrong, it results in 2 separate unconnected spans. I think I need to use the context.when but didn't see any examples of the usage. Help is appreciated. Thanks.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
You have to create a new context holding your span and run the fetch code with this context set as active. see e.g. opentelemetry-js/examples/tracer-web/examples/fetch/index.js Lines 53 to 54 in 71ba83a |
Beta Was this translation helpful? Give feedback.
You have to create a new context holding your span and run the fetch code with this context set as active.
see e.g.
opentelemetry-js/examples/tracer-web/examples/fetch/index.js
Lines 53 to 54 in 71ba83a