Skip to content

DEBUG-3700 Replace telemetry transport with a core-based transport that supports UDS#4630

Merged
p-datadog merged 55 commits into
masterfrom
telemetry-transport-2
May 13, 2025
Merged

DEBUG-3700 Replace telemetry transport with a core-based transport that supports UDS#4630
p-datadog merged 55 commits into
masterfrom
telemetry-transport-2

Conversation

@p-datadog

@p-datadog p-datadog commented May 7, 2025

Copy link
Copy Markdown
Member

What does this PR do?

Replaces telemetry's simple transport by the proper "enterprise" transport that implements Unix domain sockets besides HTTP.

Motivation:

Shopist requires usage of UDS for everything.

We also had support escalations asking for UDS support in telemetry.

Change log entry
None

Additional Notes:
I used DI transport as a starting point. There is a fair amount of boilerplate in transport code (still) which I hope to reduce one day in the future.

Telemetry initialization logic that was in Component.build was moved to Component#initialize to centralize processing.

http_transport attributes within telemetry were renamed to transport for consistency with other transports and because UDS is now supported.

Telemetry worker will now not be created at all if telemetry is disabled. This was the easiest route to get some of the tests passing and I believe this is the correct behavior.

I feel like the agent_settings should be a cached attribute of settings rather than having consumers deal with AgentSettingsResolver (again maybe in the bright future).

How to test the change?

Existing CI including integration tests added in #4588 that verify payloads.

Integration tests were expanded to add a UDS configuration.

@github-actions github-actions Bot added core Involves Datadog core libraries tracing labels May 7, 2025
@github-actions

github-actions Bot commented May 7, 2025

Copy link
Copy Markdown

Thank you for updating Change log entry section 👏

Visited at: 2025-05-13 11:55:39 UTC

@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented May 7, 2025

Copy link
Copy Markdown
Contributor

Datadog Report

Branch report: telemetry-transport-2
Commit report: 5b467e7
Test service: dd-trace-rb

❌ 15 Failed (0 Known Flaky), 20469 Passed, 1368 Skipped, 3m 34.93s Total Time

❌ Failed Tests (15)

