getsentry / sentry-docs

Sentry's documentation (and tools to build it)
https://docs.sentry.io
Other
326 stars 1.43k forks source link

Manual Trace Propagation missing in docs #11127

Open thinkocapo opened 3 weeks ago

thinkocapo commented 3 weeks ago

Core or SDK?

Platform/SDK

Which part? Which one?

Browser JS and Node JS

Description

We show Automatica Trace Propagation where the sentry sdk adds a sentry-trace header for you. What about if you need to obtain this sentry-trace id yourself and do something with it?

What if you have trace id's coming from a different vendor sdk or trace system and you want to set it as a custom tag in the sentry sdk?

Image

Suggested Solution

"You're either propagating a trace into Sentry, or you're propagating a trace out of sentry and into somewhere else. Here are both techniques 1,2"

  1. Set the Trace Id onto Sentry - code example showing something like
    // parse it from wherever you have it already
    traceId = my_non-sentrytrace.getTraceID()
    sentrySDK.setTag("non-sentrytraceId", traceId)
  2. Get the Sentry Trace Id and Set it Somewhere Else
    beforeSendTransaction(transction) {
    sentryTraceId = transaction.traceId
    // do something with your sentryTraceId...propagate it
    }

    and this is an option too:

    // you can do this while the transaction is still being recorded, you don't have to wait for beforeSendTransaction
    sentryTraceId = sentrysdk.scope.traceId
    // do something with your sentryTraceId...propagate it

    Something I wrote to a customer, he siad it made sense, "There are sdk callback functions that execute right before the sentry_sdk sends the event to Sentry, and during that callback you can analyze the event and obtain properties off of it (like sentry-traceId). beforeSendTransaction"

getsantry[bot] commented 3 weeks ago

Auto-routing to @getsentry/product-owners-issues for triage ⏲️

getsantry[bot] commented 3 weeks ago

Routing to @getsentry/product-owners-sdks-web-frontend for triage ⏲️

getsantry[bot] commented 3 weeks ago

Routing to @getsentry/product-owners-sdks-web-backend for triage ⏲️

smeubank commented 2 weeks ago

https://stackoverflow.com/questions/78895484/how-to-integrate-client-side-sentry-tracing-with-micrometer-and-opentelemetry-in

potentially related

smeubank commented 2 weeks ago

regarding standards and compatibility across stacks and vendors

https://github.com/getsentry/team-sdks/issues/41

@cleptric i believe there was an issue that came up which forced us to rollback some of the changes

cleptric commented 2 weeks ago

We need better controls how people can opt-out of traces being continued from an unknown 3rd party before we can implement the W3C tracepreant header in more SDKs. This will be part of the overall Span Streaming work we will kick-off soon.

mydea commented 1 week ago

FWIW we have these docs here: https://docs.sentry.io/platforms/javascript/guides/react/tracing/trace-propagation/custom-instrumentation/#inject-tracing-information-into-outgoing-requests which explain how to extract trace propagation data. IMHO that should cover manual use cases as well?