Module: Chronos

Extended by:
ObservabilityFacade
Defined in:
lib/chronos.rb,
lib/chronos/core.rb,
lib/chronos/agent.rb,
lib/chronos/ports.rb,
lib/chronos/rails.rb,
lib/chronos/errors.rb,
lib/chronos/version.rb,
lib/chronos/adapters.rb,
lib/chronos/internal.rb,
lib/chronos/rake_tasks.rb,
lib/chronos/application.rb,
lib/chronos/core/notice.rb,
lib/chronos/integrations.rb,
lib/chronos/configuration.rb,
lib/chronos/rails/railtie.rb,
lib/chronos/core/sanitizer.rb,
lib/chronos/core/breadcrumb.rb,
lib/chronos/ports/transport.rb,
lib/chronos/rails/installer.rb,
lib/chronos/core/runtime_info.rb,
lib/chronos/integrations/rack.rb,
lib/chronos/core/notice_builder.rb,
lib/chronos/core/sql_normalizer.rb,
lib/chronos/ports/context_store.rb,
lib/chronos/core/safe_serializer.rb,
lib/chronos/core/telemetry_event.rb,
lib/chronos/integrations/sidekiq.rb,
lib/chronos/internal/safe_logger.rb,
lib/chronos/internal/worker_pool.rb,
lib/chronos/observability_facade.rb,
lib/chronos/core/backtrace_parser.rb,
lib/chronos/core/cache_normalizer.rb,
lib/chronos/core/metric_aggregate.rb,
lib/chronos/integrations/net_http.rb,
lib/chronos/ports/query_inspector.rb,
lib/chronos/configuration/snapshot.rb,
lib/chronos/core/deploy_normalizer.rb,
lib/chronos/internal/bounded_queue.rb,
lib/chronos/core/payload_serializer.rb,
lib/chronos/core/sql_query_analyzer.rb,
lib/chronos/integrations/active_job.rb,
lib/chronos/integrations/capistrano.rb,
lib/chronos/internal/memory_backlog.rb,
lib/chronos/application/retry_policy.rb,
lib/chronos/configuration/validation.rb,
lib/chronos/core/correlation_context.rb,
lib/chronos/integrations/job_payload.rb,
lib/chronos/application/ignore_policy.rb,
lib/chronos/application/apm_aggregator.rb,
lib/chronos/adapters/net_http_transport.rb,
lib/chronos/application/circuit_breaker.rb,
lib/chronos/core/sensitive_value_filter.rb,
lib/chronos/configuration/apm_validation.rb,
lib/chronos/integrations/rack/middleware.rb,
lib/chronos/application/capture_exception.rb,
lib/chronos/application/capture_telemetry.rb,
lib/chronos/application/delivery_pipeline.rb,
lib/chronos/application/verify_integration.rb,
lib/chronos/core/exception_cause_collector.rb,
lib/chronos/rails/notifications_subscriber.rb,
lib/chronos/application/dependency_reporter.rb,
lib/chronos/application/apm_error_classifier.rb,
lib/chronos/application/remote_configuration.rb,
lib/chronos/adapters/thread_local_context_store.rb,
lib/chronos/rails/active_record_query_inspector.rb,
lib/chronos/core/integration_verification_result.rb,
lib/generators/chronos/install/install_generator.rb

Overview

Framework-independent public facade for the Chronos Ruby agent.

Examples:

Chronos.configure do |config|
  config.project_id = "project-id"
  config.project_key = "project-key"
  config.host = "https://chronos.example.com"
end
Chronos.notify(RuntimeError.new("failed"))

Defined Under Namespace

Modules: Adapters, Application, Core, Generators, Integrations, Internal, ObservabilityFacade, Ports, Rails, RakeTasks Classes: Agent, Configuration, ConfigurationError, Error, IntegrationVerificationError

Constant Summary collapse

VERSION =

Current version of the legacy Chronos Ruby agent.

"1.1.0".freeze

Class Method Summary collapse

Methods included from ObservabilityFacade

cache_integration_options, external_http_integration_options, instrument_net_http, notify_deploy, report_dependencies

Class Method Details

.add_breadcrumb(attributes = {}) ⇒ Object



124
125
126
127
128
129
# File 'lib/chronos.rb', line 124

def add_breadcrumb(attributes = {})
  agent = current_agent
  agent ? agent.add_breadcrumb(attributes) : false
rescue StandardError
  false
end

.apm_integration_optionsObject



145
146
147
148
149
150
# File 'lib/chronos.rb', line 145