This report shows up to 5 failed tests.

  • Datadog::Core::Telemetry::Component.build given settings with :agentless_enabled true and no api key does not enable telemetry when agentless mode requested but api key is not present - rspec - Details

    Expand for error
     #<Datadog::Core::Telemetry::Component (class)> received :new with unexpected arguments
       expected: ({:dependency_collection => true, :enabled => false, :heartbeat_interval_seconds => 60, :log_collectio...ansport => #<InstanceDouble(Datadog::Core::Telemetry::Transport::Telemetry::Transport) (anonymous)>}) (options hash)
            got: ({:agent_settings => #<Datadog::Core::Configuration::AgentSettingsResolver::AgentSettings:0x00007fc15c...e_set=#<struct Datadog::Core::Configuration::Option::Precedence::Value numeric=0, name=:default>>}>}) (keyword arguments)
     Diff:
     
     
     @@ -1,11 +1,7 @@
     -[{:dependency_collection => true,
     +[{:agent_settings =>
     +   #<Datadog::Core::Configuration::AgentSettingsResolver::AgentSettings:0x00007fc15c4164f8 @adapter=:net_http, @ssl=false, @hostname="agent", @port=9126, @uds_path=nil, @timeout_seconds=30>,
     ...
    
  • Datadog::Core::Telemetry::Component.build given settings with :agentless_enabled true is expected to receive agentless_telemetry({:agent_settings=>an instance of Datadog::Core::Configuration::AgentSettingsResolver::AgentSettings, :api_key=>"api_key", :logger=>#<InstanceDouble(Logger) (anonymous)>}) 1 time - rspec - Details

    Expand for error
     #<Datadog::Core::Telemetry::Component (class)> received :new with unexpected arguments
       expected: ({:dependency_collection=>true, :enabled=>true, :heartbeat_interval_seconds=>60, :log_collection_enabl...transport=>#<InstanceDouble(Datadog::Core::Telemetry::Transport::Telemetry::Transport) (anonymous)>}) (options hash)
            got: ({:agent_settings=>#<Datadog::Core::Configuration::AgentSettingsResolver::AgentSettings:0x00007f4c1fa7...e_set=#<struct Datadog::Core::Configuration::Option::Precedence::Value numeric=0, name=:default>>}>}) (keyword arguments)
     Diff:
     
     
     @@ -1,11 +1,7 @@
     -[{:dependency_collection=>true,
     +[{:agent_settings=>
     +   #<Datadog::Core::Configuration::AgentSettingsResolver::AgentSettings:0x00007f4c1fa7bfd0 @adapter=:net_http, @ssl=false, @hostname="agent", @port=9126, @uds_path=nil, @timeout_seconds=30>,
     ...
    
  • Datadog::Core::Telemetry::Component.build given settings with :agentless_enabled true is expected to receive agentless_telemetry({:agent_settings => an instance of Datadog::Core::Configuration::AgentSettingsResolver::AgentSettings, :api_key => "api_key", :logger => #<InstanceDouble(Logger) (anonymous)>}) 1 time - rspec - Details

    Expand for error
     #<Datadog::Core::Telemetry::Component (class)> received :new with unexpected arguments
       expected: ({:dependency_collection => true, :enabled => true, :heartbeat_interval_seconds => 60, :log_collection...ansport => #<InstanceDouble(Datadog::Core::Telemetry::Transport::Telemetry::Transport) (anonymous)>}) (options hash)
            got: ({:agent_settings => #<Datadog::Core::Configuration::AgentSettingsResolver::AgentSettings:0x00007fc15c...e_set=#<struct Datadog::Core::Configuration::Option::Precedence::Value numeric=0, name=:default>>}>}) (keyword arguments)
     Diff:
     
     
     @@ -1,11 +1,7 @@
     -[{:dependency_collection => true,
     +[{:agent_settings =>
     +   #<Datadog::Core::Configuration::AgentSettingsResolver::AgentSettings:0x00007fc15c3c6b38 @adapter=:net_http, @ssl=false, @hostname="agent", @port=9126, @uds_path=nil, @timeout_seconds=30>,
     ...
    
  • Datadog::Core::Telemetry::Component.build given settings with :enabled true - rspec - Details

    Expand for error
     The setting \`telemetry.enabled\` inside your app's \`Datadog.configure\` block expects a bool, but a \`RSpec::Mocks::Double\` was provided (#<Double "enabled">). Please update your \`configure\` block.
     
     Failure/Error: raise ArgumentError, error_msg
     
     ArgumentError:
       The setting \`telemetry.enabled\` inside your app's \`Datadog.configure\` block expects a bool, but a \`RSpec::Mocks::Double\` was provided (#<Double "enabled">). Please update your \`configure\` block. 
     ./lib/datadog/core/configuration/option.rb:238:in 'Datadog::Core::Configuration::Option#validate_type'
     ./lib/datadog/core/configuration/option.rb:273:in 'Datadog::Core::Configuration::Option#internal_set'
     ./lib/datadog/core/configuration/option.rb:90:in 'Datadog::Core::Configuration::Option#set'
     ./lib/datadog/core/configuration/options.rb:71:in 'Datadog::Core::Configuration::Options::InstanceMethods#set_option'
     ...
    
  • Datadog::Core::Telemetry::Component.build given settings with :enabled true and :unix agent adapter does not enable telemetry for unsupported non-http transport - rspec - Details

    Expand for error
     The setting \`telemetry.enabled\` inside your app's \`Datadog.configure\` block expects a bool, but a \`RSpec::Mocks::Double\` was provided (#<Double "enabled">). Please update your \`configure\` block.
     
     Failure/Error: raise ArgumentError, error_msg
     
     ArgumentError:
       The setting \`telemetry.enabled\` inside your app's \`Datadog.configure\` block expects a bool, but a \`RSpec::Mocks::Double\` was provided (#<Double "enabled">). Please update your \`configure\` block. 
     ./lib/datadog/core/configuration/option.rb:238:in 'Datadog::Core::Configuration::Option#validate_type'
     ./lib/datadog/core/configuration/option.rb:273:in 'Datadog::Core::Configuration::Option#internal_set'
     ./lib/datadog/core/configuration/option.rb:90:in 'Datadog::Core::Configuration::Option#set'
     ./lib/datadog/core/configuration/options.rb:71:in 'Datadog::Core::Configuration::Options::InstanceMethods#set_option'
     ...
    

@pr-commenter

pr-commenter Bot commented May 8, 2025

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2025-05-13 14:16:25

Comparing candidate commit 4bdab94 in PR branch telemetry-transport-2 with baseline commit 7ce8685 in branch master.

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

@p-datadog
p-datadog force-pushed the telemetry-transport-2 branch 2 times, most recently from 5b467e7 to e9b3353 Compare May 12, 2025 12:39
@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented May 12, 2025

Copy link
Copy Markdown
Contributor

Datadog Summary

✅ Dependencies

Test Optimization Report

Branch report: telemetry-transport-2
Commit report: 4e9cd75
Test service: dd-trace-rb

❌ 1 Failed (0 Known Flaky), 21144 Passed, 1374 Skipped, 3m 52.97s Total Time

❌ Failed Tests (1)

  • Datadog::Core::Telemetry::Emitter#request when event is app-started when call is not successful and debug logging is enabled logs the request correctly - rspec - Details

    Expand for error
     expected nil to match "Telemetry sent for event"
     
     Failure/Error: expect(log_message).to match('Telemetry sent for event')
       expected nil to match "Telemetry sent for event"
     ./spec/datadog/core/telemetry/emitter_spec.rb:83:in 'block (6 levels) in <top (required)>'
     ./spec/spec_helper.rb:263:in 'block (2 levels) in <top (required)>'
     ./spec/spec_helper.rb:148:in 'block (2 levels) in <top (required)>'
     /usr/local/bundle/gems/webmock-3.23.1/lib/webmock/rspec.rb:39:in 'block (2 levels) in <top (required)>'
     /usr/local/bundle/gems/rspec-wait-0.0.10/lib/rspec/wait.rb:47:in 'block (2 levels) in <top (required)>'
    

Was this helpful? Give us feedback!

@p-datadog
p-datadog force-pushed the telemetry-transport-2 branch from 22102ea to 4e9cd75 Compare May 12, 2025 17:52
@codecov-commenter

codecov-commenter commented May 12, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.50000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.76%. Comparing base (7ce8685) to head (55f4673).
⚠️ Report is 2738 commits behind head on master.

Files with missing lines Patch % Lines
spec/support/log_helpers.rb 71.42% 4 Missing ⚠️
...ib/datadog/core/telemetry/transport/http/client.rb 89.47% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4630      +/-   ##
==========================================
- Coverage   97.77%   97.76%   -0.02%     
==========================================
  Files        1415     1418       +3     
  Lines       86561    86598      +37     
  Branches     4386     4395       +9     
==========================================
+ Hits        84636    84663      +27     
- Misses       1925     1935      +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@p-datadog p-datadog changed the title Telemetry transport 2 DEBUG-3700 Replace telemetry transport with a core-based transport that supports UDS May 13, 2025
@p-datadog
p-datadog marked this pull request as ready for review May 13, 2025 11:55
@p-datadog
p-datadog requested a review from a team as a code owner May 13, 2025 11:55

@Strech Strech left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a suggestion to redo the enabled flag internals into 2 separate enabled and disabled telemetry components (or some sub-classes).

In addition I think few interfaces could be slightly changed (like other classes in this PR)

Comment thread lib/datadog/core/telemetry/component.rb Outdated
Comment thread lib/datadog/core/telemetry/emitter.rb Outdated
Comment thread lib/datadog/core/telemetry/request.rb
Comment thread lib/datadog/core/telemetry/transport/telemetry.rb Outdated

@anmarchenko anmarchenko left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no objections and agentless telemetry tests passed: great job @p-datadog

@y9v y9v left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great job!

@Strech

Strech commented May 13, 2025

Copy link
Copy Markdown
Member

Awesome 👏🏼

@p-datadog
p-datadog merged commit 03eefec into master May 13, 2025
@p-datadog
p-datadog deleted the telemetry-transport-2 branch May 13, 2025 16:16
@github-actions github-actions Bot added this to the 2.16.0 milestone May 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Involves Datadog core libraries tracing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants