Getting started

Capture telemetry from a Go application without writing any instrumentation code.

This page shows you how to build a Go application with compile-time instrumentation and see the telemetry it produces.

Prerequisites

  • Go 1.25 or newer
  • git and make

Build the tool

The otelc tool is built from the project repository:

git clone https://github.com/open-telemetry/opentelemetry-go-compile-instrumentation.git
cd opentelemetry-go-compile-instrumentation
make build

This produces an otelc binary in the repository root. Add it to your PATH, or note its location — the following steps assume otelc is on your PATH:

export PATH=$PATH:$(pwd)

Instrument your application

From your application’s module directory, prefix your usual go build command with otelc:

otelc go build -o myapp .

The tool intercepts the build, applies the instrumentation rules that match your application and its dependencies, and produces an instrumented binary. Everything else about the build — flags, package arguments, output paths — works exactly as it does with plain go build.

Run the application and export telemetry

Instrumented applications are configured through the standard OpenTelemetry environment variables. For example, to send telemetry to a local Collector over OTLP:

export OTEL_SERVICE_NAME=myapp
export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
./myapp

See Configuration for the full list of environment variables the instrumentation recognizes.

Try the demo

The repository ships demo applications and a complete observability stack (Collector, Jaeger, Prometheus, and Grafana) so you can see the produced telemetry end to end. The stack runs on Docker, so make sure Docker is available first. From the repository root, run:

cd demo/infrastructure/docker-compose
make start

See the demo directory for details on the demo applications and infrastructure.

Next steps