Sha256: 97d9bb3b433bc797cfd2687fabf07a61694162ba1a86371d3dd781a658afa485

Contents?: true

Size: 1.07 KB

Versions: 24

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

# Copyright The OpenTelemetry Authors
#
# SPDX-License-Identifier: Apache-2.0
module OpenTelemetry
  module Instrumentation
    module Rails
      # Railtie automatically configure the OpentTelemetry SDK
      #
      # This railtie will set defaults for the following environment variables:
      # `OTEL_SERVICE_NAME` - if unset, will default to the Rails application name
      # `OTEL_RESOURCE_ATTRIBUTES` - if unset, will set the deployment environment to the current Rails environment
      #
      # This will also set the `OpenTelemetry.logger` to the Rails logger.
      class Railtie < ::Rails::Railtie
        railtie_name :opentelemetry
        initializer 'opentelemetry.configure' do |app|
          # See https://api.rubyonrails.org/classes/Rails/Generators/NamedBase.html#method-i-application_name
          ENV['OTEL_SERVICE_NAME'] ||= app.class.name.split('::').first.underscore

          ::OpenTelemetry::SDK.configure do |c|
            c.logger = ::Rails.logger
            c.use_all
          end
        end
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
opentelemetry-instrumentation-rails-0.23.1 lib/opentelemetry/instrumentation/rails/railtie.rb
opentelemetry-instrumentation-rails-0.23.0 lib/opentelemetry/instrumentation/rails/railtie.rb
opentelemetry-instrumentation-rails-0.22.0 lib/opentelemetry/instrumentation/rails/railtie.rb
opentelemetry-instrumentation-rails-0.21.0 lib/opentelemetry/instrumentation/rails/railtie.rb