Module: Chronos

Defined in:
lib/chronos.rb,
lib/chronos/core.rb,
lib/chronos/agent.rb,
lib/chronos/ports.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/core/sanitizer.rb,
lib/chronos/core/breadcrumb.rb,
lib/chronos/ports/transport.rb,
lib/chronos/core/runtime_info.rb,
lib/chronos/integrations/rack.rb,
lib/chronos/core/notice_builder.rb,
lib/chronos/ports/context_store.rb,
lib/chronos/core/safe_serializer.rb,
lib/chronos/internal/safe_logger.rb,
lib/chronos/internal/worker_pool.rb,
lib/chronos/core/backtrace_parser.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/adapters/net_http_transport.rb,
lib/chronos/application/circuit_breaker.rb,
lib/chronos/core/sensitive_value_filter.rb,
lib/chronos/integrations/rack/middleware.rb,
lib/chronos/application/capture_exception.rb,
lib/chronos/application/delivery_pipeline.rb,
lib/chronos/core/exception_cause_collector.rb,
lib/chronos/application/remote_configuration.rb,
lib/chronos/adapters/thread_local_context_store.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, Integrations, Internal, Ports Classes: Agent, Configuration, ConfigurationError, Error

Constant Summary collapse

VERSION =

Current version of the legacy Chronos Ruby agent.

"0.4.0.pre.1".freeze

Class Method Summary collapse

Class Method Details

.add_breadcrumb(attributes = {}) ⇒ Object



91
92
93
94
95
96
# File 'lib/chronos.rb', line 91

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

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



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

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)


57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/chronos.rb', line 57

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)


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

def configured?
  !current_agent.nil?
end

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



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

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

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



70
71
72
73
74
75
# File 'lib/chronos.rb', line 70

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

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



77
78
79
80
81
82
# File 'lib/chronos.rb', line 77

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

.with_context(context = {}) ⇒ Object



84
85
86
87
88
89
# File 'lib/chronos.rb', line 84

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

  agent.with_context(context) { yield }
end