Set up local Sourcegraph OpenTelemetry development

General OpenTelemetry export configuration is done via environment variables according to the official configuration options specification.

Collector

sg start otel runs otel-collector and jaeger, and configures otel-collector to forward traces to Jaeger. Additional configuration can be provided to export to different destinations - for example, to configure a simple Honeycomb exporter, add the following to your sg.config.overwrite.yaml:

commands:
  otel-collector:
    env:
      CONFIGURATION_FILE: 'configs/honeycomb.yaml'
      HONEYCOMB_API_KEY: '...'

To learn more, see docker-images/opentelemetry-collector.

Configuration

Set dev-private site config to use "observability.tracing": { "type": "opentelemetry" } to enable OpenTelemetry export for most services - this should be set by default in the latest versions of dev-private.

Testing

Use sg start to start services, and run a complex query with &trace=1, e.g. foobar(...) patterntype:structural - this will show the View trace button in the search results.

When using different backends, you can use "urlTemplate" in "observability.tracing" to configure the link.