OpenTelemetry Integration
Gate includes built-in support for OpenTelemetry, providing comprehensive observability through metrics, distributed tracing, and structured logging. OpenTelemetry is a vendor-agnostic observability framework that allows you to instrument your application and export telemetry data to various backends.Overview
OpenTelemetry is an observability framework designed to facilitate the generation, export, and collection of telemetry data such as traces, metrics, and logs. Gate leverages the otel-config-go library, which provides a straightforward method to configure observability through environment variables.Gate automatically initializes OpenTelemetry with sensible defaults. You only need to configure the endpoints and credentials for your observability backend.
Architecture
The typical Gate observability setup follows this architecture:- OpenTelemetry Collector (recommended) - Processes and routes telemetry
- Direct backends - Services like Grafana Cloud, Honeycomb, or Datadog
- Self-hosted solutions - Prometheus, Jaeger, Tempo, etc.
Configuration
Gate’s OpenTelemetry implementation is configured entirely through environment variables, making it easy to integrate with container orchestration platforms and cloud environments.Core Settings
| Environment Variable | Default | Description |
|---|---|---|
OTEL_SERVICE_NAME | gate | Name of your service |
OTEL_SERVICE_VERSION | - | Version of your service |
OTEL_EXPORTER_OTLP_ENDPOINT | localhost:4317 | Endpoint for OTLP export |
OTEL_EXPORTER_OTLP_PROTOCOL | grpc | Protocol for OTLP (grpc or http/protobuf) |
OTEL_METRICS_ENABLED | false | Enable metrics collection |
OTEL_TRACES_ENABLED | false | Enable trace collection |
OTEL_LOG_LEVEL | info | OpenTelemetry SDK logging level |
OTEL_PROPAGATORS | tracecontext,baggage | Configured trace propagators |
Exporter Configuration
| Environment Variable | Default | Description |
|---|---|---|
OTEL_EXPORTER_OTLP_HEADERS | {} | Global headers for OTLP exporter |
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT | localhost:4317 | Endpoint for trace export |
OTEL_EXPORTER_OTLP_TRACES_HEADERS | {} | Headers specific to trace exporter |
OTEL_EXPORTER_OTLP_TRACES_INSECURE | false | Allow insecure trace connections |
OTEL_EXPORTER_OTLP_METRICS_ENDPOINT | localhost:4317 | Endpoint for metrics export |
OTEL_EXPORTER_OTLP_METRICS_HEADERS | {} | Headers specific to metrics exporter |
OTEL_EXPORTER_OTLP_METRICS_INSECURE | false | Allow insecure metrics connections |
OTEL_EXPORTER_OTLP_METRICS_PERIOD | 30s | Metrics reporting interval |
Resource Attributes
UseOTEL_RESOURCE_ATTRIBUTES to add additional context to your telemetry:
Quick Start Examples
Local OpenTelemetry Collector
Grafana Cloud
Honeycomb
Implementation Details
Gate’s OpenTelemetry integration is implemented inpkg/internal/otelutil/otel.go:15:
- Initializes trace and metric providers
- Configures OTLP exporters (gRPC or HTTP)
- Sets up context propagation
- Handles graceful shutdown
Best Practices
1. Use Meaningful Service Names
2. Track Service Versions
3. Add Deployment Context
4. Secure Production Endpoints
5. Use OpenTelemetry Collector
For production deployments, route telemetry through an OpenTelemetry Collector for:- Batching - Reduces network overhead
- Filtering - Removes unnecessary data
- Enrichment - Adds metadata and context
- Retry logic - Handles transient failures
- Multi-backend support - Send to multiple destinations
Observability Solutions
Gate works with any OpenTelemetry-compatible backend:Cloud Platforms
- Grafana Cloud - Fully managed with Prometheus, Tempo, and Loki
- Honeycomb - Observability for debugging complex systems
- Datadog - Full-stack monitoring and analytics
- New Relic - APM and observability platform
- Azure Monitor - Microsoft cloud monitoring
- AWS X-Ray - AWS distributed tracing
- Google Cloud Observability - GCP monitoring
Self-Hosted
- Metrics: Prometheus, Grafana Mimir
- Tracing: Jaeger, Grafana Tempo
- Logs: Loki
- Visualization: Grafana
Troubleshooting
No Telemetry Data
-
Verify metrics/traces are enabled:
-
Check the endpoint is reachable:
- Review Gate logs for OpenTelemetry errors
Connection Refused
- Ensure the collector/backend is running
- Verify the endpoint URL and port
- Check firewall rules
- For Docker, ensure containers are on the same network
Authentication Errors
- Verify API keys and tokens are correct
- Check header format:
key=valuepairs - Ensure credentials are base64 encoded if required
Next Steps
Metrics
Learn about available metrics and collection
Tracing
Configure distributed tracing for request flows
Logging
Set up structured logging and log levels

