Class: ActiveAgent::Telemetry::Configuration

Inherits:
ActiveAgents::Telemetry::Configuration
  • Object
show all
Defined in:
lib/active_agent/telemetry/configuration.rb

Overview

The framework's telemetry configuration, now provided by the activeagents-telemetry gem. This subclass keeps the framework's historical behavior on top of the shared core:

  • telemetry is opt-in (enabled defaults to false)
  • local_storage: true persists traces through the dashboard's trace model instead of HTTP

Every other option — endpoint, api_key, sample_rate, batch_size, flush_interval, capture_bodies, redact_attributes, service_name, environment, resource_attributes — lives on the shared class, so existing config/active_agent.yml files keep working unchanged.

See Also:

  • ActiveAgents::Telemetry::Configuration

Constant Summary collapse

LOCAL_ENDPOINT_PATH =

Fallback ingest path when the dashboard engine's mount point can't be resolved from the host's routes (e.g. engine not mounted).

"/activeagents/api/traces"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



27
28
29
30
31
32
33
# File 'lib/active_agent/telemetry/configuration.rb', line 27

def initialize
  super
  # The framework predates the shared gem and has always been opt-in;
  # adapters treat the presence of an api_key as the switch instead.
  self.enabled = false
  @local_storage = false
end

Instance Attribute Details

#local_storageBoolean

Returns Whether to store traces in the app's own database.

Returns:

  • (Boolean)

    Whether to store traces in the app's own database



25
26
27
# File 'lib/active_agent/telemetry/configuration.rb', line 25

def local_storage
  @local_storage
end

Instance Method Details

#local_endpoint_pathObject

The dashboard engine's ingest path, derived from wherever the host app actually mounted it — "/activeagents", "/observability", or "/" on a dedicated subdomain all work. Falls back to LOCAL_ENDPOINT_PATH when the engine isn't mounted.



62
63
64
65
# File 'lib/active_agent/telemetry/configuration.rb', line 62

def local_endpoint_path
  mount = dashboard_mount_path
  mount ? "#{mount}/api/traces" : LOCAL_ENDPOINT_PATH
end

#local_storage?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/active_agent/telemetry/configuration.rb', line 39

def local_storage?
  @local_storage
end

#local_storeObject

When local storage is on, traces persist through the dashboard's trace model rather than leaving the process.



49
50
51
# File 'lib/active_agent/telemetry/configuration.rb', line 49

def local_store
  super || (dashboard_store if local_storage?)
end

#local_store?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/active_agent/telemetry/configuration.rb', line 43

def local_store?
  local_storage? || super
end

#mount_path_in(route_set) ⇒ Object

The engine's mount path within a given route set, or nil when it isn't mounted there. Separate from #dashboard_mount_path so it can be exercised against a route set directly.



126
127
128
129
130
131
132
133
134
135
136
# File 'lib/active_agent/telemetry/configuration.rb', line 126

public def mount_path_in(route_set)
  return nil unless defined?(::ActiveAgent::Dashboard::Engine)

  route = route_set.routes.find do |candidate|
    mounted_engine(candidate.app) == ::ActiveAgent::Dashboard::Engine
  end
  return nil unless route

  # "/activeagents(.:format)" -> "/activeagents"; a root mount -> "".
  route.path.spec.to_s.sub(/\(\.:format\)\z/, "").chomp("/")
end

#resolved_endpointObject

Returns the resolved endpoint for trace reporting.



54
55
56
# File 'lib/active_agent/telemetry/configuration.rb', line 54

def resolved_endpoint
  local_storage? ? local_endpoint_path : endpoint
end

#resolved_service_nameObject

The framework's historical fallback is "activeagent", not the shared core's generic "ruby".



69
70
71
72
# File 'lib/active_agent/telemetry/configuration.rb', line 69

def resolved_service_name
  value = super
  value == "ruby" ? "activeagent" : value
end

#to_hObject



74
75
76
# File 'lib/active_agent/telemetry/configuration.rb', line 74

def to_h
  super.merge(local_storage: local_storage)
end