Hi there,
We'd like to take advantage of APM events and trace searching in Datadog, by adding custom tags to our ExpressJS and/or GraphQL spans, which are auto-instrumented.
Any examples on how to do this? I see there are some for Python/Ruby but none for Javascript.
For express and graphql, it would be possible to grab the current span by using the scope manager, for example tracer.scopeManager().active().span() and then calling span.addTags() from within a request or a resolver, respectively.
Complete example:
const scope = tracer.scopeManager().active()
const span = scope.span()
span.addTags({
foo: 'bar'
})
This is however only available for integrations where your code runs in the context of the integrations (i.e. web frameworks) but not for example for databases. If you have such use case, please provide more information about it as I think for that type of integration it will be case by case.
Please let me know if that doesn't work for your use case.
Closing the issue, but please let me know if you have further questions about this!
Most helpful comment
For
expressandgraphql, it would be possible to grab the current span by using the scope manager, for exampletracer.scopeManager().active().span()and then callingspan.addTags()from within a request or a resolver, respectively.Complete example:
This is however only available for integrations where your code runs in the context of the integrations (i.e. web frameworks) but not for example for databases. If you have such use case, please provide more information about it as I think for that type of integration it will be case by case.
Please let me know if that doesn't work for your use case.