Repository: DataDog/dd-trace-rb
Pull request #4641: DEBUG-3700 Inject telemetry into metrics client
Author: login: p-datadog
Labels: name: core
description: Involves Datadog core libraries
Created: 2025-05-12T16:48:38Z | Merged: 2025-05-15T15:51:25Z

<!--
Check out the
https://github.com/DataDog/dd-trace-rb/blob/master/docs/DevelopmentGuide.md
for guidance on how to set up your development environment,
run the test suite, write new integrations, and more.
-->

**What does this PR do?**
<!-- A brief description of the change being made with this pull request. -->
Injects telemetry into metrics client instead of retrieving it from the components tree.

**Motivation:**
<!-- What inspired you to submit this pull request? -->
References to the components tree currently create the tree if it does not exist by default (`allow_initialization` option to `components`). This creation is problematic in the test suite (see https://github.com/DataDog/dd-trace-rb/pull/4619). Some components appear to rely on this automatic instantiation (profiling, possibly tracing), therefore removing it is non-trivial. In the meantime, metrics client can have telemetry injected into it to avoid the issue altogether (and remove what is effectively a global variable reference).

**Change log entry**
None
<!-- If this is a customer-visible change, a brief summary to be placed
into the change log.
If you are not a Datadog employee, you can skip this section
and it will be filled or deleted during PR review. -->

**Additional Notes:**
<!-- Anything else we should know when reviewing? -->

**How to test the change?**
<!--
Describe here how the change can be validated.
You are strongly encouraged to provide automated tests for this PR (unit or integration).
If this change cannot be feasibly tested, please explain why,
unless the change does not modify code (e.g. only modifies docs, comments).
-->
Existing CI

<!-- Unsure? Have a question? Request a review! -->



Diff:
diff --git a/lib/datadog/core/configuration/components.rb b/lib/datadog/core/configuration/components.rb
index f41ecfcba00..129bd0484f3 100644
--- a/lib/datadog/core/configuration/components.rb
+++ b/lib/datadog/core/configuration/components.rb
@@ -27,12 +27,12 @@ class Components
         class << self
           include Datadog::Tracing::Component
 
-          def build_health_metrics(settings, logger)
+          def build_health_metrics(settings, logger, telemetry)
             settings = settings.health_metrics
             options = { enabled: settings.enabled }
             options[:statsd] = settings.statsd unless settings.statsd.nil?
 
-            Core::Diagnostics::Health::Metrics.new(logger: logger, **options)
+            Core::Diagnostics::Health::Metrics.new(telemetry: telemetry, logger: logger, **options)
           end
 
           def build_logger(settings)
@@ -42,24 +42,24 @@ def build_logger(settings)
             logger
           end
 
-          def build_runtime_metrics(settings, logger)
+          def build_runtime_metrics(settings, logger, telemetry)
             options = { enabled: settings.runtime_metrics.enabled }
             options[:statsd] = settings.runtime_metrics.statsd unless settings.runtime_metrics.statsd.nil?
             options[:services] = [settings.service] unless settings.service.nil?
             options[:experimental_runtime_id_enabled] = settings.runtime_metrics.experimental_runtime_id_enabled
 
-            Core::Runtime::Metrics.new(logger: logger, **options)
+            Core::Runtime::Metrics.new(logger: logger, telemetry: telemetry, **options)
           end
 
-          def build_runtime_metrics_worker(settings, logger)
+          def build_runtime_metrics_worker(settings, logger, telemetry)
             # NOTE: Should we just ignore building the worker if its not enabled?
             options = settings.runtime_metrics.opts.merge(
               enabled: settings.runtime_metrics.enabled,
-              metrics: build_runtime_metrics(settings, logger),
+              metrics: build_runtime_metrics(settings, logger, telemetry),
               logger: logger,
             )
 
-            Core::Workers::RuntimeMetrics.new(options)
+            Core::Workers::RuntimeMetrics.new(telemetry: telemetry, **options)
           end
 
           def build_telemetry(settings, agent_settings, logger)
@@ -119,8 +119,8 @@ def initialize(settings)
           )
           @environment_logger_extra.merge!(profiler_logger_extra) if profiler_logger_extra
 
