Module: Gritz::Otel

Defined in:
/home/runner/work/gritz/gritz/sources/gritz-otel/lib/gritz/otel.rb,
/home/runner/work/gritz/gritz/sources/gritz-otel/lib/gritz/otel/recorder.rb,
/home/runner/work/gritz/gritz/sources/gritz-otel/lib/gritz/otel/tracing.rb,
/home/runner/work/gritz/gritz/sources/gritz-otel/lib/gritz/otel/version.rb

Overview

Optional worker-local OpenTelemetry integration.

Defined Under Namespace

Modules: ConfigurationDSL

Constant Summary collapse

VERSION =
"0.9.1"

Class Method Summary collapse

Class Method Details

.install(config, &configure) ⇒ Object

Registration is safe before fork; SDK providers/exporters are built in the worker hook.



22
23
24
25
26
27
28
29
30
31
32
33
# File '/home/runner/work/gritz/gritz/sources/gritz-otel/lib/gritz/otel.rb', line 22

def install(config, &configure)
  return config if config.middleware.entries.any? { |entry| entry.middleware == ServerTracing }
  raise Gritz::ConfigurationError, "a metrics recorder is already installed" if config.metrics_recorder_factory

  config.middleware.insert_after(Gritz::Middleware::Context, ServerTracing)
  unless Gritz::Client.middleware.entries.any? { |entry| entry.middleware == ClientTracing }
    Gritz::Client.middleware.use(ClientTracing)
  end
  config.add_hook(:on_worker_boot) { bootstrap(config, &configure) }
  config.metrics_recorder_factory = ->(worker:) { Recorder.new(worker:, exporter: @metrics_exporter, timeout: export_timeout(config)) }
  config
end