Skip to content

Commit e45ee70

Browse files
committed
Configure OpenTelemetry SDK and OTLP exporter for Splunk Observability Cloud
- Add comprehensive OpenTelemetry configuration in runtime.exs - Configure resource attributes for service identity and environment - Set up OTLP exporter with gRPC protocol for reliable trace transmission - Include explicit sampling configuration to ensure custom spans are sent - Add environment variable support in docker-compose.yml - Use correct authentication header format for Splunk ingestion
1 parent 5f92624 commit e45ee70

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

manual-instrumentation/worms_in_space/config/runtime.exs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,36 @@ import Config
77
# any compile-time configuration in here, as it won't be applied.
88
# The block below contains prod specific runtime configuration.
99

10+
# OpenTelemetry Configuration
11+
splunk_realm = System.get_env("SPLUNK_REALM", "us0")
12+
splunk_access_token = System.get_env("SPLUNK_ACCESS_TOKEN", "")
13+
service_name = System.get_env("OTEL_SERVICE_NAME", "worms-in-space-backend")
14+
environment = System.get_env("OTEL_ENVIRONMENT", "development")
15+
16+
config :opentelemetry,
17+
resource: [
18+
service: %{
19+
name: service_name,
20+
version: "1.0.0"
21+
},
22+
deployment: %{
23+
environment: environment
24+
},
25+
splunk: %{
26+
realm: splunk_realm
27+
}
28+
],
29+
span_processor: :batch,
30+
traces_exporter: :otlp,
31+
sampler: {:parent_based, %{root: :always_on}}
32+
33+
config :opentelemetry_exporter,
34+
otlp_protocol: :grpc,
35+
otlp_endpoint: "https://ingest.#{splunk_realm}.signalfx.com:443",
36+
otlp_headers: [
37+
{"x-sf-token", splunk_access_token}
38+
]
39+
1040
# Start the phoenix server if environment is set and running in a release
1141
if System.get_env("PHX_SERVER") && System.get_env("RELEASE_NAME") do
1242
config :worms_in_space, WormsInSpaceWeb.Endpoint, server: true

manual-instrumentation/worms_in_space/docker-compose.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ services:
3131
SECRET_KEY_BASE: "your-secret-key-base-here"
3232
PHX_HOST: "localhost"
3333
MIX_ENV: "dev"
34+
# OpenTelemetry/Splunk Configuration
35+
SPLUNK_REALM: "${SPLUNK_REALM:-us1}"
36+
SPLUNK_ACCESS_TOKEN: "${SPLUNK_ACCESS_TOKEN}"
37+
OTEL_SERVICE_NAME: "${OTEL_SERVICE_NAME:-worms-in-space-backend}"
38+
OTEL_ENVIRONMENT: "${OTEL_ENVIRONMENT:-development}"
3439
volumes:
3540
- .:/app
3641
- deps:/app/deps

0 commit comments

Comments
 (0)