Configure the Go instrumentation for Splunk Observability Cloud π
You can configure the Splunk Distribution of OpenTelemetry Go to suit your instrumentation needs.
The following sections describe all available settings for configuring the Go instrumentation, including options for activating new features that are unique to the Splunk Distribution of OpenTelemetry Go.
Configuration methods π
You can change the instrumentation settings in two ways:
Set an environment variable. For example:
export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
$env:OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
// Before running distro.Run() os.Setenv("OTEL_EXPORTER_OTLP_ENDPOINT", "http://localhost:4317")
To configure the instrumentation, use environment variables. Specify options in the code to override existing environment variables.
General settings π
The following settings are specific to the Splunk Distribution of OpenTelemetry Go:
Environment variable |
Description |
---|---|
|
A Splunk authentication token that lets exporters send data directly to Splunk Observability Cloud. Unset by default. Not required unless you need to send data to the Splunk Observability Cloud ingest endpoint. See Create and manage authentication tokens using Splunk Observability Cloud. |
|
The name of your organizationβs realm, for example, |
|
Lets you add server trace information to HTTP response headers using the |
|
Sets the logging level for instrumentation log messages. Possible values are |
Trace configuration π
The following settings control tracing limits and attributes:
Environment variable |
Description |
---|---|
|
Name of the service or application youβre instrumenting. Takes precedence over the service name defined in the |
|
Comma-separated list of resource attributes added to every reported span. For example, |
|
Maximum number of attributes per span. The default value is unlimited. |
|
Maximum number of attributes per event. The default value is unlimited. |
|
Maximum number of attributes per link. The default value is unlimited. |
|
Maximum number of events per span. The default value is unlimited. |
|
Maximum number of links per span. The default value is |
|
Maximum length of strings for span attribute values. Values larger than the limit are truncated. The default value is |
Exporters configuration π
The following settings control trace exporters and their endpoints:
Environment variable |
Description |
---|---|
|
The traces exporter to use. The default value is |
|
The metrics exporter to use. The default value is |
|
Interval, in milliseconds, between the start of two export attempts. The default value is |
|
Maximum allowed time to export data, in milliseconds. The default value is |
|
The OTLP endpoint. The default value is |
|
The OTLP endpoint for traces. The default value is |
|
The OTLP endpoint. The default value is |
To send data directly to Splunk Observability Cloud, see Send data directly to Splunk Observability Cloud.
Samplers configuration π
The following settings control trace sampling:
Environment variable |
Description |
---|---|
|
Sampler to use. The default value is |
Configure a TLS connection π
By default, the exporters donβt use a TLS connection. To configure a TLS connection, set the WithTLSConfig
option in the code. See Configuration methods.
Batch processor settings π
The following settings control the BatchSpanProcessor
configuration:
Environment variable |
Description |
---|---|
|
Delay between two consecutive exports, in milliseconds. The default value is |
|
Maximum allowed time to export data, in milliseconds. The default value is |
|
Maximum queue size. The default value is |
|
Maximum batch size. The default value is |
Propagators configuration π
The following settings control trace propagation:
Environment variable |
Description |
---|---|
|
Comma-separated list of propagators you want to use. The default value is |
The instrumentation supports the following propagators:
tracecontext
: W3C tracecontext
baggage
: W3C baggage
b3
: B3 single-header format
b3multi
: B3 multiheader format
xray
: AWS X-Ray
ottrace
: OpenTracing
none
: None
You can also change the trace propagator using otel.SetTextMapPropagator
. For example:
distro.Run()
// Change propagator after distro.Run() has been invoked
otel.SetTextMapPropagator(propagation.TraceContext{})
Server trace information π
To connect Real User Monitoring (RUM) requests from mobile and web applications with server trace data, add the HTTP instrumentation packages to your code. For example:
package main
import (
"net/http"
"github.com/signalfx/splunk-otel-go/distro"
"github.com/signalfx/splunk-otel-go/instrumentation/net/http/splunkhttp"
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
)
func main() {
distro.Run()
var handler http.Handler = http.HandlerFunc(
func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Hello"))
}
)
handler = splunkhttp.NewHandler(handler)
handler = otelhttp.NewHandler(handler, "my-service")
http.ListenAndServe(":9090", handler)
}
Your application instrumentation adds the following response headers to HTTP responses:
Access-Control-Expose-Headers: Server-Timing
Server-Timing: traceparent;desc="00-<serverTraceId>-<serverSpanId>-01"
The Server-Timing
header contains the traceId
and spanId
in traceparent
format. For more information, see the Server-Timing and traceparent documentation on the W3C website.