Skip to content

Conversation

@duncanpharvey
Copy link
Collaborator

@duncanpharvey duncanpharvey commented Apr 16, 2025

What does this PR do?

Migrate datadog-serverless-trace-mini-agent crate from libdatadog to this repo.

Motivation

Develop binary crates used solely by Serverless independently from libdatadog.

https://datadoghq.atlassian.net/browse/SVLS-6543

Additional Notes

  • Renamed from datadog-serverless-trace-mini-agent to serverless-compat
    • Binary is named datadog-serverless-compat to make it clear when the process is running that it is a Datadog process
  • Added release profile
  • Remove version
  • Use local dependencies for dogstatsd and trace-agent and libdatadog commit hashes for dependencies in libdatadog

Commands to migrate crate along with commit history from libdatadog.

cd libdatadog
git subtree split -P serverless -b duncan-harvey/split-datadog-serverless-trace-mini-agent
git checkout duncan-harvey/split-datadog-serverless-trace-mini-agent
git push

cd serverless-components
git checkout -b duncan-harvey/datadog-serverless-trace-mini-agent
git subtree add -P crates/datadog-serverless-trace-mini-agent git@github.com:DataDog/libdatadog.git duncan-harvey/split-datadog-serverless-trace-mini-agent
git push

Describe how to test/QA your changes

For testing Azure Functions I built the datadog-serverless-compat binaries from this repo, deployed them to Azure, and confirmed both custom and runtime metrics are sent to Datadog successfully.

Also confirmed that binary size is roughly the same between build in libdatadog vs. build in serverless-components.

thedavl and others added 30 commits April 4, 2023 16:08
* Only setting the timeout to 0 ms is not enough, and there was a race
  in the test between the dns lookup and the timeout that intermittently
  failed the test (most likely on Windows).
