Applications that use the Go agent to connect to Application Monitoring can use the OpenTelemetry software development kit (SDK) to retrieve the trace ID and span ID from their code.
Procedure
In the agent settings for your application, enable the OpenTelemetry switch.
Add the code block.
package main import ( "context" "go.opentelemetry.io/otel/trace" ) func GetTraceIdAndSpanId() (string, string) { span := trace.SpanFromContext(context.Background()) return span.SpanContext().TraceID().String(), span.SpanContext().SpanID().String() }