Home

Awesome

Orchestrion

User Documentation Project Documentation Latest Release GitHub go.mod Go version OpenSSF Scorecard

Automatic compile-time instrumentation of Go code.

Overview

Orchestrion processes Go source code at compilation time and automatically inserts instrumentation. This instrumentation produces Datadog APM traces from the instrumented code and supports Datadog Application Security Management.

[!IMPORTANT] Should you encounter issues or a bug when using orchestrion, please report it in the bug tracker.

For support & general questions, you are welcome to use GitHub discussions. You may also contact us privately via Datadog support.

Requirements

Orchestrion supports the two latest releases of Go, matching Go's official release policy. It may function correctly with older Go releases; but we will not be able to offer support for these if they don't.

In addition to this, Orchestrion only supports projects using Go modules.

Getting started

  1. Install Orchestrion:

    $ go install github.com/DataDog/orchestrion@latest
    
  2. <details><summary>Optional: project <tt>go.mod</tt> registration</summary>

    You can automatically add orchestrion to your project's dependencies by running:

    $ orchestrion pin
    

    This will:

    1. Create a new orchestrion.tool.go file containing content similar to:
      // Code generated by `orchestrion pin`; DO NOT EDIT.
      
      // This file is generated by `orchestrion pin`, and is used to include a blank import of the
      // orchestrion package(s) so that `go mod tidy` does not remove the requirements from go.mod.
      // This file should be checked into source control.
      
      //go:build tools
      
      package tools
      
      import _ "github.com/DataDog/orchestrion"
      
    2. Run go get github.com/DataDog/orchstrion@<current-release> to make sure the project version corresponds to the one currently being used
    3. Run go mod tidy to make sure your go.mod and go.sum files are up-to-date

    If you do not run this command, it will be done automatically when required. Once done, the version of orchestrion used by this project can be controlled directly using the go.mod file, as you would control any other dependency.

    </details>
  3. Prefix your go commands with orchestrion:

    $ orchestrion go build .
    $ orchestrion go test -race ./...
    

    If you have not run orchestrion pin, you may see a message similar to the following appear, as orchestrion pin is automatically executed:

    ╭──────────────────────────────────────────────────────────────────────────────╮
    │                                                                              │
    │  Warning: github.com/DataDog/orchestrion is not present in your go.mod       │
    │  file.                                                                       │
    │  In order to ensure build reliability and reproductibility, orchestrion      │
    │  will now add itself in your go.mod file by:                                 │
    │                                                                              │
    │      1. creating a new file named orchestrion.tool.go                        │
    │      2. running go get github.com/DataDog/orchestrion@v0.7.0-dev.2           │
    │      3. running go mod tidy                                                  │
    │                                                                              │
    │  You should commit the resulting changes into your source control system.    │
    │                                                                              │
    ╰──────────────────────────────────────────────────────────────────────────────╯
    
    <details><summary>Alternative</summary>

    Orchestrion at the core is a standard Go toolchain -toolexec proxy. Instead of using orchestrion go, you can also manually provide the -toolexec argument to go commands that accept it:

    $ go build -toolexec 'orchestrion toolexec' .
    $ go test -toolexec 'orchestrion toolexec' -race .
    
    </details>

The version of orchestrion used to compile your project is ultimately tracked in the go.mod file. You can manage it in the same way you manage any other dependency, and updating to the latest release is as simple as doing:

$ go get github.com/DataDog/orchestrion@latest

Supported libraries

Orchestrion supports automatic tracing of the following libraries:

LibrarySinceNotes
database/sqlv0.7.0Aspect
github.com/gin-gonic/ginv0.7.0Aspect
github.com/go-chi/chi/v5v0.7.0Aspect
github.com/go-chi/chiv0.7.0Aspect
github.com/go-redis/redis/v7v0.7.0Aspect
github.com/go-redis/redis/v8v0.7.0Aspect
github.com/gofiber/fiber/v2v0.7.0Aspect
github.com/gomodule/redigo/redisv0.7.0Aspect
github.com/gorilla/muxv0.7.0Aspect (library-side)
github.com/jinzhu/gormv0.7.0Aspect
github.com/labstack/echo/v4v0.7.0Aspect
google.golang.org/grpcv0.7.0Aspect
gorm.io/gormv0.7.0Aspect
net/httpv0.7.0Client (library-side) / Server
go.mongodb.org/mongo-driver/mongov0.7.3Aspect
github.com/aws-sdk-go/awsv0.7.4Aspect
github.com/hashicorp/vaultv0.7.4Aspect
github.com/IBM/saramav0.7.4Aspect
github.com/Shopify/saramav0.7.4Aspect
k8s.io/client-gov0.7.4Aspect
log/slogv0.7.4Aspect
osv0.8.0Aspect
github.com/aws/aws-sdk-go-v2v0.8.0Aspect
github.com/redis/go-redis/v9v0.8.0Aspect
github.com/gocql/gocqlv0.8.0Aspect
cloud.google.com/go/pubsubv0.9.0Aspect (library-side)
github.com/99designs/gqlgenv0.9.1Aspect
github.com/redis/go-redisv0.9.1Aspect
github.com/graph-gophers/graphql-gov0.9.1Aspect
github.com/graphql-go/graphqlv0.9.1Aspect
testingv0.9.3Aspect with Test Optimization
github.com/jackc/pgxv0.9.4Aspect
github.com/elastic/go-elasticsearchv0.9.4Aspect
github.com/twitchtv/twirpv0.9.4Aspect
github.com/segmentio/kafka-gov0.9.4Aspect (library-side)
github.com/confluentinc/confluent-kafka-go/kafkav0.9.4Aspect (library-side)
github.com/confluentinc/confluent-kafka-go/kafka/v2v0.9.4Aspect (library-side)
github.com/julienschmidt/httprouterv0.9.4Aspect (library-side)
github.com/sirupsen/logrusv0.9.4Aspect

Library Side

Most integrations are added by orchestrion at the call site, making it possible to use the //orchestrion:ignore directive to locally opt out of instrumentation for a specific instance of a component.

Some integrations are however injected directly into the library (library-side instrumentation, also called callee-side instrumentation), and are hence always active and cannot be locally opted out. If you have a use-case where you need to locally opt out of a library-side instrumentation, please let us know about it by filing a GitHub issue.

Troubleshooting

If you run into issues when using orchestrion please make sure to collect all relevant details about your setup in order to help us identify (and ideally reproduce) the issue. The version of orchestrion (which can be obtained from orchestrion version) as well as of the go toolchain (from go version) are essential and must be provided with any bug report.

You can inspect everything Orchestrion is doing by adding the -work argument to your go build command; when doing so the build will emit a WORK= line pointing to a working directory that is retained after the build is finished. The contents of this directory contains all updated source code Orchestrion produced and additional metadata that can help diagnosing issues.

More information

Datadog's user guide for Orchestrion can be found on [docs.datadoghq.com][dd-doc]. [dd-doc]: https://docs.datadoghq.com/tracing/trace_collection/automatic_instrumentation/dd_libraries/go/?tab=compiletimeinstrumentation

Orchestrion's project documentation can be found at datadoghq.dev/orchestrion; in particular: