Module: ActiveAgent::Telemetry
- Extended by:
- ActiveSupport::Autoload
- Defined in:
- lib/active_agent/telemetry.rb,
lib/active_agent/telemetry/span.rb,
lib/active_agent/telemetry/tracer.rb,
lib/active_agent/telemetry/reporter.rb,
lib/active_agent/telemetry/configuration.rb,
lib/active_agent/telemetry/instrumentation.rb
Overview
Telemetry module for collecting and reporting agent traces.
Provides optional observability by capturing agent generation traces, tool calls, token usage, and errors. Reports to a configured endpoint (self-hosted or ActiveAgents.ai hosted service).
Features
- Trace Collection: Captures full generation lifecycle with spans
- Token Tracking: Records input/output/thinking tokens per generation
- Tool Call Tracing: Captures tool invocations with arguments and results
- Error Tracking: Records errors with backtraces
- Async Reporting: Non-blocking HTTP reporting with background thread
Configuration
Configure in your Rails initializer or activeagent.yml:
Defined Under Namespace
Modules: Instrumentation Classes: Configuration, NullSpan, Reporter, Span, Tracer
Class Method Summary collapse
-
.configuration ⇒ Configuration
Returns the telemetry configuration instance.
-
.configure {|config| ... } ⇒ Configuration
Configures telemetry with a block.
-
.enabled? ⇒ Boolean
Returns whether telemetry is enabled and configured.
-
.flush ⇒ void
Flushes any buffered traces immediately.
-
.reset_configuration! ⇒ Configuration
Resets the configuration to defaults.
-
.shutdown ⇒ void
Shuts down telemetry, flushing remaining traces.
-
.span(name, **attributes) ⇒ Span
Records a standalone span (outside of a trace context).
-
.trace(name, **attributes) {|trace| ... } ⇒ Span
Starts a new trace for an agent generation.
-
.tracer ⇒ Tracer
Returns the global tracer instance.
Class Method Details
.configuration ⇒ Configuration
Returns the telemetry configuration instance.
62 63 64 |
# File 'lib/active_agent/telemetry.rb', line 62 def configuration @configuration ||= Configuration.new end |
.configure {|config| ... } ⇒ Configuration
Configures telemetry with a block.
78 79 80 81 |
# File 'lib/active_agent/telemetry.rb', line 78 def configure yield configuration if block_given? configuration end |
.enabled? ⇒ Boolean
Returns whether telemetry is enabled and configured.
93 94 95 |
# File 'lib/active_agent/telemetry.rb', line 93 def enabled? configuration.enabled? && configuration.configured? end |
.flush ⇒ void
This method returns an undefined value.
Flushes any buffered traces immediately.
136 137 138 |
# File 'lib/active_agent/telemetry.rb', line 136 def flush tracer.flush if enabled? end |
.reset_configuration! ⇒ Configuration
Resets the configuration to defaults.
86 87 88 |
# File 'lib/active_agent/telemetry.rb', line 86 def reset_configuration! @configuration = Configuration.new end |
.shutdown ⇒ void
This method returns an undefined value.
Shuts down telemetry, flushing remaining traces.
143 144 145 |
# File 'lib/active_agent/telemetry.rb', line 143 def shutdown tracer.shutdown if @tracer end |
.span(name, **attributes) ⇒ Span
Records a standalone span (outside of a trace context).
127 128 129 130 131 |
# File 'lib/active_agent/telemetry.rb', line 127 def span(name, **attributes) return NullSpan.new unless enabled? tracer.span(name, **attributes) end |