Getting Started

March 5, 2026 ยท View on GitHub

OpenTelemetry Go Compile-Time Instrumentation is a tool that automatically instruments your Go applications with OpenTelemetry at compile-time. No manual code changes required.

Why Use This Tool?

  • Zero-code instrumentation - Automatically instrument your entire application without modifying source code
  • Third-party library support - Instrument dependencies and libraries you don't control
  • Complete decoupling - Keep your codebase free from instrumentation concerns
  • Flexible deployment - Integrate at development time or in your CI/CD pipeline

Quick Start

  1. Clone and build the tool

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

    make demo
    
  3. Use with your application

    # Option 1: Direct build
    ./otelc go build -o myapp .
    
    # Option 2: Install as tool dependency (Go 1.24+)
    go get -tool github.com/open-telemetry/opentelemetry-go-compile-instrumentation/cmd/otelc
    go tool otelc go build -o myapp .
    

How It Works

The tool uses compile-time instrumentation through:

  1. Trampoline Code Injection - Injects lightweight hook points into target functions
  2. Function Pointer Redirection - Automatically generates and links hooks to monitoring code via //go:linkname
  3. Custom Toolchain Integration - Intercepts compilation using -toolexec flag

This approach provides dynamic instrumentation without runtime overhead or invasive code modifications.

Learn More

Video Talks

Learn more about the project from these presentations:

Community

Status

Note: This project is currently in active development and not yet ready for production use.

For the latest updates and development progress, follow the project on GitHub and join the community discussions.