-          @runtime_metrics = self.class.build_runtime_metrics_worker(settings, @logger)
-          @health_metrics = self.class.build_health_metrics(settings, @logger)
+          @runtime_metrics = self.class.build_runtime_metrics_worker(settings, @logger, telemetry)
+          @health_metrics = self.class.build_health_metrics(settings, @logger, telemetry)
           @appsec = Datadog::AppSec::Component.build_appsec_component(settings, telemetry: telemetry)
           @dynamic_instrumentation = Datadog::DI::Component.build(settings, agent_settings, @logger, telemetry: telemetry)
           @environment_logger_extra[:dynamic_instrumentation_enabled] = !!@dynamic_instrumentation
diff --git a/lib/datadog/core/metrics/client.rb b/lib/datadog/core/metrics/client.rb
index d588fea7512..6f0eab19236 100644
--- a/lib/datadog/core/metrics/client.rb
+++ b/lib/datadog/core/metrics/client.rb
@@ -21,9 +21,10 @@ class Client
         extend Options
         extend Helpers
 
-        attr_reader :statsd, :logger
+        attr_reader :statsd, :logger, :telemetry
 
-        def initialize(logger: Datadog.logger, statsd: nil, enabled: true, **_)
+        def initialize(telemetry:, logger: Datadog.logger, statsd: nil, enabled: true, **_)
+          @telemetry = telemetry
           @logger = logger
           @statsd =
             if supported?
@@ -102,7 +103,7 @@ def count(stat, value = nil, options = nil, &block)
           logger.error(
             "Failed to send count stat. Cause: #{e.class.name} #{e.message} Source: #{Array(e.backtrace).first}"
           )
-          Telemetry::Logger.report(e, description: 'Failed to send count stat')
+          telemetry.report(e, description: 'Failed to send count stat')
         end
 
         def distribution(stat, value = nil, options = nil, &block)
@@ -116,7 +117,7 @@ def distribution(stat, value = nil, options = nil, &block)
           logger.error(
             "Failed to send distribution stat. Cause: #{e.class.name} #{e.message} Source: #{Array(e.backtrace).first}"
           )
-          Telemetry::Logger.report(e, description: 'Failed to send distribution stat')
+          telemetry.report(e, description: 'Failed to send distribution stat')
         end
 
         def increment(stat, options = nil)
@@ -129,7 +130,7 @@ def increment(stat, options = nil)
           logger.error(
             "Failed to send increment stat. Cause: #{e.class.name} #{e.message} Source: #{Array(e.backtrace).first}"
           )
-          Telemetry::Logger.report(e, description: 'Failed to send increment stat')
+          telemetry.report(e, description: 'Failed to send increment stat')
         end
 
         def gauge(stat, value = nil, options = nil, &block)
@@ -143,7 +144,7 @@ def gauge(stat, value = nil, options = nil, &block)
           logger.error(
             "Failed to send gauge stat. Cause: #{e.class.name} #{e.message} Source: #{Array(e.backtrace).first}"
           )
-          Telemetry::Logger.report(e, description: 'Failed to send gauge stat')
+          telemetry.report(e, description: 'Failed to send gauge stat')
         end
 
         def time(stat, options = nil)
@@ -163,7 +164,7 @@ def time(stat, options = nil)
             logger.error(
               "Failed to send time stat. Cause: #{e.class.name} #{e.message} Source: #{Array(e.backtrace).first}"
             )
-            Telemetry::Logger.report(e, description: 'Failed to send time stat')
+            telemetry.report(e, description: 'Failed to send time stat')
           end
         end
 
