Socket
Socket
Sign inDemoInstall

@sentry/opentelemetry

Package Overview
Dependencies
31
Maintainers
11
Versions
95
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @sentry/opentelemetry

Official Sentry utilities for OpenTelemetry


Version published
Maintainers
11
Created

Changelog

Source

8.9.1

Important changes

  • feat(solid): Add Solid SDK

    This release adds a dedicated SDK for Solid JS in alpha state with instrumentation for Solid Router and a custom ErrorBoundary. See the package README for how to use the SDK.

Other changes

  • feat(deps): bump @opentelemetry/instrumentation-express from 0.40.0 to 0.40.1 (#12438)
  • feat(deps): bump @opentelemetry/instrumentation-mongodb from 0.44.0 to 0.45.0 (#12439)
  • feat(deps): bump @opentelemetry/propagator-aws-xray from 1.24.1 to 1.25.0 (#12437)
  • feat(nextjs): Allow for suppressing warning about missing global error handler file (#12369)
  • feat(redis): Add cache logic for redis-4 (#12429)
  • feat(replay): Replay Web Vital Breadcrumbs (#12296)
  • fix: Fix types export order (#12404)
  • fix(astro): Ensure server-side exports work correctly (#12453)
  • fix(aws-serverless): Add op to Otel-generated lambda function root span (#12430)
  • fix(aws-serverless): Only auto-patch handler in CJS when loading awslambda-auto (#12392)
  • fix(aws-serverless): Only start root span in Sentry wrapper if Otel didn't wrap handler (#12407)
  • fix(browser): Fix INP span creation & transaction tagging (#12372)
  • fix(nextjs): correct types conditional export ordering (#12355)
  • fix(replay): Fix guard for exception event (#12441)
  • fix(vue): Handle span name assignment for nested routes in VueRouter (#12398)

Work in this release was contributed by @soch4n. Thank you for your contribution!

Readme

Source

Sentry

Official Sentry SDK for OpenTelemetry

npm version npm dm npm dt

This package allows you to send your OpenTelemetry trace data to Sentry via OpenTelemetry SpanProcessors.

This SDK is considered experimental and in an alpha state. It may experience breaking changes. Please reach out on GitHub if you have any feedback/concerns.

Installation

npm install @sentry/opentelemetry

# Or yarn
yarn add @sentry/opentelemetry

Note that @sentry/opentelemetry depends on the following peer dependencies:

  • @opentelemetry/api version 1.0.0 or greater
  • @opentelemetry/core version 1.0.0 or greater
  • @opentelemetry/semantic-conventions version 1.0.0 or greater
  • @opentelemetry/sdk-trace-base version 1.0.0 or greater, or a package that implements that, like @opentelemetry/sdk-node.

Usage

This package exposes a few building blocks you can add to your OpenTelemetry setup in order to capture OpenTelemetry traces to Sentry.

This is how you can use this in your app:

  1. Initialize Sentry, e.g. @sentry/node!
  2. Call setupEventContextTrace(client)
  3. Add SentrySampler as sampler
  4. Add SentrySpanProcessor as span processor
  5. Add a context manager wrapped via wrapContextManagerClass
  6. Add SentryPropagator as propagator
  7. Setup OTEL-powered async context strategy for Sentry via setOpenTelemetryContextAsyncContextStrategy()

For example, you could set this up as follows:

import * as Sentry from '@sentry/node';
import {
  SentryPropagator,
  SentrySampler,
  SentrySpanProcessor,
  setupEventContextTrace,
  wrapContextManagerClass,
  setOpenTelemetryContextAsyncContextStrategy,
} from '@sentry/opentelemetry';
import { AsyncLocalStorageContextManager } from '@opentelemetry/context-async-hooks';

function setupSentry() {
  Sentry.init({
    dsn: 'xxx',
  });

  const client = Sentry.getClient();
  setupEventContextTrace(client);

  const provider = new BasicTracerProvider({
    sampler: new SentrySampler(client),
  });
  provider.addSpanProcessor(new SentrySpanProcessor());

  const SentryContextManager = wrapContextManagerClass(AsyncLocalStorageContextManager);

  // Initialize the provider
  provider.register({
    propagator: new SentryPropagator(),
    contextManager: new SentryContextManager(),
  });

  setOpenTelemetryContextAsyncContextStrategy();
}

A full setup example can be found in node-experimental.

FAQs

Last updated on 11 Jun 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc