Sha256: 748556d48118f36deeb94e5467632d94b39096a1afa6a4663067288d1bfdf8f3

Contents?: true

Size: 1.19 KB

Versions: 3

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true

require_relative "opentelemetry/version"
require_relative "opentelemetry/configurator"
require_relative "opentelemetry/resource/detectors/aspecto"
require "opentelemetry/sdk"
require "opentelemetry/exporter/otlp"
require "opentelemetry/instrumentation/all"

module Aspecto
  # Aspecto Opentelemetry Distro
  module Opentelemetry
    module_function

    class Error < StandardError; end

    def configure
      configurator = Configurator.new
      yield configurator if block_given?

      OpenTelemetry::SDK.configure do |c|
        c.service_name = configurator.service_name
        c.resource = Aspecto::Opentelemetry::Resource::Detectors::Aspecto.detect
        c.use_all "OpenTelemetry::Instrumentation::ActionPack" => { enable_recognize_route: true }

        c.add_span_processor(
          OpenTelemetry::SDK::Trace::Export::BatchSpanProcessor.new(
            OpenTelemetry::Exporter::OTLP::Exporter.new(endpoint: "https://otelcol.aspecto.io/v1/trace", headers: {
                                                          "Authorization" => configurator.aspecto_auth
                                                        })
          )
        )
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rr-temp-demo-demo-0.1.3 lib/aspecto/opentelemetry.rb
rr-temp-demo-demo-0.1.1 lib/aspecto/opentelemetry.rb
rr-temp-demo-demo-0.1.0 lib/aspecto/opentelemetry.rb