Datadog Go Orchestrion
Middleware supports the Orchestrion Datadog feature to ensure seamless tracing integration.
Install Orchestrion
To install and set up Orchestrion:
1 Install Orchestrion:
go install github.com/DataDog/orchestrion@latest
Note: Ensure that $(go env GOBIN)
or $(go env GOPATH)/bin
is in your $PATH
.
2 Register Orchestrion in your project’s go.mod
:
orchestrion pin
Refer to the output of orchestrion pin -help
for more information about available customization options.
3 Commit changes to your version control system (unless you are integrating orchestrion directly in your CI/CD pipeline):
git add go.mod go.sum orchestrion.tool.go git commit -m "chore: enable orchestrion"
Now you can manage your dependency on orchestrion like any other dependency using the go.mod file.
Ship to Middleware
Add the following code to your main.go
file. This will send your traces directly to the middleware, enabling seamless monitoring and trace management:
// customTransport adds custom headers to the HTTP requests type customTransport struct { transport http.RoundTripper headers map[string]string } func (c *customTransport) RoundTrip(req *http.Request) (*http.Response, error) { // Add custom headers for key, value := range c.headers { req.Header.Set(key, value)
Replace "YOUR_MIDDLEWARE_API_KEY" with your actual API key in the dd-api-key header.
Usage
To enable Orchestrion during the build, run, or test processes, prepend Orchestrion to your usual Go commands:
orchestrion go build . DD_TRACE_AGENT_URL=https://<MW_UID>.middleware.io:443 orchestrion go run . orchestrion go test ./...
Verifying Tracing
After completing the integration, you can verify that traces are being sent to the middleware by checking Middleware APM system.