Class: CDC::Core::Observer
- Inherits:
-
Object
- Object
- CDC::Core::Observer
- Defined in:
- lib/cdc/core/observer.rb
Overview
Observer interface for CDC runtime instrumentation.
Observers receive lifecycle and result notifications from core runtime objects. The default implementation is a no-op so callers can opt in without taking a dependency on a metrics backend.
Direct Known Subclasses
Constant Summary collapse
- METRIC_NAMES =
Canonical metric names emitted by core runtime hooks.
Ractor.make_shareable({ dispatch_started: 'cdc_core.dispatch.started', dispatch_succeeded: 'cdc_core.dispatch.succeeded', dispatch_failed: 'cdc_core.dispatch.failed', dispatch_skipped: 'cdc_core.dispatch.skipped' }.freeze)
Class Method Summary collapse
-
.failed_metric_name ⇒ String
Canonical metric name for the failure hook.
-
.metric_tags(payload) ⇒ Hash{String=>Object}
Build a canonical metric tag set for a CDC work item or result.
-
.skipped_metric_name ⇒ String
Canonical metric name for the skip hook.
-
.started_metric_name ⇒ String
Canonical metric name for the start hook.
-
.succeeded_metric_name ⇒ String
Canonical metric name for the success hook.
Instance Method Summary collapse
-
#dispatch_failed(_result) ⇒ void
Called after a work item fails.
-
#dispatch_skipped(_result) ⇒ void
Called when a work item is filtered or skipped.
-
#dispatch_started(_event) ⇒ void
Called before a work item is dispatched.
-
#dispatch_succeeded(_result) ⇒ void
Called after a work item is processed successfully.
Class Method Details
.failed_metric_name ⇒ String
Canonical metric name for the failure hook.
54 |
# File 'lib/cdc/core/observer.rb', line 54 def self.failed_metric_name = METRIC_NAMES.fetch(:dispatch_failed) |
.metric_tags(payload) ⇒ Hash{String=>Object}
Build a canonical metric tag set for a CDC work item or result.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/cdc/core/observer.rb', line 23 def self.(payload) = {} # : Hash[String, untyped] case payload when ChangeEvent .merge!((payload)) when TransactionEnvelope .merge!((payload)) when ProcessorResult .merge!((payload)) when Array .merge!((payload)) else ['kind'] = payload.class.name end Ractor.make_shareable(.freeze) end |
.skipped_metric_name ⇒ String
Canonical metric name for the skip hook.
59 |
# File 'lib/cdc/core/observer.rb', line 59 def self.skipped_metric_name = METRIC_NAMES.fetch(:dispatch_skipped) |
.started_metric_name ⇒ String
Canonical metric name for the start hook.
44 |
# File 'lib/cdc/core/observer.rb', line 44 def self.started_metric_name = METRIC_NAMES.fetch(:dispatch_started) |
.succeeded_metric_name ⇒ String
Canonical metric name for the success hook.
49 |
# File 'lib/cdc/core/observer.rb', line 49 def self.succeeded_metric_name = METRIC_NAMES.fetch(:dispatch_succeeded) |
Instance Method Details
#dispatch_failed(_result) ⇒ void
This method returns an undefined value.
Called after a work item fails.
77 |
# File 'lib/cdc/core/observer.rb', line 77 def dispatch_failed(_result); end |
#dispatch_skipped(_result) ⇒ void
This method returns an undefined value.
Called when a work item is filtered or skipped.
83 |
# File 'lib/cdc/core/observer.rb', line 83 def dispatch_skipped(_result); end |
#dispatch_started(_event) ⇒ void
This method returns an undefined value.
Called before a work item is dispatched.
65 |
# File 'lib/cdc/core/observer.rb', line 65 def dispatch_started(_event); end |
#dispatch_succeeded(_result) ⇒ void
This method returns an undefined value.
Called after a work item is processed successfully.
71 |
# File 'lib/cdc/core/observer.rb', line 71 def dispatch_succeeded(_result); end |