Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@vercel/otel

Package Overview
Dependencies
Maintainers
8
Versions
89
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vercel/otel

Vercel wrapper around OpenTelemetry APIs

Source
npmnpm
Version
0.2.0
Version published
Weekly downloads
1.4M
-7.62%
Maintainers
8
Weekly downloads
 
Created
Source

🚀 Vercel Otel

npm

Note: This package is experimental. Updates 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 HTTP 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 HTTP exporter using the given service name. This is all that is needed to trace your app on Vercel.

  • 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! 📈

FAQs

Package last updated on 17 Apr 2023

Did you know?

Socket

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