Instrument your 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 Splunk Observability Cloud.
Open the Go guided setup . Optionally, you can navigate to the guided setup on your own:
In the navigation menu, select
.Go to the Available integrations tab, or select Add Integration in the Deployed integrations tab.
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 π
If you donβt use the guided setup, follow these instructions to manually 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. The following example shows how to instrument a basic function.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 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.
Deploy the Go instrumentation in Kubernetes or Azure π
To deploy the Go instrumentation in Kubernetes or Azure, 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 Splunk 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 Splunk Observability Cloud, set the following environment variables:
export SPLUNK_ACCESS_TOKEN=<access_token>
export SPLUNK_REALM=<realm>
export OTEL_METRICS_EXPORTER=none
$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.
To find your Splunk realm, see Note about realms.
For more information on the ingest API endpoints, see Send APM traces and Send data points .
Specify the source host π
To override the host used by the agent, use the environment variable OTEL_RESOURCE_ATTRIBUTES
to set your hostβs name to the desired source:
$env:OTEL_RESOURCE_ATTRIBUTES=host.name=<host_name>
export OTEL_RESOURCE_ATTRIBUTES=host.name=<host_name>