feat: add telemetry engine for distributed tracing#326
Open
feat: add telemetry engine for distributed tracing#326
Conversation
Adds a comprehensive telemetry system for collecting and reporting agent traces
to hosted or self-hosted observability endpoints.
Features:
- Trace collection with spans for generation lifecycle
- Token usage tracking (input, output, thinking)
- Tool call tracing with timing
- Error recording with backtraces
- Async HTTP reporting with batching
- Configurable sampling rate
- Auto-instrumentation via railtie
Configuration via YAML:
telemetry:
enabled: true
endpoint: https://api.activeagents.ai/v1/traces
api_key: your-api-key
sample_rate: 1.0
Or programmatically:
ActiveAgent::Telemetry.configure do |config|
config.enabled = true
config.endpoint = "https://..."
config.api_key = "..."
end
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This adds a Rails Engine to the ActiveAgent gem that provides: - TelemetryTrace model for storing traces - TracesController for viewing traces in a dashboard - API::TracesController for ingesting traces - ProcessTelemetryTracesJob for async trace processing - ERB views with Tailwind CSS for the dashboard UI - Install generator for migrations and configuration The dashboard supports two modes: - Local mode: Single-tenant, no auth, synchronous processing - Multi-tenant mode: Account association, API key auth, async processing Configuration options: - multi_tenant: Enable multi-tenant mode - account_class: Class name for Account model - current_account_method: Controller method to get current account - trace_model_class: Custom trace model class - use_inertia: Enable React/Inertia frontend - authentication_method: Custom auth callback 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
The method name 'create_migration' conflicts with ActiveRecord::Generators::Migration module internals. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a comprehensive telemetry system for collecting and reporting agent traces to hosted or self-hosted observability endpoints. This is competitive with Phoenix Arize but built natively for Rails.
Features:
Configuration via YAML:
Or programmatically:
Files added:
lib/active_agent/telemetry.rb- Main module with NullSpan for disabled statelib/active_agent/telemetry/configuration.rb- Configuration optionslib/active_agent/telemetry/span.rb- Span with attributes, tokens, eventslib/active_agent/telemetry/tracer.rb- Trace management with thread-local contextlib/active_agent/telemetry/reporter.rb- Async HTTP reporter with batchinglib/active_agent/telemetry/instrumentation.rb- Auto-instrumentation moduledocs/framework/telemetry.md- Comprehensive documentationTest plan
🤖 Generated with Claude Code