Instrument a Go application for Splunk Observability Cloud π
The Splunk Distribution of OpenTelemetry Go can instrument your Go application or service. To get started, use the guided setup or follow the instructions manually.
Generate customized instructions using the guided setup π
To generate all the basic installation commands for your environment and application, use the Go guided setup. To access the Go guided setup, follow these steps:
Log in to Observability Cloud.
Open the Go guided setup. Optionally, you can navigate to the guided setup on your own:
In the left navigation menu, select
.Select Add Integration to open the Integrate Your Data page.
In the integration filter menu, select By Product.
Select the APM product.
Select the Go tile to open the Go guided setup.
Install the Splunk Distribution of OpenTelemetry Go manually π
Follow these instructions to install the Splunk Distribution of OpenTelemetry Go.
Install and activate the Go instrumentation π
Follow these steps to instrument your application using the Go instrumentation:
Check that you meet the requirements. See Go instrumentation compatibility and requirements.
Install the distribution:
go get github.com/signalfx/splunk-otel-go/distro
Set the
OTEL_SERVICE_NAME
environment variable:export OTEL_SERVICE_NAME=<yourServiceName>
$env:OTEL_SERVICE_NAME=<yourServiceName>
(Optional) Set the endpoint URL if the Splunk Distribution of OpenTelemetry Collector is running on a different host:
export OTEL_EXPORTER_OTLP_ENDPOINT=<yourCollectorEndpoint>:<yourCollectorPort>
$env:OTEL_EXPORTER_OTLP_ENDPOINT=<yourCollectorEndpoint>:<yourCollectorPort>
(Optional) Set the version and environment name:
export OTEL_RESOURCE_ATTRIBUTES="service.version=<version>,deployment.environment=<environment>"
$env:OTEL_RESOURCE_ATTRIBUTES="service.version=<version>,deployment.environment=<environment>"
Add the instrumentation using the
distro
package:package main import ( "context" "github.com/signalfx/splunk-otel-go/distro" ) func main() { sdk, err := distro.Run() if err != nil { panic(err) } // Flush all spans before the application exits defer func() { if err := sdk.Shutdown(context.Background()); err != nil { panic(err) } }() // ...
Activate additional instrumentations. For more information, see Supported libraries and frameworks.
(Optional) To link APM and RUM data, activate the HTTP instrumentation. See Server trace information.
If no data appears in Observability > APM, see Troubleshoot Go instrumentation for Splunk Observability Cloud.
Note
If you need to add custom attributes to spans or want to manually generate spans, instrument your Go application or service manually. See Custom Go instrumentation for Splunk Observability Cloud.
Enable metrics collection π
Caution
The OpenTelemetry Go Metrics API is a release candidate. Use it for evaluation purposes only. Donβt use it in production environments. Some features might have restrictions, limited stability, or might change in next versions. Limited support is provided on best-effort basis.
To enable automatic runtime metric collection, you need to set the OTLP_METRICS_EXPORTER
environment variable.
export OTLP_METRICS_EXPORTER=otlp
$env:OTLP_METRICS_EXPORTER=otlp
Deploy the Go instrumentation in Kubernetes π
To deploy the Go instrumentation in Kubernetes, configure the Kubernetes Downward API to expose environment variables to Kubernetes resources.
The following example shows how to update a deployment to expose environment variables by adding the OTel configuration under the .spec.template.spec.containers.env
section:
apiVersion: apps/v1
kind: Deployment
spec:
selector:
matchLabels:
app: your-application
template:
spec:
containers:
- name: myapp
env:
- name: SPLUNK_OTEL_AGENT
valueFrom:
fieldRef:
fieldPath: status.hostIP
- name: OTEL_EXPORTER_OTLP_ENDPOINT
value: "http://$(SPLUNK_OTEL_AGENT):4317"
- name: OTEL_SERVICE_NAME
value: "<serviceName>"
- name: OTEL_RESOURCE_ATTRIBUTES
value: "deployment.environment=<environmentName>"
Send data directly to Observability Cloud π
By default, all telemetry is sent to the local instance of the Splunk Distribution of OpenTelemetry Collector.
If you need to send data directly to Observability Cloud, set the following environment variables:
export SPLUNK_ACCESS_TOKEN=<access_token>
export SPLUNK_REALM=<realm>
$env:SPLUNK_ACCESS_TOKEN=<access_token>
$env:SPLUNK_REALM=<realm>
To obtain an access token, see Retrieve and manage user API access tokens using Splunk Observability Cloud.
In the ingest endpoint URL, realm
is the Observability Cloud realm, for example, us0
. To find the realm name of your account, follow these steps:
Open the left navigation menu in Observability Cloud.
Select
.Select your username.
The realm name appears in the Organizations section.
Note
For more information on the ingest API endpoints, see Send APM traces.