Sha256: 4f4bf874079d3c29be64914ebf3b07efe5007e5296e5cda31f7cbd4439d06c33

Contents?: true

Size: 1.96 KB

Versions: 1

Compression:

Stored size: 1.96 KB

Contents

# 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_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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hephaestus-0.8.9 config/initializers/opentelemetry.rb