-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Open Telemetry initializer for Rails
This initializes Open Telemetry for Rails applications. This can be used to send trace information to a collector. This functionality is only enabled if the env var ENABLE_OPEN_TELEMETRY is set to "true".
- Loading branch information
1 parent
6e15638
commit 8576638
Showing
4 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module GovukOpenTelemetry | ||
def self.should_configure? | ||
ENV["ENABLE_OPEN_TELEMETRY"] == "true" | ||
end | ||
|
||
def self.configure(service_name) | ||
return unless should_configure? | ||
|
||
require "opentelemetry/sdk" | ||
require "opentelemetry/exporter/otlp" | ||
require "opentelemetry/instrumentation/all" | ||
|
||
OpenTelemetry::SDK.configure do |config| | ||
config.service_name = service_name | ||
config.use_all # enables all instrumentation! | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters