JSPM

@vercel/otel

0.3.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1624712
  • Score
    100M100P100Q199643F
  • License MIT

Vercel wrapper around OpenTelemetry APIs

Package Exports

  • @vercel/otel

Readme

๐Ÿš€ Vercel Otel

npm

Note: This package is experimental. It doesn't follow semver yet. Minors can contain breaking changes.

@vercel/otel is a simple and easy-to-use package that sets up your trace provider and exporter.

๐Ÿ’ก Use this package to quickly instrument your applications and get started with OpenTelemetry!

๐Ÿ“ฆ Installation

npm install @vercel/otel

๐Ÿ“š Usage

import { registerOTel } from "@vercel/otel";
import { trace } from "@opentelemetry/api";

// Register the OpenTelemetry provider with an GRPC exporter
registerOTel("your-service-name");

// Now you can use the OpenTelemetry APIs
const span = trace.getTracer("your-component").startSpan("your-operation");

๐Ÿ“– API Reference

registerOTel(serviceName: string)

Registers the OpenTelemetry provider with an OTLP exporter using the given service name. This is all that is needed to trace your app on Vercel or any other platform exposing its own OpenTelemetry Collector.

  • serviceName: The name of your service, used as the app name in many OpenTelemetry backends.

๐Ÿงช What exactly is this package doing

This package utilizes the exports API, enabling us to import the OpenTelemetry SDK in Node only. When you import registerOTel in a file intended for the edge, it returns an empty function because OpenTelemetry doesn't support the edge. However, if you import the same function in a file designed for Node, you'll receive a standard function that sets up the OpenTelemetry SDK correctly.

The OpenTelemetry SDK initialization itself is straightforward. For more details, please see the code.

๐Ÿ“„ License

MIT


Made with ๐Ÿ’– by Vercel. Happy tracing! ๐Ÿ“ˆ