Class: Ask::Observability::Configuration
- Inherits:
-
Object
- Object
- Ask::Observability::Configuration
- Defined in:
- lib/ask/observability/configuration.rb
Overview
Configuration for ask-observability. Set before the railtie runs (config/initializers/ask_observability.rb) so the metrics are created with their final label set — prometheus-client fixes a metric's label keys at creation time.
Instance Attribute Summary collapse
-
#enabled ⇒ Object
Master switch: when false, the subscriber, the OpenTelemetry bootstrap, and the /metrics mount all no-op.
-
#json_logging ⇒ Object
Structured JSON logs on stdout via rails_semantic_logger (applied when that gem is present and the app hasn't configured appenders).
-
#label_metadata ⇒ Object
Metadata keys from Ask::Instrumentation.with_metadata to expose as metric labels.
-
#metrics_path ⇒ Object
Mount path for the /metrics Rack endpoint; nil disables the mount (a host app that serves its own /metrics can point this elsewhere or nil and serve Ask::Observability.registry itself).
-
#otlp_endpoint ⇒ Object
OTLP/HTTP endpoint spans are exported to.
-
#service_name ⇒ Object
service.name for OpenTelemetry spans and logs.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#metadata_label_keys ⇒ Array<Symbol>
The configured metadata keys, normalized to symbols.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
38 39 40 41 42 43 44 45 |
# File 'lib/ask/observability/configuration.rb', line 38 def initialize @enabled = true @service_name = nil @otlp_endpoint = ENV.fetch('OTEL_EXPORTER_OTLP_ENDPOINT', 'http://localhost:4318/v1/traces') @json_logging = true @metrics_path = '/metrics' @label_metadata = [] end |
Instance Attribute Details
#enabled ⇒ Object
Master switch: when false, the subscriber, the OpenTelemetry bootstrap, and the /metrics mount all no-op. Set in tests/CI to keep output clean.
13 14 15 |
# File 'lib/ask/observability/configuration.rb', line 13 def enabled @enabled end |
#json_logging ⇒ Object
Structured JSON logs on stdout via rails_semantic_logger (applied when that gem is present and the app hasn't configured appenders).
25 26 27 |
# File 'lib/ask/observability/configuration.rb', line 25 def json_logging @json_logging end |
#label_metadata ⇒ Object
Metadata keys from Ask::Instrumentation.with_metadata to expose as metric labels. WARNING: every distinct value creates a new series — only use low-cardinality keys (workspace_id, org, tenant), never per-request ids.
36 37 38 |
# File 'lib/ask/observability/configuration.rb', line 36 def @label_metadata end |
#metrics_path ⇒ Object
Mount path for the /metrics Rack endpoint; nil disables the mount (a host app that serves its own /metrics can point this elsewhere or nil and serve Ask::Observability.registry itself).
30 31 32 |
# File 'lib/ask/observability/configuration.rb', line 30 def metrics_path @metrics_path end |
#otlp_endpoint ⇒ Object
OTLP/HTTP endpoint spans are exported to. Defaults to the local collector (OpenObserve reference stack).
21 22 23 |
# File 'lib/ask/observability/configuration.rb', line 21 def otlp_endpoint @otlp_endpoint end |
#service_name ⇒ Object
service.name for OpenTelemetry spans and logs. Defaults to the Rails app name when running under Rails, else "ask-app".
17 18 19 |
# File 'lib/ask/observability/configuration.rb', line 17 def service_name @service_name end |
Instance Method Details
#metadata_label_keys ⇒ Array<Symbol>
The configured metadata keys, normalized to symbols.
50 51 52 |
# File 'lib/ask/observability/configuration.rb', line 50 def @label_metadata.map(&:to_sym) end |