Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a DogStatsD API #2639

Merged
merged 16 commits into from
May 27, 2024
Merged

Provide a DogStatsD API #2639

merged 16 commits into from
May 27, 2024

Conversation

iamluc
Copy link
Contributor

@iamluc iamluc commented Apr 23, 2024

Description

Provide a DogStatsD API.

Related libdatadog PR => DataDog/libdatadog#399

Reviewer checklist

  • Test coverage seems ok.
  • Appropriate labels assigned.

@codecov-commenter
Copy link

codecov-commenter commented Apr 23, 2024

Codecov Report

Attention: Patch coverage is 88.02817% with 17 lines in your changes are missing coverage. Please review.

Project coverage is 77.78%. Comparing base (1aaebd8) to head (51fbd86).
Report is 1 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #2639      +/-   ##
============================================
+ Coverage     77.72%   77.78%   +0.06%     
  Complexity     2212     2212              
============================================
  Files           225      226       +1     
  Lines         26109    26250     +141     
  Branches        988      988              
============================================
+ Hits          20292    20418     +126     
- Misses         5291     5306      +15     
  Partials        526      526              
Flag Coverage Δ
appsec-extension 69.13% <ø> (ø)
tracer-extension 78.67% <88.02%> (+0.11%) ⬆️
tracer-php 80.30% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
ext/auto_flush.c 56.17% <ø> (ø)
ext/ddtrace.c 74.54% <100.00%> (+0.88%) ⬆️
ext/ddtrace.h 62.50% <ø> (ø)
ext/ddtrace_arginfo.h 100.00% <ø> (ø)
ext/sidecar.h 53.84% <0.00%> (-9.80%) ⬇️
ext/dogstatsd.c 85.71% <85.71%> (ø)
ext/sidecar.c 83.33% <82.60%> (+0.57%) ⬆️

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1aaebd8...51fbd86. Read the comment docs.

@iamluc iamluc force-pushed the lv/dogstatsd-api branch 2 times, most recently from 621a6d0 to d7fb685 Compare April 23, 2024 11:29
@pr-commenter
Copy link

pr-commenter bot commented Apr 25, 2024

Benchmarks

Benchmark execution time: 2024-05-17 08:02:17

Comparing candidate commit 51fbd86 in PR branch lv/dogstatsd-api with baseline commit 1aaebd8 in branch master.

Found 14 performance improvements and 5 performance regressions! Performance is the same for 159 metrics, 0 unstable metrics.

scenario:EmptyFileBench/benchEmptyFileBaseline

  • 🟩 execution_time [-455.369µs; -310.931µs] or [-16.175%; -11.045%]

scenario:EmptyFileBench/benchEmptyFileBaseline-opcache

  • 🟩 execution_time [-451.791µs; -269.389µs] or [-15.526%; -9.258%]

scenario:EmptyFileBench/benchEmptyFileOverhead

  • 🟩 execution_time [-498.069µs; -331.011µs] or [-13.965%; -9.281%]

scenario:EmptyFileBench/benchEmptyFileOverhead-opcache

  • 🟩 execution_time [-555.972µs; -420.328µs] or [-14.965%; -11.314%]

scenario:LaravelBench/benchLaravelBaseline

  • 🟩 execution_time [-421.136µs; -293.844µs] or [-14.220%; -9.922%]

scenario:LaravelBench/benchLaravelBaseline-opcache

  • 🟩 execution_time [-452.796µs; -282.244µs] or [-14.736%; -9.185%]

scenario:LaravelBench/benchLaravelOverhead

  • 🟩 execution_time [-559.835µs; -393.725µs] or [-14.806%; -10.413%]

scenario:LaravelBench/benchLaravelOverhead-opcache

  • 🟩 execution_time [-548.354µs; -356.406µs] or [-14.184%; -9.219%]

scenario:MessagePackSerializationBench/benchMessagePackSerialization

  • 🟥 execution_time [+4.904µs; +7.016µs] or [+3.326%; +4.758%]

scenario:MessagePackSerializationBench/benchMessagePackSerialization-opcache

  • 🟥 execution_time [+4.430µs; +6.030µs] or [+2.960%; +4.028%]

scenario:PDOBench/benchPDOBaseline

  • 🟥 execution_time [+16.761µs; +17.547µs] or [+9.593%; +10.043%]

scenario:PDOBench/benchPDOOverhead

  • 🟥 execution_time [+15.542µs; +19.010µs] or [+5.696%; +6.966%]