diff --git a/lib/datadog/core/runtime/metrics.rb b/lib/datadog/core/runtime/metrics.rb
index 08fa4140ca0..e5a6a16fdff 100644
--- a/lib/datadog/core/runtime/metrics.rb
+++ b/lib/datadog/core/runtime/metrics.rb
@@ -14,7 +14,7 @@ module Core
     module Runtime
       # For generating runtime metrics
       class Metrics < Core::Metrics::Client
-        def initialize(**options)
+        def initialize(telemetry:, **options)
           super
 
           # Initialize service list
diff --git a/lib/datadog/core/workers/runtime_metrics.rb b/lib/datadog/core/workers/runtime_metrics.rb
index b20678410a1..e5e0d6224e8 100644
--- a/lib/datadog/core/workers/runtime_metrics.rb
+++ b/lib/datadog/core/workers/runtime_metrics.rb
@@ -20,8 +20,8 @@ class RuntimeMetrics < Worker
         attr_reader \
           :metrics
 
-        def initialize(options = {})
-          @metrics = options.fetch(:metrics) { Core::Runtime::Metrics.new(logger: options[:logger]) }
+        def initialize(telemetry:, **options)
+          @metrics = options.fetch(:metrics) { Core::Runtime::Metrics.new(logger: options[:logger], telemetry: telemetry) }
 
           # Workers::Async::Thread settings
           self.fork_policy = options.fetch(:fork_policy, Workers::Async::Thread::FORK_POLICY_STOP)
diff --git a/sig/datadog/core/metrics/client.rbs b/sig/datadog/core/metrics/client.rbs
index cbbf09dd405..04c4c631425 100644
--- a/sig/datadog/core/metrics/client.rbs
+++ b/sig/datadog/core/metrics/client.rbs
@@ -13,7 +13,7 @@ module Datadog
         attr_reader statsd: untyped
 	attr_reader logger: Core::Logger
 
-        def initialize: (?statsd: untyped?, ?enabled: bool, logger: Core::Logger, **untyped _) -> void
+        def initialize: (telemetry: Core::Telemetry::Component, ?statsd: untyped?, ?enabled: bool, logger: Core::Logger, **untyped _) -> void
 
         def supported?: () -> untyped
 
diff --git a/spec/datadog/core/configuration/components_spec.rb b/spec/datadog/core/configuration/components_spec.rb
index 247b07e4c1a..b53424d7624 100644
--- a/spec/datadog/core/configuration/components_spec.rb
+++ b/spec/datadog/core/configuration/components_spec.rb
@@ -82,11 +82,11 @@
       ).and_return([profiler, environment_logger_extra])
 
       expect(described_class).to receive(:build_runtime_metrics_worker)
-        .with(settings, logger)
+        .with(settings, logger, telemetry)
         .and_return(runtime_metrics)
 
       expect(described_class).to receive(:build_health_metrics)
-        .with(settings, logger)
+        .with(settings, logger, telemetry)
         .and_return(health_metrics)
     end
 
@@ -155,7 +155,7 @@
   end
 
   describe '::build_health_metrics' do
-    subject(:build_health_metrics) { described_class.build_health_metrics(settings, logger) }
+    subject(:build_health_metrics) { described_class.build_health_metrics(settings, logger, telemetry) }
 
     context 'given settings' do
       shared_examples_for 'new health metrics' do
@@ -165,7 +165,7 @@
 
         before do
           expect(Datadog::Core::Diagnostics::Health::Metrics).to receive(:new)
-            .with(default_options.merge(options).merge(logger: logger))
+            .with(default_options.merge(options).merge(logger: logger, telemetry: telemetry))
             .and_return(health_metrics)
         end
 
@@ -291,7 +291,7 @@
   end
 
   describe '::build_runtime_metrics' do
-    subject(:build_runtime_metrics) { described_class.build_runtime_metrics(settings, logger) }
+    subject(:build_runtime_metrics) { described_class.build_runtime_metrics(settings, logger, telemetry) }
 
     context 'given settings' do
       shared_examples_for 'new runtime metrics' do
