Module: RailsOtelContext
- Defined in:
- lib/rails_otel_context.rb,
lib/rails_otel_context/railtie.rb,
lib/rails_otel_context/version.rb,
lib/rails_otel_context/adapters.rb,
lib/rails_otel_context/adapters/pg.rb,
lib/rails_otel_context/configuration.rb,
lib/rails_otel_context/frame_context.rb,
lib/rails_otel_context/adapters/redis.rb,
lib/rails_otel_context/adapters/mysql2.rb,
lib/rails_otel_context/request_context.rb,
lib/rails_otel_context/source_location.rb,
lib/rails_otel_context/adapters/trilogy.rb,
lib/rails_otel_context/adapters/clickhouse.rb,
lib/rails_otel_context/activerecord_context.rb,
lib/rails_otel_context/call_context_processor.rb
Defined Under Namespace
Modules: ActiveRecordContext, Adapters, FrameContext, Frameable, RequestContext, SourceLocation
Classes: CallContextProcessor, Configuration, Railtie
Constant Summary
collapse
- VERSION =
'0.9.2'
Class Method Summary
collapse
Class Method Details
.configuration ⇒ Object
21
22
23
|
# File 'lib/rails_otel_context.rb', line 21
def configuration
@configuration ||= Configuration.new
end
|
25
26
27
|
# File 'lib/rails_otel_context.rb', line 25
def configure
yield(configuration)
end
|
.install_processor! ⇒ Object
Registers CallContextProcessor with the OTel tracer_provider. Called automatically by the Railtie after_initialize. Call this manually when OpenTelemetry::SDK.configure runs after Rails boot (e.g. in a custom after_initialize block):
OpenTelemetry::SDK.configure { |c| c.use_all() }
RailsOtelContext.install_processor!
Safe to call multiple times — idempotent.
42
43
44
45
46
47
48
49
50
|
# File 'lib/rails_otel_context.rb', line 42
def install_processor!
return if @processor_installed
return unless defined?(Rails) && Rails.root
return unless OpenTelemetry.tracer_provider.respond_to?(:add_span_processor)
@processor_installed = true
processor = RailsOtelContext::CallContextProcessor.new(app_root: Rails.root)
OpenTelemetry.tracer_provider.add_span_processor(processor)
end
|
.pop_frame ⇒ Object
61
62
63
|
# File 'lib/rails_otel_context.rb', line 61
def pop_frame
FrameContext.pop
end
|
.push_frame(class_name:, method_name:) ⇒ Object
57
58
59
|
# File 'lib/rails_otel_context.rb', line 57
def push_frame(class_name:, method_name:)
FrameContext.push(class_name: class_name, method_name: method_name)
end
|
.reset_configuration! ⇒ Object
29
30
31
|
# File 'lib/rails_otel_context.rb', line 29
def reset_configuration!
@configuration = Configuration.new
end
|
.with_frame(class_name:, method_name:, &block) ⇒ Object
Convenience delegates to FrameContext — see FrameContext for full docs.
53
54
55
|
# File 'lib/rails_otel_context.rb', line 53
def with_frame(class_name:, method_name:, &block)
FrameContext.with_frame(class_name: class_name, method_name: method_name, &block)
end
|