# typed: false # frozen_string_literal: true # development is intentionally disabled return if Rails.env.development? return if defined?(Rails::Console) # establish the environment for OTEL ENV["OTEL_EXPORTER_OTLP_ENDPOINT"] = "http://service-otelcol-#{Rails.env}.internal:4318" ENV["OTEL_EXPORTER_OTLP_HEADERS"] = "x-honeycomb-dataset=plug-#{plug_shortname}-#{Rails.env}" ENV["OTEL_SERVICE_NAME"] = "plug-#{plug_shortname}-#{Rails.env}" require "opentelemetry/sdk" require "opentelemetry/instrumentation/all" require "opentelemetry/exporter/otlp" require "opentelemetry/semantic_conventions" OpenTelemetry::SDK.configure do |c| c.logger = Rails.logger ##### Instruments c.use("OpenTelemetry::Instrumentation::Rack", { use_rack_events: false }) c.use("OpenTelemetry::Instrumentation::ActionPack") c.use("OpenTelemetry::Instrumentation::ActionView") c.use("OpenTelemetry::Instrumentation::ActiveJob") c.use("OpenTelemetry::Instrumentation::ActiveRecord") c.use("OpenTelemetry::Instrumentation::AwsSdk") c.use("OpenTelemetry::Instrumentation::ConcurrentRuby") c.use("OpenTelemetry::Instrumentation::Faraday") c.use("OpenTelemetry::Instrumentation::HttpClient") c.use("OpenTelemetry::Instrumentation::Net::HTTP") c.use("OpenTelemetry::Instrumentation::PG", { # By default, this instrumentation includes the executed SQL as the `db.statement` # semantic attribute. Optionally, you may disable the inclusion of this attribute entirely by # setting this option to :omit or sanitize the attribute by setting to :obfuscate db_statement: :obfuscate, }) c.use("OpenTelemetry::Instrumentation::Rails") c.use("OpenTelemetry::Instrumentation::RestClient") if !productionish? c.add_span_processor( OpenTelemetry::SDK::Trace::Export::BatchSpanProcessor.new( OpenTelemetry::Exporter::OTLP::Exporter.new, ), ) else # useful for testing instrumentation c.add_span_processor( OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new( OpenTelemetry::SDK::Trace::Export::SpanExporter.new, ), ) end end