scenario:PDOBench/benchPDOOverheadWithDBM

  • 🟥 execution_time [+16.562µs; +18.151µs] or [+5.616%; +6.155%]

scenario:SymfonyBench/benchSymfonyBaseline

  • 🟩 execution_time [-477.949µs; -430.871µs] or [-7.579%; -6.832%]

scenario:SymfonyBench/benchSymfonyBaseline-opcache

  • 🟩 execution_time [-443.918µs; -372.242µs] or [-6.892%; -5.779%]

scenario:SymfonyBench/benchSymfonyOverhead

  • 🟩 execution_time [-862.491µs; -786.849µs] or [-10.979%; -10.016%]

scenario:SymfonyBench/benchSymfonyOverhead-opcache

  • 🟩 execution_time [-890.436µs; -838.324µs] or [-11.149%; -10.497%]

scenario:WordPressBench/benchWordPressOverhead

  • 🟩 execution_time [-9.024ms; -7.319ms] or [-4.119%; -3.341%]

scenario:WordPressBench/benchWordPressOverhead-opcache

  • 🟩 execution_time [-9.048ms; -7.530ms] or [-4.162%; -3.463%]

@morrisonlevi
Copy link
Collaborator

FYI there is a tiny dogstatsd client that should probably be cleaned up or deleted at src/dogstatsd.

@iamluc iamluc force-pushed the lv/dogstatsd-api branch 4 times, most recently from 8a45adc to ea7b71d Compare April 30, 2024 09:47
@iamluc iamluc marked this pull request as ready for review April 30, 2024 15:00
@iamluc iamluc requested review from a team as code owners April 30, 2024 15:00
@iamluc iamluc force-pushed the lv/dogstatsd-api branch 3 times, most recently from 757138f to 051fc5d Compare May 13, 2024 11:53
@iamluc iamluc mentioned this pull request May 22, 2024
2 tasks
Comment on lines +26 to 38
ddog_Endpoint *dogstatsd_endpoint;
if (get_global_DD_TRACE_AGENTLESS() && ZSTR_LEN(get_global_DD_API_KEY())) {
ddtrace_endpoint = ddog_endpoint_from_api_key(dd_zend_string_to_CharSlice(get_global_DD_API_KEY()));
dogstatsd_endpoint = ddog_endpoint_from_api_key(dd_zend_string_to_CharSlice(get_global_DD_API_KEY()));;
} else {
char *agent_url = ddtrace_agent_url();
ddtrace_endpoint = ddog_endpoint_from_url((ddog_CharSlice) {.ptr = agent_url, .len = strlen(agent_url)});
free(agent_url);

char *dogstatsd_url = ddtrace_dogstatsd_url();
dogstatsd_endpoint = ddog_endpoint_from_url((ddog_CharSlice) {.ptr = dogstatsd_url, .len = strlen(dogstatsd_url)});
free(dogstatsd_url);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Here, and this also applies to ddtrace_endpoint, I believe we don't respect the value of DD_SITE. Most specifically, I think that ddog_endpoint_from_api_key doesn't take this env var into consideration.

Maybe ddog_endpoint_from_api_key_and_site should be used? Maybe a new function needs to be created for ddog_endpoint_from_url?

Correct me if I'm wrong

Copy link
Collaborator

Choose a reason for hiding this comment

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

That's correct, however we don't even read that config at all currently. We should support it for sure when we add official agentless support.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hummmm, I'm thinking of multiple things atm:

  • For instance, when using Docker, customers will typically only set DD_SITE on the datadog-agent container, not necessarily the instrumented container --> The tracer doesn't know the value of DD_SITE. Is there any communication of this value between the agent and the tracers (not to my knowledge)
  • (Still using the Docker example) To use the DogStatsD API, does a customer MUST set DD_API_KEY in the instrumented container?
  • If a European customer wants to use the DogStatsD API, then I believe this... wouldn't work, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

Nevermind, quickly tested and it seems to work 🤔

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not following - the dogstatsd data still goes to the agent - and then agent will then send it to the correct site.

Copy link
Collaborator

@bwoebi bwoebi left a comment

Choose a reason for hiding this comment

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

Looks good to me, excellent work :-)

@bwoebi bwoebi merged commit f246102 into master May 27, 2024
601 of 606 checks passed
@bwoebi bwoebi deleted the lv/dogstatsd-api branch May 27, 2024 12:39
@bwoebi bwoebi added this to the 1.0.0 milestone May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants