@effect/opentelemetry provides seamless integration between Effect and OpenTelemetry, enabling observability through tracing, metrics, and logging for your Effect applications.
Installation
Required Peer Dependencies
The package requires several OpenTelemetry packages as peer dependencies:@opentelemetry/api(^1.9)@opentelemetry/resources(^2.0.0)@opentelemetry/sdk-trace-base(^2.0.0)@opentelemetry/sdk-trace-node(^2.0.0) - for Node.js@opentelemetry/sdk-trace-web(^2.0.0) - for browsers@opentelemetry/sdk-metrics(^2.0.0)@opentelemetry/sdk-logs(>=0.203.0 <0.300.0)@opentelemetry/semantic-conventions(^1.33.0)
Quick Start
Set up basic tracing for your Effect application:Tracing
Automatic Span Creation
Effect operations automatically create spans:Manual Span Management
Metrics
Collect and export metrics:Custom Metrics
Logging
Integrate Effect logging with OpenTelemetry:Exporters
OTLP Exporter
Export to OpenTelemetry Collector:Prometheus Exporter
Expose metrics for Prometheus:Semantic Conventions
Use standard attribute names:Context Propagation
Automatic context propagation across async boundaries:Best Practices
- Service Name: Always set a descriptive service name
- Sampling: Configure sampling for production to reduce overhead
- Batch Processing: Use batch processors for better performance
- Attribute Limits: Be mindful of attribute cardinality
- Resource Cleanup: Ensure proper shutdown of exporters
Related Resources
API Reference
Complete API documentation
OpenTelemetry Docs
Official OpenTelemetry documentation
@effect/platform
Platform abstractions with built-in tracing
Effect Observability
Observability guide for Effect