Go Tracer は Go 1.18+ および Datadog Agent >= 5.21.1 を必要とします。Datadog の Go バージョンとフレームワークのサポート一覧 (レガシーバージョンとメンテナンスバージョンを含む) については、互換性要件ページをご覧ください。
Note: This documentation uses v2 of the Go tracer, which Datadog recommends for all users. If you are using v1, see the migration guide to upgrade to v2.
orchestrion go build .
orchestrion go run .
orchestrion go test ./...
go コマンドに -toolexec="orchestrion toolexec" 引数を追加します。
go build -toolexec="orchestrion toolexec" .
go run -toolexec="orchestrion toolexec" .
go test -toolexec="orchestrion toolexec" ./...
Orchestrion を注入するために $GOFLAGS 環境変数を変更し、通常通り go コマンドを使用します。
# Make sure to include the quotes as shown below, as these are required for# the Go toolchain to parse GOFLAGS properly!exportGOFLAGS="${GOFLAGS} '-toolexec=orchestrion toolexec'"go build .
go run .
go test ./...
トレースのカスタマイズ
unified service tagging の設定
orchestrion によってインスツルメンテーションされたアプリケーションは、Unified Service Tagging (UST) をサポートしています。アプリケーションの runtime 環境で対応する環境変数を設定することで、トレースに UST タグを設定できます。
//dd:span tag-name:spanName other-tag:bar span.name:operationNamefunctracedFunction(){// This function will be represented as a span named "operationName"}//dd:span tag-name:spanName other-tag:barfuncotherTracedFunction(){// This function will be represented as a span named "otherTracedFunction"}//dd:span tag-name:spanName other-tag:bartracedFunction:=func(){// This function will be represented as a span named "spanName"}
import"database/sql"// Caller-side instrumentation normally happens within this function...funcnormal(){// The following assignment will NOT be modified to add any caller-side// instrumentation as it is opted out by the orchestrion:ignore directive://orchestrion:ignoredb,err:=sql.Open("driver-name","database=example")// ...}// Caller-side instrumentation will NOT happen in the following function// as it is annotated with orchestrion:ignore.//orchestrion:ignorefuncexcluded(){// The following assignment will NOT be modified to add any caller-side// instrumentation as the surrounding context is excluded by an// orchestrion:ignore directive:db,err:=sql.Open("driver-name","database=example")// ...}
Go インテグレーションを有効化してスパンを生成します。Datadog には、一連のライブラリやフレームワークのインスツルメンテーション向けにすぐに使えるサポートを提供するプラグイン可能な一連のパッケージがあります。これらのパッケージの一覧は、互換性要件ページにあります。これらのパッケージをアプリケーションにインポートし、各インテグレーションに記載されている構成手順に従ってください。