The opentelemetry-sdk and opentelemetry-instrumentation-all packages populate the traces/spans automatically with minimal manual effort.
For the list of supported frameworks, see Supported Framework.
The following procedure is an example of instrumenting a simple Ruby On Rails application:
- Add the following packages to the existing
Gemfile.
gem 'opentelemetry-sdk'
gem 'opentelemetry-exporter-otlp'
gem 'opentelemetry-instrumentation-all'
- Configure the Ruby application to initialize OpenTelemetry by creating a
<project>/config/initializers/opentelemetry.rb file.
# config/initializers/opentelemetry.rb
require 'opentelemetry/sdk'
require 'opentelemetry/exporter/otlp'
require 'opentelemetry/instrumentation/all'
OpenTelemetry::SDK.configure do |c|
c.resource = OpenTelemetry::SDK::Resources::Resource.create({
OpenTelemetry::SemanticConventions::Resource::SERVICE_NAMESPACE => '<YOUR_SERVICE_NAMESPACE>', # corresponds to Appd controller Application name
OpenTelemetry::SemanticConventions::Resource::SERVICE_NAME => '<YOUR_SERVICE_NAME>' # corresponds to Appd controller Tier name
})
c.use_all() # enables all instrumentation!
end
- Configure the application to report traces to the OpenTelemetry Collector by setting up the
OTEL_EXPORTER_OTLP_ENDPOINT environment variable on which the OpenTelemetry Collector listens to:
export OTEL_EXPORTER_OTLP_ENDPOINT=http://0.0.0.0:4318
Note:
0.0.0.0 is the OpenTelemetry collector HOST and 4318 is the OpenTelemetry Collector PORT. For more information about available exporters, see Ruby Exporter.
- Install the newly added Gems to Gemfile.
- Start the Ruby application.