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.
63 64 65 |
# File 'lib/active_agent/telemetry.rb', line 63 def configuration @configuration ||= Configuration.new end |
.configure {|config| ... } ⇒ Configuration
Configures telemetry with a block.
79 80 81 82 |
# File 'lib/active_agent/telemetry.rb', line 79 def configure yield configuration if block_given? configuration end |
.enabled? ⇒ Boolean
Returns whether telemetry is enabled and configured.
94 95 96 |
# File 'lib/active_agent/telemetry.rb', line 94 def enabled? configuration.enabled? && configuration.configured? end |
.flush ⇒ void
This method returns an undefined value.
Flushes any buffered traces immediately.
137 138 139 |
# File 'lib/active_agent/telemetry.rb', line 137 def flush tracer.flush if enabled? end |
.reset_configuration! ⇒ Configuration
Resets the configuration to defaults.
87 88 89 |
# File 'lib/active_agent/telemetry.rb', line 87 def reset_configuration! @configuration = Configuration.new end |
.shutdown ⇒ void
This method returns an undefined value.
Shuts down telemetry, flushing remaining traces.
144 145 146 |
# File 'lib/active_agent/telemetry.rb', line 144 def shutdown tracer.shutdown if @tracer end |
.span(name, **attributes) ⇒ Span
Records a standalone span (outside of a trace context).
128 129 130 131 132 |
# File 'lib/active_agent/telemetry.rb', line 128 def span(name, **attributes) return NullSpan.new unless enabled? tracer.span(name, **attributes) end |