OpenTelemetry (@banana-universe/plugin-otel)
Exports OpenTelemetryPlugin(options) returning a BananaPlugin that:
- Lazy-loads
@opentelemetry/sdk-nodeand@opentelemetry/auto-instrumentations-node - Starts a
NodeSDKwithserviceName - Optionally configures an OTLP HTTP exporter when
exporterUrlis set and@opentelemetry/exporter-trace-otlp-httpis installed - Mounts middleware in
register()to annotate the active span withrequest.id(from request context /x-request-id) - Shuts down the SDK in
onShutdown
Install
bash
npm install @banana-universe/plugin-otel \
@opentelemetry/sdk-node \
@opentelemetry/auto-instrumentations-node \
@opentelemetry/exporter-trace-otlp-httpOptions
typescript
OpenTelemetryPlugin({
serviceName: 'my-api',
exporterUrl: 'http://localhost:4318/v1/traces', // optional
})If the exporter package is missing, the plugin logs a warning and may fall back to default behavior.
Initialization order
Initialize tracing before heavy imports if you need full coverage — same guidance as any Node OTel setup. The plugin itself runs during BananaApp.create plugin registration.