…or Azure Functions, Google Cloud Functions, and Azure Spring Apps (#548)

* add _dd.mini_agent_version to spans in all environments

* apply formatting
* use dogstatsd in serverless

* convert env var value to lowercase and nest dogstatsd logic

* refactor to move loop outside of conditional dogstatsd block

* add environment variables for hardcoded values and refactor start_dogstatsd

* fix unit test

* add env var for default dogstatsd port
* feat: Support DD_HTTP_PROXY and DD_HTTPS_PROXY

* fix: fmt

* feat: honor dd_proxy
* feat: upstream dogstatsd from datadog lambda extension

* add: stand alone dogstatsd binary as example

* fix: imports

* fix: make test utils public

* fix: more test utils public

* fix: make entry public

* fix: clippy

* fix: make test config public

* Revert "fix: make test config public"

This reverts commit 7dc979979d85c665767906030f91253725850f30.

* fix: make fields public for tests and assertions

* refactor: remove unused error

* refactor: do one step parsing

* fix: duplicate dependencies from conflicts

* refactor: use type for sorted tags and ustr

* fix: statsd parsing and tests

* format: format and clippy
test: fix test format with # for tags. It also changed the byte wise
test expected result

* fix: use only minimum regexp

* fix: increase to 10k context size, lost in refactors/moving

* refactor: update license

* fix: remove custom toolchain

* style: fix comment too long not picked up by rustfmt

* fix: restore previous cargo.lock

* fix: missing error dep

* fix: use empty tags

* fix: update license

* fix: nightly rustc 1.83 format

* fix: clippy

* fix: do not use a map, support duplicate tag values

---------

Co-authored-by: Taegyun Kim <taegyun.kim@datadoghq.com>
* feat: support HTTPS_PROXY for traces

* fix: https_proxy only.

* fix: maybe native-tls works in lambda?

* feat: try rust-tls

* fix: rusttls oops

* fix: reee it's rustls why

* fix: default-features must be false

* WIP: debug log, will revert

* fix: reqwest honors system proxies, hyper doesn't seem to. Only proxy https traffic

* fix: revert hyper-proxy, just use system proxy

* fix: revert proxy, use system

* fix: revert hyper-proxy, use system proxy

* fix: revert senddata proxy change from tests

* Revert "fix: revert senddata proxy change from tests"

This reverts commit 105000853f86dd46c39914434907452d9ca05b60.

* Revert "fix: revert hyper-proxy, use system proxy"

This reverts commit d9ebdc7e3cd68f046a4e8d981ac0564b34458983.

* Revert "fix: revert proxy, use system"

This reverts commit e4a8e18c14b56f8b889aec23b40cf3ccaf511639.

* Revert "fix: revert hyper-proxy, just use system proxy"

This reverts commit f8ed3005f75bdb3a4a4fb35dc52f499206b8d2b9.

* fix: re-commit tests

* fix: fmt

* feat: license

* feat: Wrap proxy in feature flag

* fix: fmt

* fix: not sure why the arg is needed in create_send_data

* fix: no api changes for public interfaces

* fix: None

* fix: allow unused

* fix: None for update_send_results_example

* fix: remove unused error import
* feat: Prefer DD_PROXY_HTTPS over HTTPS_PROXY

* fix: no proxy on ints

* fix: clippy thx
* show dogstatsd logs in serverless mini agent

* increase buffer size to 8192 bytes

* update metric pattern to exclude service checks and to account for container ids

* exclude events from being parsed

* add comment for 8KB max buffer size matching default value in Go Agent

* lazily initialize static regex for dogstatsd metrics

* minor refactors

* add unit tests

* remove explicit drops
* add fixed timeout to verify behavior

* add number of series and distro to flush

* tmp: add info on trace retries

* add more tmp debug log

* fix debug log

* Revert "fix debug log"

This reverts commit 4b44bb37ec4cc658d37fbeea820d399a4e924788.

* Revert "add more tmp debug log"

This reverts commit 536917b8c2f990365058c90a580937ee5e5f1894.

* Revert "tmp: add info on trace retries"

This reverts commit 5e4790794decea0f3f7e1ab523a9ab36e39820db.

* add timeout for client

* add todo

* fmt

* add constant for timeout duration

---------

Co-authored-by: jordan gonzález <30836115+duncanista@users.noreply.github.com>

Co-authored-by: jordan gonzález <30836115+duncanista@users.noreply.github.com>
* add _dd.serverless_compat_version span tag

* remove _dd.mini_agent_version tag from spans
duncanista and others added 11 commits March 6, 2025 02:55
* add `aggregator.rs`

adds an aggregator which gives batches limited by intake payload size

* update `TraceFlusher` to use the `TraceAggregator`

* make `MiniAgent` use `TraceAggregator` on `TraceFlusher`

* fmt + clippy

* add license
Add clippy warnings and allows for panic macros to most crates

Add an extension crate for mutex in ddcommon to isolate the unwrap to one location in code to avoid the allow annotations. We aren't going to stop unwrapping mutexes anytime soon. 

Replace use of lazy_static with OnceLock for ddcommon, ddtelemetry, live-debugger, tools, sidecar
(serverless) feature: Push retry strategy to libdatadog to avoid re-compressing
* remove serverless specific dogstatsd server implementation

* remove dogstatsd version from dependency
* add origin tag to metrics emitted from mini agent

* add dd.origin tag to metrics emitted from mini agent
…e95d31581e142bd98079ee38378ca39dd3'

git-subtree-dir: crates/datadog-serverless-trace-mini-agent
git-subtree-mainline: 7867680
git-subtree-split: edba93e
@duncanpharvey duncanpharvey force-pushed the duncan-harvey/datadog-serverless-trace-mini-agent branch from 17720e2 to b889a4f Compare April 18, 2025 19:09
@duncanpharvey duncanpharvey marked this pull request as ready for review April 18, 2025 19:25
@@ -0,0 +1,21 @@
[package]
name = "datadog-serverless-compat"
version = "0.1.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

A description of what is this would be nice tho

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done!

description = "Binary to run trace-agent and dogstatsd servers in Serverless environments"

@duncanpharvey duncanpharvey merged commit 93ab35e into main Apr 21, 2025
18 checks passed
@duncanpharvey duncanpharvey deleted the duncan-harvey/datadog-serverless-trace-mini-agent branch April 21, 2025 19:52
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.

10 participants