Class: Multiplayer::Exporter

Inherits:
OpenTelemetry::Exporter::OTLP::Exporter
  • Object
show all
Defined in:
lib/multiplayer/exporters/http_exporter.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = Multiplayer::ExporterConfig.new) ⇒ Exporter

Returns a new instance of Exporter.



17
18
19
20
21
22
23
24
# File 'lib/multiplayer/exporters/http_exporter.rb', line 17

def initialize(config = Multiplayer::ExporterConfig.new)

  config.endpoint ||= MULTIPLAYER_OTEL_DEFAULT_TRACES_EXPORTER_URL
  config.headers = (config.headers || {}).merge(
    config.api_key ? { "Authorization" => config.api_key } : {}
  )
  super(endpoint: config.endpoint, headers: config.headers)
end

Class Method Details

.filter_mp_attributes(exporter) ⇒ Object



30
31
32
33
34
35
36
37
38
# File 'lib/multiplayer/exporters/http_exporter.rb', line 30

def self.filter_mp_attributes(exporter)
  original_export = exporter.method("export")
  exporter.define_singleton_method("export") do |*args, &block|
    args[0] = Exporter.prefilter(args[0])
    original_export.call(*args, &block)
  end

  exporter
end

Instance Method Details

#get_default_url(config) ⇒ Object



26
27
28
# File 'lib/multiplayer/exporters/http_exporter.rb', line 26

def get_default_url(config)
  config.url || MULTIPLAYER_OTEL_DEFAULT_TRACES_EXPORTER_URL
end