-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Sentry.getCurrentHub().getScope().getTransaction()
does not find transaction when using otel
#7985
Comments
Hey @md384 this is intentional! When you set Instead we recommend you grab the active span off via the otel APIs, and use that to add a const activeSpan = opentelemetry.trace.getActiveSpan();
const { traceId, spanId } = activeSpan.spanContext();
const sentryTrace = `${traceId}-${spanId}-1`; then when you inject <html>
<head>
<meta name="sentry-trace" content="{{ sentryTrace }}" />
</head>
</html> You shouldn't need a baggage header here! |
@AbhiPrasad can we get a helper function in the |
For what it is worth, our internal helper: import { context, trace } from '@opentelemetry/api';
export const findSentryTrace = () => {
const activeContext = context.active();
const activeSpan = trace.getSpan(activeContext);
if (!activeSpan) {
return null;
}
const { spanId, traceId } = activeSpan.spanContext();
const sentryTrace = `${traceId}-${spanId}-1`;
// Note that we do not need the `baggage` header.
// @see https://github.com/getsentry/sentry-javascript/issues/7985#issuecomment-1529060940
return {
sentryTrace,
};
}; |
Heads up that the From conversation with Sentry support:
You need to adjust this value accordingly as otherwise every request will get sampled. |
Related thread #7538 |
Is there an existing issue for this?
How do you use Sentry?
Self-hosted/on-premise
Which SDK are you using?
@sentry/opentelemetry-node
SDK Version
7.49.0
Framework Version
No response
Link to Sentry event
No response
SDK Setup
Steps to Reproduce
I am trying to connect server and browser services with https://docs.sentry.io/platforms/javascript/performance/connect-services/#pageload so need to get the current transaction.
Expected Result
Expect the same transaction
Actual Result
The text was updated successfully, but these errors were encountered: