Class: Datadog::DI::GuardrailsTelemetry Private
- Inherits:
-
Object
- Object
- Datadog::DI::GuardrailsTelemetry
- Defined in:
- lib/datadog/di/guardrails_telemetry.rb,
lib/datadog/di/guardrails_telemetry/reason.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Telemetry reporter for the DI guardrails: the reason codes and the metric emitters.
Defined Under Namespace
Modules: Reason
Constant Summary collapse
- EVENTS_SKIPPED =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Skip count metric name, emitted under
DI::TELEMETRY_NAMESPACE. "events.skipped"- EVENTS_DROPPED =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Drop count metric name, emitted under
DI::TELEMETRY_NAMESPACE. "events.dropped"- CAPTURE_INCOMPLETE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Incomplete-capture count metric name, emitted under
DI::TELEMETRY_NAMESPACE. "capture.incomplete"- QUEUE_DROPPED_BYTES =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Queue byte-count metric, emitted under
DI::TELEMETRY_NAMESPACE. "guardrails.queue.dropped_bytes"- EVENT_TYPE_SNAPSHOT =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Tag value for probes that capture a full snapshot.
"snapshot"- EVENT_TYPE_LOG =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Tag value for probes that capture evaluated log output.
"log"
Instance Attribute Summary collapse
-
#capture_incomplete_tags_memo ⇒ Hash{String => Hash{String => Hash{Symbol => String}}}
readonly
private
The memo of frozen tag hashes for emitted incomplete-capture metrics, keyed by reason and event type.
-
#dropped_tags_memo ⇒ Hash{String => Hash{String => Hash{Symbol => String}}}
readonly
private
The memo of frozen tag hashes for emitted drop metrics, keyed by reason and event type.
-
#logger ⇒ DI::Logger
readonly
private
The logger.
-
#settings ⇒ Datadog::Core::Configuration::Settings
readonly
private
The tracer settings.
-
#skipped_tags_memo ⇒ Hash{String => Hash{String => Hash{Symbol => String}}}
readonly
private
The memo of frozen tag hashes for emitted skip metrics without
probe_id, keyed by reason and event type. -
#telemetry ⇒ Datadog::Core::Telemetry::Component?
readonly
private
The component the guardrails metrics are emitted through.
Class Method Summary collapse
-
.probe_event_type_tag(probe) ⇒ String
private
Returns the canonical event_type tag for a probe, derived from whether the probe captures a full snapshot.
Instance Method Summary collapse
-
#capture_incomplete(reason:, event_type:) ⇒ void
private
Emits the canonical
debugger.capture.incompletecount metric for a capture limit enforced on a snapshot that is still sent. -
#dropped(reason:, event_type:, bytes: nil) ⇒ void
private
Emits the canonical
debugger.events.droppedcount metric, and, whenbytesis provided, theguardrails.queue.dropped_bytescount metric. -
#initialize(settings:, logger:, telemetry:) ⇒ GuardrailsTelemetry
constructor
private
Initializes the reporter.
-
#skipped(reason:, probe:) ⇒ void
private
Emits the canonical
debugger.events.skippedcount metric for a probe firing a guardrail rejected.
Constructor Details
#initialize(settings:, logger:, telemetry:) ⇒ GuardrailsTelemetry
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initializes the reporter.
36 37 38 39 40 41 42 43 |
# File 'lib/datadog/di/guardrails_telemetry.rb', line 36 def initialize(settings:, logger:, telemetry:) @settings = settings @logger = logger @telemetry = telemetry @skipped_tags_memo = {} @dropped_tags_memo = {} @capture_incomplete_tags_memo = {} end |
Instance Attribute Details
#capture_incomplete_tags_memo ⇒ Hash{String => Hash{String => Hash{Symbol => String}}} (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The memo of frozen tag hashes for emitted incomplete-capture metrics, keyed by reason and event type.
65 66 67 |
# File 'lib/datadog/di/guardrails_telemetry.rb', line 65 def @capture_incomplete_tags_memo end |
#dropped_tags_memo ⇒ Hash{String => Hash{String => Hash{Symbol => String}}} (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The memo of frozen tag hashes for emitted drop metrics, keyed by reason and event type.
61 62 63 |
# File 'lib/datadog/di/guardrails_telemetry.rb', line 61 def @dropped_tags_memo end |
#logger ⇒ DI::Logger (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The logger.
50 51 52 |
# File 'lib/datadog/di/guardrails_telemetry.rb', line 50 def logger @logger end |
#settings ⇒ Datadog::Core::Configuration::Settings (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The tracer settings.
47 48 49 |
# File 'lib/datadog/di/guardrails_telemetry.rb', line 47 def settings @settings end |
#skipped_tags_memo ⇒ Hash{String => Hash{String => Hash{Symbol => String}}} (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The memo of frozen tag hashes for emitted skip metrics without
probe_id, keyed by reason and event type.
57 58 59 |
# File 'lib/datadog/di/guardrails_telemetry.rb', line 57 def @skipped_tags_memo end |
#telemetry ⇒ Datadog::Core::Telemetry::Component? (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The component the guardrails metrics are emitted through.
53 54 55 |
# File 'lib/datadog/di/guardrails_telemetry.rb', line 53 def telemetry @telemetry end |
Class Method Details
.probe_event_type_tag(probe) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the canonical event_type tag for a probe, derived from whether the probe captures a full snapshot.
72 73 74 |
# File 'lib/datadog/di/guardrails_telemetry.rb', line 72 def self.probe_event_type_tag(probe) probe.capture_snapshot? ? EVENT_TYPE_SNAPSHOT : EVENT_TYPE_LOG end |
Instance Method Details
#capture_incomplete(reason:, event_type:) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Emits the canonical debugger.capture.incomplete count metric for
a capture limit enforced on a snapshot that is still sent.
112 113 114 115 116 117 118 |
# File 'lib/datadog/di/guardrails_telemetry.rb', line 112 def capture_incomplete(reason:, event_type:) inc_metric( DI::TELEMETRY_NAMESPACE, CAPTURE_INCOMPLETE, 1, tags: (reason, event_type), ) nil end |
#dropped(reason:, event_type:, bytes: nil) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Emits the canonical debugger.events.dropped count metric, and,
when bytes is provided, the guardrails.queue.dropped_bytes count
metric.
99 100 101 102 103 104 |
# File 'lib/datadog/di/guardrails_telemetry.rb', line 99 def dropped(reason:, event_type:, bytes: nil) = (reason, event_type) inc_metric(DI::TELEMETRY_NAMESPACE, EVENTS_DROPPED, 1, tags: ) inc_metric(DI::TELEMETRY_NAMESPACE, QUEUE_DROPPED_BYTES, bytes, tags: ) if bytes nil end |
#skipped(reason:, probe:) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Emits the canonical debugger.events.skipped count metric for a
probe firing a guardrail rejected.
82 83 84 85 86 87 88 89 |
# File 'lib/datadog/di/guardrails_telemetry.rb', line 82 def skipped(reason:, probe:) probe_id = probe.id if Reason::PROBE_SCOPED_REASONS.include?(reason) inc_metric( DI::TELEMETRY_NAMESPACE, EVENTS_SKIPPED, 1, tags: (reason, self.class.probe_event_type_tag(probe), probe_id), ) nil end |