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

Improve distributed tracing custom instrumentation #11774

Open
AbhiPrasad opened this issue Apr 24, 2024 · 1 comment
Open

Improve distributed tracing custom instrumentation #11774

AbhiPrasad opened this issue Apr 24, 2024 · 1 comment

Comments

@AbhiPrasad
Copy link
Member

AbhiPrasad commented Apr 24, 2024

Right now to implement distributed tracing with the JS SDK, it is a bit confusing. The docs jump back and forth between different concepts: https://docs.sentry.io/platforms/javascript/distributed-tracing/custom-instrumentation/

and attaching headers requires both @sentry/core and @sentry/utils to be installed.

import * as Sentry from '@sentry/node';
import { spanToTraceHeader, getDynamicSamplingContextFromSpan } from '@sentry/core';
import { dynamicSamplingContextToSentryBaggageHeader } from '@sentry/utils';
app.get('/v1/metrics', (req, res, next) => helpers.authenticated(req, res, next), async (req, res) => {
  await Sentry.startSpan(
    {
      name: 'enqueue metrics job',
      op: 'queue.submit',
      attributes: {
      },
    },
    async (span) => {
      const traceHeader = spanToTraceHeader(span);
      const dynamicSamplingContext = getDynamicSamplingContextFromSpan(span);
      const baggageHeader = dynamicSamplingContextToSentryBaggageHeader(dynamicSamplingContext);
      console.info(traceHeader, baggageHeader);
    },
  );
  res.send('ok');
});

We need to restructure the docs, and make sure all relevant methods are accessible via @sentry/browser and @sentry/node.

@AbhiPrasad
Copy link
Member Author

Related #11199

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant