TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/elysiajs/documentation/llms.txt
Use this file to discover all available pages before exploring further.
@elysia/opentelemetry plugin integrates the OpenTelemetry SDK with your Elysia server. It automatically collects spans from any library compatible with the OpenTelemetry standard and applies parent–child span relationships to each request lifecycle.
Installation
Basic usage
Configuration
The plugin extends the OpenTelemetry Node SDK options. All fields are optional.spanProcessors
An array of SpanProcessor instances to register with the tracer provider. Use BatchSpanProcessor with your chosen exporter for production:
traceExporter
A SpanExporter instance. When provided, it is automatically wrapped with a BatchSpanProcessor. Use either traceExporter or spanProcessors — not both.
If neither is configured, the plugin sets up a default OTLP HTTP/protobuf exporter with a BatchSpanProcessor.
serviceName
A string identifying your service in traces. Appears as the service name in your tracing backend.
instrumentations
Default: getNodeAutoInstrumentations()
Configure which instrumentations are active. By default, all Node.js auto-instrumentations are enabled. Pass an array to enable specific instrumentations only:
resource
An IResource instance providing metadata about the service (e.g., service name, version, environment). Use this alongside autoDetectResources for full context.
resourceDetectors
Default: [envDetector, processDetector, hostDetector]
Array of resource detectors that run when autoDetectResources is true. You can also configure detectors via the OTEL_NODE_RESOURCE_DETECTORS environment variable:
env, host, os, process, serviceinstance, all, none.
autoDetectResources
Default: true
When true, the SDK runs the configured resource detectors to populate resource attributes automatically.
contextManager
Default: AsyncHooksContextManager
Provide a custom context manager for propagating trace context across async operations.
textMapPropagator
Default: CompositePropagator (W3C Trace Context + Baggage)
Provide a custom propagator for injecting and extracting trace context from HTTP headers.
metricReader
A MetricReader instance passed to the MeterProvider for metrics collection alongside tracing.
views
An array of View instances passed to the MeterProvider. Use views to configure histogram bucket boundaries and other metric aggregation settings.
sampler
Default: all traces sampled
A custom Sampler to control which traces are recorded and exported. Useful for reducing trace volume in high-traffic production environments.