Package Exports
- @vercel/otel
Readme
🚀 Vercel Otel
@vercel/otel is a simple and easy-to-use package that sets up your tracing configuration.
💡 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.
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 SDK with the specified service name and the default configuration.
serviceName: The name of your service, used as the app name in many OpenTelemetry backends.
registerOTel(config: Configuration)
Registers the OpenTelemetry SDK with the specified configuration. Configuration options include:
serviceName: The name of your service, used as the app name in many OpenTelemetry backends.attributes: The resource attributes. By default,@vercel/otelconfigures relevant Vercel attributes based on the environment, such asvercel.env,vercel.runtime,vercel.host, etc.instrumentations: A set of instrumentations. By default,@vercel/otelconfigures "fetch" instrumentation.instrumentationConfig: Customize configuration for predefined instrumentations:fetch: Customize configuration of the predefined "fetch" instrumentation:ignoreUrls: A set of URL matchers (string prefix or regex) that should be ignored from tracing. By default all URLs are traced. Example:fetch: { ignoreUrls: [/example.com/] }propagateContextUrls: A set of URL matchers (string prefix or regex) for which the tracing context should be propagated (seepropagators). By default the context is propagated only for the deployment URLs, all other URLs should be enabled explicitly. Example:fetch: { propagateContextUrls: [ /my.api/ ] }.dontPropagateContextUrls: A set of URL matchers (string prefix or regex) for which the tracing context should not be propagated (seepropagators). This allows you to exclude a subset of URLs allowed by thepropagateContextUrls.
propagators: A set of propagators that may extend inbound and outbound contexts. By default,@vercel/otelconfigures W3C Trace Context propagator.traceSampler: The sampler to be used to decide which requests should be traced. By default, all requests are traced. This option can be changed to, for instance, only trace 1% of all requests.spanProcessorsandtraceExporter: The export mechanism for traces. By default,@vercel/otelconfigures the best export mechanism for the environment. For instance, if a tracing integrations is configured on Vercel, this integration will be automatically used for export; otherwise an OTLP exporter can be used if configured in environment variables.
See API for more details.
📄 License
Made with 💖 by Vercel. Happy tracing! 📈