File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
manual-instrumentation/worms_in_space/lib/worms_in_space Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,9 @@ defmodule WormsInSpace.Application do
77
88 @ impl true
99 def start ( _type , _args ) do
10+ # Setup OpenTelemetry instrumentations
11+ setup_opentelemetry ( )
12+
1013 children = [
1114 # Start the Ecto repository
1215 WormsInSpace.Repo ,
@@ -24,6 +27,23 @@ defmodule WormsInSpace.Application do
2427 Supervisor . start_link ( children , opts )
2528 end
2629
30+ defp setup_opentelemetry do
31+ # Setup OpenTelemetry SDK
32+ :opentelemetry_cowboy . setup ( )
33+ OpentelemetryPhoenix . setup ( adapter: :cowboy2 )
34+ OpentelemetryEcto . setup ( [ :worms_in_space , :repo ] )
35+ OpentelemetryAbsinthe . setup ( )
36+
37+ # Log initialization status
38+ if System . get_env ( "SPLUNK_ACCESS_TOKEN" ) do
39+ service_name = System . get_env ( "OTEL_SERVICE_NAME" , "worms-in-space-backend" )
40+ realm = System . get_env ( "SPLUNK_REALM" , "us0" )
41+ IO . puts ( "OpenTelemetry initialized for #{ service_name } sending to Splunk #{ realm } " )
42+ else
43+ IO . puts ( "OpenTelemetry: No Splunk access token configured. Traces will not be sent." )
44+ end
45+ end
46+
2747 # Tell Phoenix to update the endpoint configuration
2848 # whenever the application is updated.
2949 @ impl true
You can’t perform that action at this time.
0 commit comments