Commit 7867680
Migrate trace-mini-agent from libdatadog to serverless-components as trace-agent (#6)
* Serverless Trace Mini Agent (#124)
* Mini Agent: add trace normalization, root span calculation, logging (#130)
* Mini Agent: Modify flushing logic, Serverless root span tags (#133)
* Mini Agent: Trace stats (#139)
* Mini Agent: Verify GCP Env (#142)
* Fix env_verifier + protobuf gitlab build issues (#148)
* Mini Agent: Support DD_SITE (#149)
* Mini Agent: Support env var set custom trace & trace stats intake urls (#172)
* Mini Agent: Verify azure function env w/ filesystem (#174)
* support dotnet (#177)
* Mini Agent: Integrate tag replacement (#195)
* Implement sending via sidecar (#192)
* Implemented tracing and agent sampling in sidecar
* Address CR feedback
Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com>
* Polyfill memfd on old glibc targets
Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com>
* Small nit from CR applied
Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com>
---------
Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com>
* Refactor common unit test create_test_span function into trace-utils (#226)
* Http url string obfuscation (#228)
* Run Miri everywhere (#269)
* Explicitly mark all tests where MIRI doesn't run
* Update the github action to run miri on the entire library
* Reformat License and add SPDX headers
* Add comment wrapping and lenghts to rustfmt
* Make verify timeout test in datadog-trace-mini-agent trigger timeout
* 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).
* Add descriptions to cargo.toml files, mainly to help discover the repo
* Collect some trace_api.* metrics in the trace flusher
* Refactor trace_utils.rs into smaller units.
* adds azure app service tags to serverless mini agent traces for azure functions
* refactor logic for setting azure span tags in serverless mini agent
* apply formatting
* add mini agent version to config
* fix unit test
* apply formatting
* Add 'src_library' tag to metrics collect in the sidecar.
* bump serverless mini agent version to 0.4.0
* move trace_util test helpers behind a feature flag (#461)
Put trace_test_utils behind a test-utils feature flag
To reduce the possibility of test helper functions being used in
non-test code. Also, move create_send_data and poll_for_mock_hit
functions into trace_test_utils. And update third party license file for test-utils feature in trace-utils crate
* Skip normalization & obfuscation and coalesce instead (#475)
* Skip normalization & obfuscation and coalesce instead
Turns out the agent ignores the root_span_tags for v0.7 anyway.
This is useful to coalesce chunks with common data, allowing us to actually save us from doing redundant requests.
As it was currently, the agentful trace sender always sent one trace per request, instead of merging them.
We also skip normalization and rely on the agent to do it, for sake of consistency with other tracers and reduce the potentially duplicated work across tracer and agent. We may change that back in future, but for now we've determined it to be the easiest way to work, also with respect to normalization-unaware testing.
Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com>
* Update trace-utils/src/trace_utils.rs
Co-authored-by: Pierre Bonet <pierotibou@gmail.com>
* Update trace-utils/src/trace_utils.rs
Co-authored-by: Pierre Bonet <pierotibou@gmail.com>
* Update trace-mini-agent/src/trace_processor.rs
Co-authored-by: Pierre Bonet <pierotibou@gmail.com>
* Add comment back
Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com>
---------
Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com>
Co-authored-by: Pierre Bonet <pierotibou@gmail.com>
* bump version of datadog-trace-mini-agent to 0.4.2 (#502)
* Add support for sending v0.4 traces. (#491)
* Add enum to hold v04 and v07 traces.
* Modify collect_trace_chunks to handle both types.
* Refactor SendData to be able to send both formats.
* Change trace exporter, mini-agent and sidecar to handle TracerPayloadCollection type.
* Support v0.5 trace endpoint (#505)
* feat: add Lambda
* feat: env verifier
* feat: set origin tag correctly
* debug: what is v5 sending us
* revert
* feat: v0.5 trace decompression support
* fix: remove comment and unwraps
* feat: remove erroneous GCP comment from my copypasta
* fix: complex type, license for rmpv
* feat: Rename methods to use v05. Add v05 string method. Temp debugging log to figure out json string encoding stuff
* wip: more debugging
* fix: use into_str instead of to_string to avoid string escaping
* feat: clean up match
* feat: Rename last method to get_v05 nomenclature
* Enable all benchmarks
* bump versions of datadog-serverless-trace-mini-agent and datadog-trace-mini-agent to 0.5.0 (#528)
* ekump/APMSP-1279 benchmark trace exporting (#531)
* Extract logic to build TracerPayloadCollection from sidecar into TracerPayload.
This functionality to turn msgpack bytes and header tags into a
TracerPayloadCollection should live somewhere more common than the sidecar as it will need to
also be used by data-pipeline (and presumably agentless). It only supports v04 at the moment, but
should eventually support v05 and v07 in follow up PRs.
* Adding some initial benchmarks for deserializing traces from msgpack
Deserializing msgpack bytes into an internal representation is currently
inefficient. Before work starts on fixing the performance issues we want
to set some baseline benchmarks.
* Switch the chunk processing to use a trait impl instead of dyn
The TraceChunk processor that is used primarily by the mini-agent (but is also created and passed by Sidecar and data-pipeline) was previously a closure that was dynamically dispatched. This was changed to be a trait in order to remove the dynamic-ness and should improve performance and in many cases the compiler should optimize the calls to it away as it is a noop for the Sidecar and data pipeline.
Co-authored-by: Bob Weinand <bob.weinand@datadoghq.com>
---------
Co-authored-by: Bob Weinand <bob.weinand@datadoghq.com>
* Implement timeouts for both sending traces and telemetry. (#518)
* Add timeout field to Endpoint struct.
* Fix Endpoint use to handle the new timeout field.
* Implement timeouts in trace-utils and ddtelemetry.
* Add FFI call to set the timeout in the endpoint struct.
* Make Endpoint instantiation more idiomatic.
* Update profling and crashtracker API to use the new endpoint.
* Add error handling to set_timeout.
* Fixes to make clippy version 1.80 happy (#550)
* cargo clippy fix for 1.80
* make windows happy
* windows unexpected cfgs
* typo
* [Serverless Mini Agent] Add _dd.mini_agent_version tag to all spans for Azure Functions, Google Cloud Functions, and Azure Spring Apps (#548)
* add _dd.mini_agent_version to spans in all environments
* apply formatting
* [Serverless Mini Agent] Run in Azure Spring Apps (#547)
* add azure spring app environment type for serverless mini agent
* add config.statsd_port to mini agent info endpoint
* update mini agent trace endpoint status code and response body to work with java tracer
* use different environment variable to identify azure spring apps
* only update http response for success responses to traces endpoint
* address lint errors
* updates comment and formatting
* update trace-mini-agent description to include Azure Spring Apps
* fix formatting
* [SVLS-5049] It is okay to have a stats payload without stats (#567)
* [Serverless Mini Agent] Use DogStatsD in Serverless (#616)
* 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
* reduced allocation v04 span representation (#598)
Leverage tinybytes to perform zero-copy msgpack decoding of v04 spans within trace-utils for use by data-pipeline and the sidecar. This was driven by the need to reduce memory footprint of the sidecar in PHP.
---------
Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com>
Co-authored-by: Bob Weinand <bob.weinand@datadoghq.com>
* Support http-proxy for trace agent, remove proxy from dsd (#658)
* 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
* [Serverless Mini Agent] Add Span Tags for Azure Spring Apps (#672)
* add span tags for azure spring apps
* fix unit test
* feat: Prefer DD_PROXY_HTTPS over HTTPS_PROXY (#673)
* feat: Prefer DD_PROXY_HTTPS over HTTPS_PROXY
* fix: no proxy on ints
* fix: clippy thx
* Enable backports/deprecated features on hyper crate
These features will help us migrate to 1.x, as suggested in the
migration guide: https://hyper.rs/guides/1/upgrading/ .
* Fix all compatibility warnings emitted by hyper crate
* Refactor proxy handling.
* [chore] Use elapsed() if possible when calculating durations (#750)
* fix(alloc): potentially dangling temporary (#772)
* fix: potentially dangling temporary
I was trying out the Rust 2024 edition which required a new nightly.
There's now a warning for dangling_pointers_from_temporaries. This
could be a false positive but I am not certain.
* test: skip problematic miri tests on MacOS
These are all due to kqueue, example:
```
error: unsupported operation: can't call foreign function `kqueue` on OS `macos`
--> /levi.morrison/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-1.0.2/src/sys/unix/selector/kqueue.rs:76:48
|
76 | let kq = unsafe { OwnedFd::from_raw_fd(syscall!(kqueue())?) };
| ^^^^^^^^^^^^^^^^^^ can't call foreign function `kqueue` on OS `macos`
```
* test: fix env test when running locally
If the local env has this set, it fails.
* [trace-mini-agent] change logging crate (#799)
* `log` => `tracing`
* fmt
* change logs to be `debug` (#806)
info is too noisy for customers
* Add _dd.gcrfx.resource_name to serverless compatibility layer for Google Cloud Functions (#770)
* Add _dd.gcrfx.resource_name to mini agent for Google Cloud Functions
* fix lint
* fix lint
* add create_test_gcp_span
* add create_test_gcp_span
* update test_process_trace
* update tests
* simplify function
* reformat file
* reformat file
* FIX TESTS!!!!!!
* move helpers function
* move helpers function
* lint
* update code from comments
* update enrich_span_with_google_cloud_function_metadata
* lint
* update tag to remove _dd prefix
* lint
* update enrich_span_with_google_cloud_function_metadata to todo instead of return
* ekump/APMSP-1756 add trace exporter integration tests (#897)
- APMSP-1756 add initial integration tests for trace exporter
- APMSP-1779 add span deserialization and Payload collection construction to send data integration tests
- Return the offending key in the error message when decoding v04 msgpack spans and we encounter an invalid key
- Fix confusing var name in dogstatsd client from PR #890
* [trace-mini-agent] add trace aggregator (#907)
* 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 v05 support in the trace exporter (#898)
* Add v05 decoding.
* Integrate v05 decoding/encoding in the trace exporter.
* Use TraceChunkSpan as a common placeholder for v04 and v05 incoming payloads.
* Add support for V05 payloads in TracerPayloadCollection.
* Refactor send and send_deser_ser.
* Prevent invalid modes combination in the builder in order to avoid panicking.
* Improve error handling in collect_trace_chunks_function.
* Enable conversion from v04 to v05.
* Add integration tests for v05 format.
* Solve PR comments.
* ekump/APMSP-1827 add warnings for panics (#915)
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
* refactor(trace-utils): make flate2 and and hyper-proxy dependencies optionnal (#929)
# What does this PR do?
* Add a new feature "mini_agent" on trace_utils and do not use it bydefault. This is going to be used to progressively separate code used by only the mini agent from common code=
* Hide flate2 usage under the compression flag
* Hide hyper-proxy dependency under the proxy feature flag
* chore: hyper 1.x migration (#946)
# What does this PR do?
Update all direct dependencies from hyper 0.14 to hyper 1.x
The path of migration is not always obvious:
* The hyper::Client struct was dropped
* Migration: use hyper_utils::client::legacy
* hyper::Body was dropped in favor of a trait that people are free to implement
* Migration: This one is hard to fix. hyper::Body was a unifying struct over multiple behaviors (incoming and outgoing requests) (empty body, single body, streaming body)
To match the previous behaviour I implemented hyper_migration::Body, an enum abstracting over all listed uses cases.
This type is used everywhere to unify the Body types used in libdatadog
* hyper::Server was dropped in favor of a simpler, connection oriented server
* Migration: implement the accept spawn responder task loop ourselves. This is one of the things where I am the less sure we keep previous behaviour. Looking at hyper 0.14 code I don't think we are missing any part with the current migrated code in the mini-agent but without integration tests it's hard to be sure.
* Because of the migration, hyper_util::Error is less descriptive than hyper::Error, which makes migration of the TraceExporterError not easy. We try to unwrap and find the source error as much as we can to preserve the behavior, and use anyhow to store the source error
* hyper_proxy use in trace-util for the mini-agent has not migrated to hyper 1 (and is in general not maintained)
* Migration: Use `hyper-http-proxy` a fork that did the update. We could also vendor the code because it's pretty small
We're not completely free of hyper 0.14 though sadly because httpmock, a dev-dependency of the data-pipeline crate has not migrated yet to hyper 1.
* refactor: split collect_chunks into two methods (#1021)
# What does this PR do?
This refactor splits the logic in `collect_trace_chunks` between the trace exporter spans (v04 and v05) and the mini agent spans (pb::Spans).
it completely removes usage of the `TraceCollection` struct from data-pipeline, and instead introduces the `TraceChunks` enum to differentiate between v04 and v05.
Currently the way the code is structured makes replacing ByteString with the slice harder due to shared lifetime.
Furthermore, the enums encodes two different codepaths, the spanBytes and span pb which never interact with each other. So having function that handle both span bytes and pb spans is pure complexity overhead.
This refactor also removes a bunch of panics and lines of code that were here because to handle the "fake" pb spans and trace exporter spans overlap, which is practice never happens.
Lastly, this remove the TracerParams struct. Every occurence of if was creating it, and invoking `TryInto<TracerCollection>` just after on it. So replacing it by a simple function is a lot less complex for the same feature set.
# Motivation
Prepare for using `SpanSlice<'a>` instead of `SpanBytes` in the trace exporter.
* rename to trace-agent, update version, pin dependencies with libdatadog commit hash
* remove description
---------
Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com>
Co-authored-by: David Lee <thedavl2001@gmail.com>
Co-authored-by: Bob Weinand <bob.weinand@datadoghq.com>
Co-authored-by: Daniel Schwartz-Narbonne <danielsn@users.noreply.github.com>
Co-authored-by: Björn Antonsson <bjorn.antonsson@datadoghq.com>
Co-authored-by: Pierre Bonet <pierre.bonet@datadoghq.com>
Co-authored-by: Luc Vieillescazes <luc.vieillescazes@datadoghq.com>
Co-authored-by: Julio Gonzalez <julio.gonzalez@datadoghq.com>
Co-authored-by: Edmund Kump <edmund.kump@datadoghq.com>
Co-authored-by: Pierre Bonet <pierotibou@gmail.com>
Co-authored-by: Julio Gonzalez <107922352+hoolioh@users.noreply.github.com>
Co-authored-by: AJ Stuyvenberg <astuyve@gmail.com>
Co-authored-by: Taegyun Kim <taegyun.kim@datadoghq.com>
Co-authored-by: Aleksandr Pasechnik <aleksandr.pasechnik@datadoghq.com>
Co-authored-by: Ivo Anjo <ivo.anjo@datadoghq.com>
Co-authored-by: Levi Morrison <levi.morrison@datadoghq.com>
Co-authored-by: jordan gonzález <30836115+duncanista@users.noreply.github.com>
Co-authored-by: Nina Rei <31524679+nina9753@users.noreply.github.com>
Co-authored-by: paullegranddc <82819397+paullegranddc@users.noreply.github.com>1 parent 1be056e commit 7867680
File tree
12 files changed
+4369
-96
lines changed- crates/trace-agent
- src
12 files changed
+4369
-96
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
0 commit comments