Sha256: 657587ab8965893ad28aba81c3d2ed774296dfb831f94e15d5284d1e61083113

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 KB

Contents

# typed: false
# frozen_string_literal: true

unless Rails.env.development?
  # establish the environment for OTEL
  ENV["OTEL_EXPORTER_OTLP_ENDPOINT"] = "https://api.honeycomb.io"

  ENV["OTEL_EXPORTER_OTLP_HEADERS"] = set_env_var(
    production: "op://Plug-#{plug_name}/Production/OTEL_EXPORTER_OTLP_HEADERS",
    staging: "op://Plug-#{plug_name}/Staging/OTEL_EXPORTER_OTLP_HEADERS",
    local: ENV.fetch("OTEL_EXPORTER_OTLP_HEADERS", "x-honeycomb-team=your-api-key"),
  )

  ENV["OTEL_SERVICE_NAME"] = "plug-#{plug_shortname}-#{Rails.env}"

  require "opentelemetry/sdk"
  require "opentelemetry/semantic_conventions"

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

    c.use_all(
      "OpenTelemetry::Instrumentation::PG" => { db_statement: :obfuscate },
      "OpenTelemetry::Instrumentation::Rack" => { use_rack_events: false },
    )

    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 # development is intentionally disabled
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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