@@ -305,7 +305,7 @@
 
         before do
           expect(Datadog::Core::Runtime::Metrics).to receive(:new)
-            .with(default_options.merge(options).merge(logger: logger))
+            .with(**default_options.merge(options).merge(logger: logger, telemetry: telemetry))
             .and_return(runtime_metrics)
         end
 
@@ -375,7 +375,7 @@
   end
 
   describe '::build_runtime_metrics_worker' do
-    subject(:build_runtime_metrics_worker) { described_class.build_runtime_metrics_worker(settings, logger) }
+    subject(:build_runtime_metrics_worker) { described_class.build_runtime_metrics_worker(settings, logger, telemetry) }
 
     context 'given settings' do
       shared_examples_for 'new runtime metrics worker' do
@@ -391,11 +391,11 @@
 
         before do
           allow(described_class).to receive(:build_runtime_metrics)
-            .with(settings, logger)
+            .with(settings, logger, telemetry)
             .and_return(runtime_metrics)
 
           expect(Datadog::Core::Workers::RuntimeMetrics).to receive(:new)
-            .with(default_options.merge(options).merge(logger: logger))
+            .with(**default_options.merge(options).merge(logger: logger, telemetry: telemetry))
             .and_return(runtime_metrics_worker)
         end
 
diff --git a/spec/datadog/core/metrics/client_spec.rb b/spec/datadog/core/metrics/client_spec.rb
index d161404f426..584cb256c32 100644
--- a/spec/datadog/core/metrics/client_spec.rb
+++ b/spec/datadog/core/metrics/client_spec.rb
@@ -7,9 +7,10 @@
   include_context 'metrics'
 
   let(:logger) { Logger.new($stderr) }
+  let(:telemetry) { double(Datadog::Core::Telemetry::Component) }
   let(:options) { { statsd: statsd } }
 
-  subject(:metrics) { described_class.new(logger: logger, **options) }
+  subject(:metrics) { described_class.new(telemetry: telemetry, logger: logger, **options) }
   after { metrics.close }
 
   it { is_expected.to have_attributes(statsd: statsd) }
@@ -19,7 +20,7 @@
       expect(logger).to receive(:error).with(
         /Failed to send #{action} stat/
       )
