Skip to content

Backends & Configuration

Configure OpenTelemetry exporters, provider management, and integration with observability backends like Jaeger and Grafana.

Environment Variables Reference

Service Metadata

VariableDescription
OTEL_SERVICE_NAMEService name (required)
OTEL_SERVICE_VERSIONService version
OTEL_SERVICE_NAMESPACEService namespace (e.g., production)

Exporters

VariableDescriptionValues
OTEL_TRACES_EXPORTERTrace exporterotlp, console, none
OTEL_METRICS_EXPORTERMetrics exporterotlp, console, none
OTEL_LOGS_EXPORTERLogs exporterotlp, console, none

OTLP Endpoints

VariableDescription
OTEL_EXPORTER_OTLP_ENDPOINTBase OTLP endpoint
OTEL_EXPORTER_OTLP_TRACES_ENDPOINTTraces endpoint (overrides base)
OTEL_EXPORTER_OTLP_METRICS_ENDPOINTMetrics endpoint (overrides base)
OTEL_EXPORTER_OTLP_LOGS_ENDPOINTLogs endpoint (overrides base)

OTLP Settings

VariableDescription
OTEL_EXPORTER_OTLP_PROTOCOLProtocol: http/protobuf or grpc
OTEL_EXPORTER_OTLP_HEADERSHeaders (comma-separated key=value)

Batch Span Processor

VariableDefaultDescription
OTEL_BSP_SCHEDULE_DELAY5000Schedule delay (ms)
OTEL_BSP_MAX_QUEUE_SIZE2048Max queue size
OTEL_BSP_MAX_EXPORT_BATCH_SIZE512Max batch size
OTEL_BSP_EXPORT_TIMEOUT30000Export timeout (ms)

Instrumentations

VariableDescription
OTEL_NODE_DISABLED_INSTRUMENTATIONSComma-separated list of disabled auto-instrumentations

Provider Management

The OTel provider initializes lazily when you first call getTracer(), getMeter(), or getLogger(). For explicit control:

typescript
import { initProvider, shutdownProvider } from '@connectum/otel';

// Explicit initialization (optional)
initProvider({
  serviceName: 'my-service',
  serviceVersion: '1.0.0',
});

// Graceful shutdown (flush pending telemetry)
server.onShutdown('otel', async () => {
  await shutdownProvider();
});

Development vs Production Configuration

Development

Use console exporters for immediate visibility:

bash
OTEL_SERVICE_NAME=greeter-service
OTEL_TRACES_EXPORTER=console
OTEL_METRICS_EXPORTER=none
OTEL_LOGS_EXPORTER=console

Production

Export to an OTLP-compatible collector (Jaeger, Grafana Tempo, Datadog):

bash
OTEL_SERVICE_NAME=greeter-service
OTEL_SERVICE_VERSION=1.0.0
OTEL_SERVICE_NAMESPACE=production

OTEL_TRACES_EXPORTER=otlp
OTEL_METRICS_EXPORTER=otlp
OTEL_LOGS_EXPORTER=otlp

OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4318
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf

OTEL_BSP_SCHEDULE_DELAY=5000
OTEL_BSP_MAX_QUEUE_SIZE=2048

OTEL_NODE_DISABLED_INSTRUMENTATIONS=fs,dns

Integration with Backends

Jaeger

yaml
# docker-compose.yml
services:
  jaeger:
    image: jaegertracing/all-in-one:latest
    ports:
      - "16686:16686"   # Jaeger UI
      - "4318:4318"     # OTLP HTTP
bash
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318

Grafana (Tempo + Prometheus + Loki)

bash
# Traces -> Tempo
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://tempo:4318/v1/traces

# Metrics -> Prometheus (via OTLP)
OTEL_EXPORTER_OTLP_METRICS_ENDPOINT=http://prometheus:4318/v1/metrics

# Logs -> Loki (via OTLP)
OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=http://loki:4318/v1/logs