def apm_integration_options
  agent = current_agent
  agent ? agent.apm_integration_options : {:enabled => false}
rescue StandardError
  {:enabled => false}
end

.close(timeout = Agent::DEFAULT_FLUSH_TIMEOUT) ⇒ Object



192
193
194
195
196
197
198
199
200
201
# File 'lib/chronos.rb', line 192

def close(timeout = Agent::DEFAULT_FLUSH_TIMEOUT)
  agent = @mutex.synchronize do
    current = @agent
    @agent = nil
    current
  end
  agent ? agent.close(timeout) : true
rescue StandardError
  false
end

.configure {|configuration| ... } ⇒ Object

Yields:

  • (configuration)


75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/chronos.rb', line 75

def configure
  configuration = Configuration.new
  yield configuration if block_given?
  agent = Agent.new(configuration.snapshot)
  previous = nil
  @mutex.synchronize do
    previous = @agent
    @agent = agent
  end
  previous.close if previous
  configuration
end

.configured?Boolean

Returns:

  • (Boolean)


181
182
183
# File 'lib/chronos.rb', line 181

def configured?
  !current_agent.nil?
end

.flush(timeout = Agent::DEFAULT_FLUSH_TIMEOUT) ⇒ Object



185
186
187
188
189
190
# File 'lib/chronos.rb', line 185

def flush(timeout = Agent::DEFAULT_FLUSH_TIMEOUT)
  agent = current_agent
  agent ? agent.flush(timeout) : true
rescue StandardError
  false
end

.ignore_if(&block) ⇒ Object



167
168
169
170
171
172
# File 'lib/chronos.rb', line 167

def ignore_if(&block)
  agent = current_agent
  agent ? agent.ignore_if(&block) : false
rescue StandardError
  false
end

.notify(exception, context = {}) ⇒ Object



88
89
90
91
92
93
# File 'lib/chronos.rb', line 88

def notify(exception, context = {})
  agent = current_agent
  agent ? agent.notify(exception, context) : false
rescue StandardError
  false
end

.notify_once(exception, context = {}) ⇒ Object



160
161
162
163
164
165
# File 'lib/chronos.rb', line 160

def notify_once(exception, context = {})
  agent = current_agent
  agent ? agent.notify_once(exception, context) : false
rescue StandardError
  false
end

.notify_sync(exception, context = {}) ⇒ Object



95
96
97
98
99
100
# File 'lib/chronos.rb', line 95

def notify_sync(exception, context = {})
  agent = current_agent
  agent ? agent.notify_sync(exception, context) : false
rescue StandardError
  false
end

.propagation_contextObject

Returns only trace/request identifiers for optional process-boundary adapters.



153
154
155
156
157
158
# File 'lib/chronos.rb', line 153

def propagation_context
  agent = current_agent
  agent ? agent.propagation_context : {}
rescue StandardError
  {}
end

.rails_integration_options(environment = nil, console = false) ⇒ Object



174
175
176
177
178
179
# File 'lib/chronos.rb', line 174

def rails_integration_options(environment = nil, console = false)
  agent = current_agent
  agent ? agent.rails_integration_options(environment, console) : {:enabled => false}
rescue StandardError
  {:enabled => false}
end

.record_event(event_type, payload = {}, context = {}) ⇒ Object



131
132
133
134
135
136
# File 'lib/chronos.rb', line 131

def record_event(event_type, payload = {}, context = {})
  agent = current_agent
  agent ? agent.record_event(event_type, payload, context) : false
rescue StandardError
  false
end

.record_event_once(key, event_type, payload = {}, context = {}) ⇒ Object



138
139
140
141
142
143
# File 'lib/chronos.rb', line 138

def record_event_once(key, event_type, payload = {}, context = {})
  agent = current_agent
  agent ? agent.record_event_once(key, event_type, payload, context) : false
rescue StandardError
  false
end

.verify_integrationObject



102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/chronos.rb', line 102

def verify_integration
  agent = current_agent
  return agent.verify_integration if agent

  verification_failure(
    "not_configured", "Chronos is not configured.",
    "Run Chronos.configure before verifying the integration."
  )
rescue StandardError
  verification_failure(
    "verification_failed", "Chronos integration verification failed locally.",
    "Review the Chronos configuration and retry."
  )
end

.with_context(context = {}) ⇒ Object



117
118
119
120
121
122
# File 'lib/chronos.rb', line 117

def with_context(context = {})
  agent = current_agent
  return yield unless agent

  agent.with_context(context) { yield }
end