Module: Chronos

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/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/core/backtrace_parser.rb,
lib/chronos/core/metric_aggregate.rb,
lib/chronos/configuration/snapshot.rb,
lib/chronos/internal/bounded_queue.rb,
lib/chronos/core/payload_serializer.rb,
lib/chronos/internal/memory_backlog.rb,
lib/chronos/application/retry_policy.rb,
lib/chronos/configuration/validation.rb,
lib/chronos/integrations/job_payload.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/core/exception_cause_collector.rb,
lib/chronos/rails/notifications_subscriber.rb,
lib/chronos/application/remote_configuration.rb,
lib/chronos/adapters/thread_local_context_store.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, Ports, Rails Classes: Agent, Configuration, ConfigurationError, Error

Constant Summary collapse

VERSION =

Current version of the legacy Chronos Ruby agent.

"0.7.0.pre.1".freeze

Class Method Summary collapse

Class Method Details

.add_breadcrumb(attributes = {}) ⇒ Object



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

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

.apm_integration_optionsObject



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

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



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

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)


62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/chronos.rb', line 62

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)


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

def configured?
  !current_agent.nil?
end

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



150
151
152
153
154
155
# File 'lib/chronos.rb', line 150

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

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



75
76
77
78
79
80
# File 'lib/chronos.rb', line 75

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

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



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

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

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



82
83
84
85
86
87
# File 'lib/chronos.rb', line 82

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.



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

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

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



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

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



103
104
105
106
107
108
# File 'lib/chronos.rb', line 103

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



110
111
112
113
114
115
# File 'lib/chronos.rb', line 110

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

.with_context(context = {}) ⇒ Object



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

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

  agent.with_context(context) { yield }
end