# Go compile-time instrumentation

> Instrument Go applications at build time, without code changes.

---

LLMS index: [llms.txt](/llms.txt)

---

Compile-time instrumentation for Go automatically instruments your application
during the build, capturing telemetry from many popular libraries and frameworks
without any changes to your source code. It works by hooking into the Go build
process and injecting instrumentation as your application is compiled, so the
resulting binary contains the instrumentation code with no runtime agent
required.

> [!NOTE]
>
> This project is under active development and is not yet ready for production
> use. To follow progress or get involved, visit the
> [opentelemetry-go-compile-instrumentation repository](https://github.com/open-telemetry/opentelemetry-go-compile-instrumentation).

## How it works

The `otelc` tool wraps your regular `go build` invocation. During the build it:

1. Intercepts compilation of each package using the Go toolchain's `-toolexec`
   mechanism.
2. Matches packages and functions against a set of instrumentation rules that
   describe where telemetry hooks belong.
3. Injects lightweight hook points into the matched functions and links them to
   OpenTelemetry instrumentation code.

Because instrumentation is baked into the binary at compile time, it also covers
third-party dependencies you don't control, and it adds no runtime attach or
startup steps.

## When to use it

Compile-time instrumentation is one of several
[zero-code](/docs/concepts/instrumentation/zero-code/) options for Go: it
complements the [Auto SDK](/docs/zero-code/go/autosdk/), while eBPF-based
instrumentation is available through [OBI](/docs/zero-code/obi/). Compile-time
instrumentation is a good fit when you can modify the build pipeline but not the
source code, when you want instrumentation inside third-party libraries, or when
you can't run a privileged agent alongside your application.

---

Section pages:

- [Getting started](/ko/docs/zero-code/go/compile-time/getting-started/): Capture telemetry from a Go application without writing any instrumentation code.
- [Supported libraries](/ko/docs/zero-code/go/compile-time/supported-libraries/): Libraries and frameworks instrumented out of the box.
- [Configuration](/ko/docs/zero-code/go/compile-time/configuration/): Configure the otelc tool and the telemetry produced by instrumented applications.
- [Troubleshooting](/ko/docs/zero-code/go/compile-time/troubleshooting/): Diagnose issues with Go compile-time instrumentation.
