From 40c190cf4a4253fc53e37a7d4b084f2684c04cbb Mon Sep 17 00:00:00 2001 From: Andrey Marchenko Date: Mon, 24 Jun 2024 14:54:31 +0200 Subject: [PATCH] add distributions event --- lib/datadog/core/telemetry/event.rb | 7 +++++++ sig/datadog/core/telemetry/event.rbs | 3 +++ spec/datadog/core/telemetry/event_spec.rb | 18 ++++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/lib/datadog/core/telemetry/event.rb b/lib/datadog/core/telemetry/event.rb index e04aaf0cc08..60a9886eb1e 100644 --- a/lib/datadog/core/telemetry/event.rb +++ b/lib/datadog/core/telemetry/event.rb @@ -306,6 +306,13 @@ def payload(_) } end end + + # Telemetry class for the 'distributions' event + class Distributions < GenerateMetrics + def type + 'distributions' + end + end end end end diff --git a/sig/datadog/core/telemetry/event.rbs b/sig/datadog/core/telemetry/event.rbs index ac432ef0488..61b2e34588d 100644 --- a/sig/datadog/core/telemetry/event.rbs +++ b/sig/datadog/core/telemetry/event.rbs @@ -62,6 +62,9 @@ module Datadog def initialize: (String namespace, Enumerable[Hash[Symbol, untyped]] metric_series) -> void end + + class Distributions < GenerateMetrics + end end end end diff --git a/spec/datadog/core/telemetry/event_spec.rb b/spec/datadog/core/telemetry/event_spec.rb index 798d1e91e73..50ae1265539 100644 --- a/spec/datadog/core/telemetry/event_spec.rb +++ b/spec/datadog/core/telemetry/event_spec.rb @@ -225,4 +225,22 @@ def contain_configuration(*array) ) end end + + context 'Distributions' do + let(:event) { described_class::Distributions.new(namespace, metric_series) } + + let(:namespace) { 'general' } + let(:metric_name) { 'request_duration' } + let(:points) { [13, 14, 15, 16] } + let(:metric_series) { [{ metric: metric_name, points: points }] } + + it do + is_expected.to eq( + { + namespace: namespace, + series: metric_series + } + ) + end + end end