Skip to main content

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:
Gate emits telemetry data using the OpenTelemetry Protocol (OTLP), which can be sent to:
  • 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

Exporter Configuration

Resource Attributes

Use OTEL_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 in pkg/internal/otelutil/otel.go:15:
The SDK automatically:
  • 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

Self-Hosted

Troubleshooting

No Telemetry Data

  1. Verify metrics/traces are enabled:
  2. Check the endpoint is reachable:
  3. 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=value pairs
  • 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

Further Reading