How to Run an OpenTelemetry Collector in CI
A Collector as a service container gives pipeline steps a local OTLP endpoint that batches and forwards telemetry.
Declare the Collector under services: so it starts before your steps, and mount a config that receives OTLP on 4317 and exports to your backend. Steps then send to localhost:4317.
Steps
- Add the Collector image under
services:with port 4317 mapped. - Provide a config that receives OTLP and exports to your backend.
- Point step exporters at
localhost:4317.
Service container
.github/workflows/ci.yml
jobs:
build:
runs-on: ubuntu-latest
services:
otelcol:
image: otel/opentelemetry-collector-contrib:latest
ports: ['4317:4317']
steps:
- uses: actions/checkout@v4
- run: OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317 ./run-tests.shCollector config
otel-collector.yaml
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317
processors:
batch: {}
exporters:
otlphttp:
endpoint: ${env:BACKEND_OTLP_URL}
service:
pipelines:
traces:
receivers: [otlp]
processors: [batch]
exporters: [otlphttp]Related guides
How to Export Build Traces to Jaeger or Grafana TempoSend CI build traces to Jaeger or Grafana Tempo through an OpenTelemetry Collector, routing OTLP spans from t…
How to Instrument a GitHub Actions Pipeline With OpenTelemetryEmit OpenTelemetry traces for a GitHub Actions workflow run so each job and step becomes a span, using the ru…