-      expect(Datadog::Core::Telemetry::Logger).to receive(:report).with(
+      expect(telemetry).to receive(:report).with(
         a_kind_of(StandardError),
         description: "Failed to send #{action} stat"
       )
@@ -758,6 +759,7 @@
       context 'which raises an error' do
         before do
           expect(statsd).to receive(:distribution).and_raise(StandardError)
+          expect(telemetry).to receive(:report)
           expect(logger).to receive(:error)
         end
 
diff --git a/spec/datadog/core/metrics/logging_spec.rb b/spec/datadog/core/metrics/logging_spec.rb
index a336ddad3fe..8663992e3fa 100644
--- a/spec/datadog/core/metrics/logging_spec.rb
+++ b/spec/datadog/core/metrics/logging_spec.rb
@@ -10,6 +10,7 @@
   subject(:adapter) { described_class.new(logger) }
 
   let(:logger) { instance_double(Logger) }
+  let(:telemetry) { double(Datadog::Core::Telemetry::Component) }
 
   def have_received_json_metric(expected_hash)
     have_received(:info) do |msg|
@@ -121,7 +122,7 @@ def have_received_json_metric(expected_hash)
   end
 
   context 'when used in Datadog::Metrics' do
-    subject(:metrics) { Datadog::Core::Metrics::Client.new(statsd: adapter, logger: logger) }
+    subject(:metrics) { Datadog::Core::Metrics::Client.new(statsd: adapter, logger: logger, telemetry: telemetry) }
 
     describe 'and #count is sent' do
       subject(:count) { metrics.count(stat, value, options) }
diff --git a/spec/datadog/core/runtime/metrics_spec.rb b/spec/datadog/core/runtime/metrics_spec.rb
index 6f65fc6f91f..8e7f69eec44 100644
--- a/spec/datadog/core/runtime/metrics_spec.rb
+++ b/spec/datadog/core/runtime/metrics_spec.rb
@@ -5,8 +5,9 @@
 
 RSpec.describe Datadog::Core::Runtime::Metrics do
   let(:logger) { logger_allowing_debug }
+  let(:telemetry) { double(Datadog::Core::Telemetry::Component) }
   let(:options) { {} }
-  subject(:runtime_metrics) { described_class.new(logger: logger, **options) }
+  subject(:runtime_metrics) { described_class.new(logger: logger, telemetry: telemetry, **options) }
 
   describe '::new' do
     context 'given :services' do
diff --git a/spec/datadog/core/workers/runtime_metrics_spec.rb b/spec/datadog/core/workers/runtime_metrics_spec.rb
index 59cdb7fb759..683d750500e 100644
--- a/spec/datadog/core/workers/runtime_metrics_spec.rb
+++ b/spec/datadog/core/workers/runtime_metrics_spec.rb
@@ -4,12 +4,13 @@
 require 'datadog/core/workers/runtime_metrics'
 
 RSpec.describe Datadog::Core::Workers::RuntimeMetrics do
-  subject(:worker) { described_class.new(options) }
+  subject(:worker) { described_class.new(telemetry: telemetry, **options) }
 
   let(:metrics) { instance_double(Datadog::Core::Runtime::Metrics, close: nil) }
   let(:options) { { metrics: metrics, enabled: true } }
 
   let(:logger) { logger_allowing_debug }
+  let(:telemetry) { double(Datadog::Core::Telemetry::Component) }
 
   before { allow(metrics).to receive(:flush) }
 
@@ -19,7 +20,7 @@
     it { expect(worker).to be_a_kind_of(Datadog::Core::Workers::Polling) }
 
     context 'by default' do
-      subject(:worker) { described_class.new(logger: logger) }
+      subject(:worker) { described_class.new(logger: logger, telemetry: telemetry) }
 
       it { expect(worker.enabled?).to be false }
       it { expect(worker.loop_base_interval).to eq 10 }
diff --git a/spec/datadog/tracing/diagnostics/health_spec.rb b/spec/datadog/tracing/diagnostics/health_spec.rb
index 7794649ecf6..c73830354c7 100644
--- a/spec/datadog/tracing/diagnostics/health_spec.rb
+++ b/spec/datadog/tracing/diagnostics/health_spec.rb
@@ -7,9 +7,10 @@
   # TODO: Core::Health::Metrics directly extends Tracing::Health::Metrics
   #       In the future, have tracing add this behavior itself. For now,
   #       just use the core metrics class to drive the tests.
-  subject(:health_metrics) { Datadog::Core::Diagnostics::Health::Metrics.new(logger: logger) }
+  subject(:health_metrics) { Datadog::Core::Diagnostics::Health::Metrics.new(logger: logger, telemetry: telemetry) }
 
   let(:logger) { logger_allowing_debug }
+  let(:telemetry) { double(Datadog::Core::Telemetry::Component) }
 
   shared_examples_for 'a health metric' do |type, name, stat|
     subject(:health_metric) { health_metrics.send(name, *args, &block) }


Reviews:
user: login: Strech
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-05-13T11:11:47Z
user: login: p-datadog
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-05-13T11:43:47Z
user: login: Strech
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-05-13T12:52:09Z
user: login: p-datadog
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-05-14T14:23:34Z
user: login: Strech
state: APPROVED
author_association: MEMBER
submitted_at: 2025-05-15T07:55:08Z

Review comments:
diff_hunk: @@ -21,9 +21,10 @@ class Client
         extend Options
         extend Helpers
 
-        attr_reader :statsd, :logger
+        attr_reader :statsd, :logger, :telemetry
 
-        def initialize(logger: Datadog.logger, statsd: nil, enabled: true, **_)
+        def initialize(telemetry: nil, logger: Datadog.logger, statsd: nil, enabled: true, **_)
path: lib/datadog/core/metrics/client.rb
user: login: Strech
body: I think I have just one question, will it be ever that telemetry is `nil` because not provided? Can we enforce its presence instead of safe-navigation?
created_at: 2025-05-13T11:11:47Z
author_association: MEMBER
diff_hunk: @@ -21,9 +21,10 @@ class Client
         extend Options
         extend Helpers
 
-        attr_reader :statsd, :logger
+        attr_reader :statsd, :logger, :telemetry
 
-        def initialize(logger: Datadog.logger, statsd: nil, enabled: true, **_)
+        def initialize(telemetry: nil, logger: Datadog.logger, statsd: nil, enabled: true, **_)
path: lib/datadog/core/metrics/client.rb
user: login: p-datadog
body: When I implemented DI I treated telemetry as being optional but the rest of the tracer seems to assume it always exists.

However, telemetry can also be turned off, and in that case presently all of the telemetry objects are still built (even sub-component ones like worker) which then check if they are enabled on each operation. I personally would prefer telemetry object to not exist at all if telemetry is disabled, which would require its usage to be conditional.

What do you think?
created_at: 2025-05-13T11:43:47Z
author_association: MEMBER
diff_hunk: @@ -21,9 +21,10 @@ class Client
         extend Options
         extend Helpers
 
-        attr_reader :statsd, :logger
+        attr_reader :statsd, :logger, :telemetry
 
-        def initialize(logger: Datadog.logger, statsd: nil, enabled: true, **_)
+        def initialize(telemetry: nil, logger: Datadog.logger, statsd: nil, enabled: true, **_)
path: lib/datadog/core/metrics/client.rb
user: login: Strech
body: What about NullObject pattern to avoid unnecessary checks?
created_at: 2025-05-13T12:52:09Z
author_association: MEMBER
diff_hunk: @@ -21,9 +21,10 @@ class Client
         extend Options
         extend Helpers
 
-        attr_reader :statsd, :logger
+        attr_reader :statsd, :logger, :telemetry
 
-        def initialize(logger: Datadog.logger, statsd: nil, enabled: true, **_)
+        def initialize(telemetry: nil, logger: Datadog.logger, statsd: nil, enabled: true, **_)
path: lib/datadog/core/metrics/client.rb
user: login: p-datadog
body: I removed the defaulting. The concern I had was if any customer was instantiating these classes.
created_at: 2025-05-14T14:23:34Z
author_association: MEMBER

PR comments:
user: login: github-actions[bot]
created_at: 2025-05-12T16:48:48Z
body: <!-- CHANGELOG_HIDDEN_MARKER -->
Thank you for updating **Change log entry** section :clap:

<sup>Visited at: 2025-05-12 19:03:24 UTC</sup>
author_association: NONE
user: login: datadog-datadog-prod-us1[bot]
created_at: 2025-05-12T16:50:13Z
body: # Datadog Summary

<b>✅&nbsp;Dependencies</b>




## Test Optimization Report

Branch report: [`components-init-metrics`](https://app.datadoghq.com/ci/test-branch/github.com%2Fdatadog%2Fdd-trace-rb/dd-trace-rb/components-init-metrics?env=ci&index=citest&_user_click_origin_=github)
Commit report: [`c7359b6`](https://app.datadoghq.com/ci/test-commit/github.com%2Fdatadog%2Fdd-trace-rb/dd-trace-rb/components-init-metrics/c7359b62cbe12ceeaef7f02f6547d85014fd0f03?env=ci&index=citest&_user_click_origin_=github)
Test service: `dd-trace-rb`

✅ 0 Failed, 21254 Passed, 1377 Skipped, 3m 46.84s Total Time





---
Was this helpful? Give us [feedback](https://dd.enterprise.slack.com/archives/C01FA7FASUR)!

author_association: CONTRIBUTOR
user: login: codecov-commenter
created_at: 2025-05-12T17:02:52Z
body: ## [Codecov](https://app.codecov.io/gh/DataDog/dd-trace-rb/pull/4641?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog) Report
Attention: Patch coverage is `97.61905%` with `1 line` in your changes missing coverage. Please review.
> Project coverage is 97.76%. Comparing base [(`df9dba8`)](https://app.codecov.io/gh/DataDog/dd-trace-rb/commit/df9dba87dc84751053b12467f70260ec74e427df?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog) to head [(`e85c6b5`)](https://app.codecov.io/gh/DataDog/dd-trace-rb/commit/e85c6b54398592117d6c08ef1ffef36e6fc0a02f?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog).
> Report is 4 commits behind head on master.

| [Files with missing lines](https://app.codecov.io/gh/DataDog/dd-trace-rb/pull/4641?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog) | Patch % | Lines |
|---|---|---|
| [lib/datadog/core/metrics/client.rb](https://app.codecov.io/gh/DataDog/dd-trace-rb/pull/4641?src=pr&el=tree&filepath=lib%2Fdatadog%2Fcore%2Fmetrics%2Fclient.rb&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog#diff-bGliL2RhdGFkb2cvY29yZS9tZXRyaWNzL2NsaWVudC5yYg==) | 87.50% | [1 Missing :warning: ](https://app.codecov.io/gh/DataDog/dd-trace-rb/pull/4641?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog) |

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##           master    #4641      +/-   ##
==========================================
- Coverage   97.77%   97.76%   -0.01%     
==========================================
  Files        1419     1422       +3     
  Lines       86624    86703      +79     
  Branches     4397     4403       +6     
==========================================
+ Hits        84697    84769      +72     
- Misses       1927     1934       +7     
```

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/DataDog/dd-trace-rb/pull/4641?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog).

<details><summary> :rocket: New features to boost your workflow: </summary>

- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
author_association: NONE
user: login: pr-commenter[bot]
created_at: 2025-05-13T12:08:19Z
body: ## Benchmarks

Benchmark execution time: 2025-05-15 15:35:48

Comparing candidate commit e85c6b54398592117d6c08ef1ffef36e6fc0a02f in PR branch `components-init-metrics` with baseline commit df9dba87dc84751053b12467f70260ec74e427df in branch `master`.

Found 0 performance improvements and 2 performance regressions! Performance is the same for 29 metrics, 2 unstable metrics.

#### scenario:line instrumentation - targeted

- 🟥 `throughput` [-11197.199op/s; -10612.677op/s] or [-6.697%; -6.348%]

#### scenario:method instrumentation

- 🟥 `throughput` [-12488.587op/s; -11843.119op/s] or [-6.947%; -6.588%]




author_association: NONE
user: login: datadog-datadog-prod-us1[bot]
created_at: 2025-05-13T22:34:04Z
body: 
## Datadog Report

Branch report: [`components-init-metrics`](https://app.datadoghq.com/ci/test-branch/github.com%2Fdatadog%2Fdd-trace-rb/dd-trace-rb/components-init-metrics?env=ci&index=citest&_user_click_origin_=github)
Commit report: [`e85c6b5`](https://app.datadoghq.com/ci/test-commit/github.com%2Fdatadog%2Fdd-trace-rb/dd-trace-rb/components-init-metrics/e85c6b54398592117d6c08ef1ffef36e6fc0a02f?env=ci&index=citest&_user_click_origin_=github)
Test service: `dd-trace-rb`

:white_check_mark: 0 Failed, 21046 Passed, 1373 Skipped, 3m 44.83s Total Time




author_association: CONTRIBUTOR