diff --git a/bottlecap/Cargo.lock b/bottlecap/Cargo.lock index 2e7022912..c64786b3b 100644 --- a/bottlecap/Cargo.lock +++ b/bottlecap/Cargo.lock @@ -37,9 +37,9 @@ checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" [[package]] name = "anyhow" -version = "1.0.100" +version = "1.0.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" +checksum = "5f0e0fee31ef5ed1ba1316088939cea399010ed7731dba877ed44aeb407a75ea" [[package]] name = "ascii-canvas" @@ -238,7 +238,7 @@ checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.114", + "syn 2.0.115", ] [[package]] @@ -289,9 +289,9 @@ dependencies = [ [[package]] name = "aws-lc-sys" -version = "0.37.0" +version = "0.37.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c34dda4df7017c8db52132f0f8a2e0f8161649d15723ed63fc00c82d0f2081a" +checksum = "b092fe214090261288111db7a2b2c2118e5a7f30dc2569f1732c4069a6840549" dependencies = [ "cc", "cmake", @@ -391,7 +391,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.114", + "syn 2.0.115", ] [[package]] @@ -727,7 +727,7 @@ dependencies = [ [[package]] name = "datadog-fips" version = "0.1.0" -source = "git+https://github.com/DataDog/serverless-components?rev=18b49baba8bfef97060d7edd8b830584d0da3373#18b49baba8bfef97060d7edd8b830584d0da3373" +source = "git+https://github.com/DataDog/serverless-components?rev=2eb009a59ed07ffcaf174db1c31af413365e9bc6#2eb009a59ed07ffcaf174db1c31af413365e9bc6" dependencies = [ "reqwest", "rustls", @@ -762,9 +762,9 @@ dependencies = [ [[package]] name = "deranged" -version = "0.5.5" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ececcb659e7ba858fb4f10388c250a7252eb0a27373f1a72b8748afdd248e587" +checksum = "cc3dc5ad92c2e2d1c193bbbbdf2ea477cb81331de4f3103f267ca18368b988c4" dependencies = [ "powerfmt", ] @@ -786,7 +786,7 @@ checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" dependencies = [ "proc-macro2", "quote", - "syn 2.0.114", + "syn 2.0.115", "unicode-xid", ] @@ -830,13 +830,13 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.114", + "syn 2.0.115", ] [[package]] name = "dogstatsd" version = "0.1.0" -source = "git+https://github.com/DataDog/serverless-components?rev=18b49baba8bfef97060d7edd8b830584d0da3373#18b49baba8bfef97060d7edd8b830584d0da3373" +source = "git+https://github.com/DataDog/serverless-components?rev=2eb009a59ed07ffcaf174db1c31af413365e9bc6#2eb009a59ed07ffcaf174db1c31af413365e9bc6" dependencies = [ "datadog-fips", "datadog-protos", @@ -850,6 +850,7 @@ dependencies = [ "rustls-pemfile", "serde", "serde_json", + "socket2 0.6.2", "thiserror 1.0.69", "tokio", "tokio-util", @@ -872,9 +873,9 @@ checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" [[package]] name = "ena" -version = "0.14.3" +version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d248bdd43ce613d87415282f69b9bb99d947d290b10962dd6c56233312c2ad5" +checksum = "eabffdaee24bd1bf95c5ef7cec31260444317e72ea56c4c91750e8b7ee58d5f1" dependencies = [ "log", ] @@ -1088,7 +1089,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.114", + "syn 2.0.115", ] [[package]] @@ -1158,6 +1159,19 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "getrandom" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "139ef39800118c7683f2fd3c98c1b23c09ae076556b435f8e9064ae108aaeeec" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "wasip2", + "wasip3", +] + [[package]] name = "glob" version = "0.3.3" @@ -1463,7 +1477,7 @@ dependencies = [ "tokio", "tokio-rustls", "tower-service", - "webpki-roots 1.0.5", + "webpki-roots 1.0.6", ] [[package]] @@ -1583,6 +1597,12 @@ dependencies = [ "zerovec", ] +[[package]] +name = "id-arena" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954" + [[package]] name = "idna" version = "1.1.0" @@ -1622,6 +1642,8 @@ checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017" dependencies = [ "equivalent", "hashbrown 0.16.1", + "serde", + "serde_core", ] [[package]] @@ -1745,6 +1767,12 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" +[[package]] +name = "leb128fmt" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" + [[package]] name = "levenshtein" version = "1.0.5" @@ -1753,9 +1781,9 @@ checksum = "db13adb97ab515a3691f56e4dbab09283d0b86cb45abd991d8634a9d6f501760" [[package]] name = "libc" -version = "0.2.180" +version = "0.2.181" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcc35a38544a891a5f7c865aca548a982ccb3b8650a5b06d0fd33a10283c56fc" +checksum = "459427e2af2b9c839b132acb702a1c654d95e10f8c326bfc2ad11310e458b1c5" [[package]] name = "libdd-common" @@ -1924,7 +1952,7 @@ checksum = "3d0b95e02c851351f877147b7deea7b1afb1df71b63aa5f8270716e0c5720616" dependencies = [ "bitflags 2.10.0", "libc", - "redox_syscall 0.7.0", + "redox_syscall 0.7.1", ] [[package]] @@ -1986,9 +2014,9 @@ checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3" [[package]] name = "memchr" -version = "2.7.6" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" +checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" [[package]] name = "mime" @@ -2258,7 +2286,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.114", + "syn 2.0.115", ] [[package]] @@ -2319,7 +2347,7 @@ checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861" dependencies = [ "proc-macro2", "quote", - "syn 2.0.114", + "syn 2.0.115", ] [[package]] @@ -2402,7 +2430,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" dependencies = [ "proc-macro2", - "syn 2.0.114", + "syn 2.0.115", ] [[package]] @@ -2422,16 +2450,16 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.114", + "syn 2.0.115", "version_check", "yansi", ] [[package]] name = "proptest" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bee689443a2bd0a16ab0348b52ee43e3b2d1b1f931c8aa5c9f8de4c86fbe8c40" +checksum = "37566cb3fdacef14c0737f9546df7cfeadbfbc9fef10991038bf5015d0c80532" dependencies = [ "bit-set 0.8.0", "bit-vec 0.8.0", @@ -2482,7 +2510,7 @@ dependencies = [ "prost 0.13.5", "prost-types", "regex", - "syn 2.0.114", + "syn 2.0.115", "tempfile", ] @@ -2496,7 +2524,7 @@ dependencies = [ "itertools 0.14.0", "proc-macro2", "quote", - "syn 2.0.114", + "syn 2.0.115", ] [[package]] @@ -2509,7 +2537,7 @@ dependencies = [ "itertools 0.14.0", "proc-macro2", "quote", - "syn 2.0.114", + "syn 2.0.115", ] [[package]] @@ -2728,9 +2756,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f3fe0889e69e2ae9e41f4d6c4c0181701d00e4697b356fb1f74173a5e0ee27" +checksum = "35985aa610addc02e24fc232012c86fd11f14111180f902b67e2d5331f8ebf2b" dependencies = [ "bitflags 2.10.0", ] @@ -2814,7 +2842,7 @@ dependencies = [ "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "webpki-roots 1.0.5", + "webpki-roots 1.0.6", ] [[package]] @@ -2969,9 +2997,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.22" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a50f4cf475b65d88e057964e0e9bb1f0aa9bbb2036dc65c64596b42932536984" +checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" [[package]] name = "safemem" @@ -3041,6 +3069,12 @@ dependencies = [ "libc", ] +[[package]] +name = "semver" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2" + [[package]] name = "serde" version = "1.0.228" @@ -3099,7 +3133,7 @@ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", - "syn 2.0.114", + "syn 2.0.115", ] [[package]] @@ -3196,7 +3230,7 @@ checksum = "6f50427f258fb77356e4cd4aa0e87e2bd2c66dbcee41dc405282cae2bfc26c83" dependencies = [ "proc-macro2", "quote", - "syn 2.0.114", + "syn 2.0.115", ] [[package]] @@ -3339,9 +3373,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.114" +version = "2.0.115" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4d107df263a3013ef9b1879b0df87d706ff80f65a86ea879bd9c31f9b307c2a" +checksum = "6e614ed320ac28113fa64972c4262d5dbc89deacdfd00c34a3e4cea073243c12" dependencies = [ "proc-macro2", "quote", @@ -3365,7 +3399,7 @@ checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.114", + "syn 2.0.115", ] [[package]] @@ -3381,12 +3415,12 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.24.0" +version = "3.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "655da9c7eb6305c55742045d5a8d2037996d61d8de95806335c7c86ce0f82e9c" +checksum = "0136791f7c95b1f6dd99f9cc786b91bb81c3800b639b3478e561ddb7be95e5f1" dependencies = [ "fastrand", - "getrandom 0.3.4", + "getrandom 0.4.1", "once_cell", "rustix 1.1.3", "windows-sys 0.61.2", @@ -3429,7 +3463,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.114", + "syn 2.0.115", ] [[package]] @@ -3440,7 +3474,7 @@ checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.114", + "syn 2.0.115", ] [[package]] @@ -3561,7 +3595,7 @@ checksum = "af407857209536a95c8e56f8231ef2c2e2aff839b22e07a1ffcbc617e9db9fa5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.114", + "syn 2.0.115", ] [[package]] @@ -3656,7 +3690,7 @@ dependencies = [ "prost-build", "prost-types", "quote", - "syn 2.0.114", + "syn 2.0.115", ] [[package]] @@ -3757,7 +3791,7 @@ checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" dependencies = [ "proc-macro2", "quote", - "syn 2.0.114", + "syn 2.0.115", ] [[package]] @@ -3841,9 +3875,9 @@ checksum = "dbc4bc3a9f746d862c45cb89d705aa10f187bb96c76001afab07a0d35ce60142" [[package]] name = "unicode-ident" -version = "1.0.22" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" +checksum = "537dd038a89878be9b64dd4bd1b260315c1bb94f4d784956b81e27a088d9a09e" [[package]] name = "unicode-xid" @@ -3951,7 +3985,16 @@ version = "1.0.1+wasi-0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0562428422c63773dad2c345a1882263bbf4d65cf3f42e90921f787ef5ad58e7" dependencies = [ - "wit-bindgen", + "wit-bindgen 0.46.0", +] + +[[package]] +name = "wasip3" +version = "0.4.0+wasi-0.3.0-rc-2026-01-06" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5" +dependencies = [ + "wit-bindgen 0.51.0", ] [[package]] @@ -4000,7 +4043,7 @@ dependencies = [ "bumpalo", "proc-macro2", "quote", - "syn 2.0.114", + "syn 2.0.115", "wasm-bindgen-shared", ] @@ -4013,6 +4056,40 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "wasm-encoder" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319" +dependencies = [ + "leb128fmt", + "wasmparser", +] + +[[package]] +name = "wasm-metadata" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909" +dependencies = [ + "anyhow", + "indexmap 2.13.0", + "wasm-encoder", + "wasmparser", +] + +[[package]] +name = "wasmparser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" +dependencies = [ + "bitflags 2.10.0", + "hashbrown 0.15.5", + "indexmap 2.13.0", + "semver", +] + [[package]] name = "web-sys" version = "0.3.85" @@ -4039,14 +4116,14 @@ version = "0.26.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "521bc38abb08001b01866da9f51eb7c5d647a19260e00054a8c7fd5f9e57f7a9" dependencies = [ - "webpki-roots 1.0.5", + "webpki-roots 1.0.6", ] [[package]] name = "webpki-roots" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12bed680863276c63889429bfd6cab3b99943659923822de1c8a39c49e4d722c" +checksum = "22cfaf3c063993ff62e73cb4311efde4db1efb31ab78a3e5c457939ad5cc0bed" dependencies = [ "rustls-pki-types", ] @@ -4271,6 +4348,94 @@ version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59" +[[package]] +name = "wit-bindgen" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" +dependencies = [ + "wit-bindgen-rust-macro", +] + +[[package]] +name = "wit-bindgen-core" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc" +dependencies = [ + "anyhow", + "heck", + "wit-parser", +] + +[[package]] +name = "wit-bindgen-rust" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21" +dependencies = [ + "anyhow", + "heck", + "indexmap 2.13.0", + "prettyplease", + "syn 2.0.115", + "wasm-metadata", + "wit-bindgen-core", + "wit-component", +] + +[[package]] +name = "wit-bindgen-rust-macro" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a" +dependencies = [ + "anyhow", + "prettyplease", + "proc-macro2", + "quote", + "syn 2.0.115", + "wit-bindgen-core", + "wit-bindgen-rust", +] + +[[package]] +name = "wit-component" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2" +dependencies = [ + "anyhow", + "bitflags 2.10.0", + "indexmap 2.13.0", + "log", + "serde", + "serde_derive", + "serde_json", + "wasm-encoder", + "wasm-metadata", + "wasmparser", + "wit-parser", +] + +[[package]] +name = "wit-parser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736" +dependencies = [ + "anyhow", + "id-arena", + "indexmap 2.13.0", + "log", + "semver", + "serde", + "serde_derive", + "serde_json", + "unicode-xid", + "wasmparser", +] + [[package]] name = "writeable" version = "0.6.2" @@ -4312,28 +4477,28 @@ checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.114", + "syn 2.0.115", "synstructure", ] [[package]] name = "zerocopy" -version = "0.8.38" +version = "0.8.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57cf3aa6855b23711ee9852dfc97dfaa51c45feaba5b645d0c777414d494a961" +checksum = "db6d35d663eadb6c932438e763b262fe1a70987f9ae936e60158176d710cae4a" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.8.38" +version = "0.8.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a616990af1a287837c4fe6596ad77ef57948f787e46ce28e166facc0cc1cb75" +checksum = "4122cd3169e94605190e77839c9a40d40ed048d305bfdc146e7df40ab0f3e517" dependencies = [ "proc-macro2", "quote", - "syn 2.0.114", + "syn 2.0.115", ] [[package]] @@ -4353,7 +4518,7 @@ checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" dependencies = [ "proc-macro2", "quote", - "syn 2.0.114", + "syn 2.0.115", "synstructure", ] @@ -4393,14 +4558,14 @@ checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.114", + "syn 2.0.115", ] [[package]] name = "zmij" -version = "1.0.19" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ff05f8caa9038894637571ae6b9e29466c1f4f829d26c9b28f869a29cbe3445" +checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" [[package]] name = "zstd" diff --git a/bottlecap/Cargo.toml b/bottlecap/Cargo.toml index 5253169ef..6412ea5a9 100644 --- a/bottlecap/Cargo.toml +++ b/bottlecap/Cargo.toml @@ -71,8 +71,8 @@ libdd-trace-utils = { git = "https://github.com/DataDog/libdatadog", rev = "158b libdd-trace-normalization = { git = "https://github.com/DataDog/libdatadog", rev = "158b59471f1132e3cb36023fa3c46ccb2dd0eda1" } libdd-trace-obfuscation = { git = "https://github.com/DataDog/libdatadog", rev = "158b59471f1132e3cb36023fa3c46ccb2dd0eda1" } libdd-trace-stats = { git = "https://github.com/DataDog/libdatadog", rev = "158b59471f1132e3cb36023fa3c46ccb2dd0eda1" } -dogstatsd = { git = "https://github.com/DataDog/serverless-components", rev = "18b49baba8bfef97060d7edd8b830584d0da3373", default-features = false } -datadog-fips = { git = "https://github.com/DataDog/serverless-components", rev = "18b49baba8bfef97060d7edd8b830584d0da3373", default-features = false } +dogstatsd = { git = "https://github.com/DataDog/serverless-components", rev = "2eb009a59ed07ffcaf174db1c31af413365e9bc6", default-features = false } +datadog-fips = { git = "https://github.com/DataDog/serverless-components", rev = "2eb009a59ed07ffcaf174db1c31af413365e9bc6", default-features = false } libddwaf = { version = "1.28.1", git = "https://github.com/DataDog/libddwaf-rust", rev = "d1534a158d976bd4f747bf9fcc58e0712d2d17fc", default-features = false, features = ["serde"] } [dev-dependencies] diff --git a/bottlecap/LICENSE-3rdparty.csv b/bottlecap/LICENSE-3rdparty.csv index 85e333834..383854dff 100644 --- a/bottlecap/LICENSE-3rdparty.csv +++ b/bottlecap/LICENSE-3rdparty.csv @@ -66,6 +66,7 @@ h2,https://github.com/hyperium/h2,MIT,"Carl Lerche , Sean McA hashbrown,https://github.com/rust-lang/hashbrown,MIT OR Apache-2.0,Amanieu d'Antras headers,https://github.com/hyperium/headers,MIT,Sean McArthur headers-core,https://github.com/hyperium/headers,MIT,Sean McArthur +heck,https://github.com/withoutboats/heck,MIT OR Apache-2.0,The heck Authors hex,https://github.com/KokaKiwi/rust-hex,MIT OR Apache-2.0,KokaKiwi hmac,https://github.com/RustCrypto/MACs,MIT OR Apache-2.0,RustCrypto Developers http,https://github.com/hyperium/http,MIT OR Apache-2.0,"Alex Crichton , Carl Lerche , Sean McArthur " @@ -85,6 +86,7 @@ icu_normalizer_data,https://github.com/unicode-org/icu4x,Unicode-3.0,The ICU4X P icu_properties,https://github.com/unicode-org/icu4x,Unicode-3.0,The ICU4X Project Developers icu_properties_data,https://github.com/unicode-org/icu4x,Unicode-3.0,The ICU4X Project Developers icu_provider,https://github.com/unicode-org/icu4x,Unicode-3.0,The ICU4X Project Developers +id-arena,https://github.com/fitzgen/id-arena,MIT OR Apache-2.0,"Nick Fitzgerald , Aleksey Kladov " idna,https://github.com/servo/rust-url,MIT OR Apache-2.0,The rust-url developers idna_adapter,https://github.com/hsivonen/idna_adapter,Apache-2.0 OR MIT,The rust-url developers indexmap,https://github.com/bluss/indexmap,Apache-2.0 OR MIT,The indexmap Authors @@ -97,6 +99,7 @@ itoa,https://github.com/dtolnay/itoa,MIT OR Apache-2.0,David Tolnay js-sys,https://github.com/wasm-bindgen/wasm-bindgen/tree/master/crates/js-sys,MIT OR Apache-2.0,The wasm-bindgen Developers lazy_static,https://github.com/rust-lang-nursery/lazy-static.rs,MIT OR Apache-2.0,Marvin Löbel +leb128fmt,https://github.com/bluk/leb128fmt,MIT OR Apache-2.0,Bryant Luk libc,https://github.com/rust-lang/libc,MIT OR Apache-2.0,The Rust Project Developers libdd-common,https://github.com/DataDog/libdatadog/tree/main/datadog-common,Apache-2.0,The libdd-common Authors libdd-ddsketch,https://github.com/DataDog/libdatadog/tree/main/libdd-ddsketch,Apache-2.0,The libdd-ddsketch Authors @@ -144,6 +147,7 @@ pin-utils,https://github.com/rust-lang-nursery/pin-utils,MIT OR Apache-2.0,Josef potential_utf,https://github.com/unicode-org/icu4x,Unicode-3.0,The ICU4X Project Developers powerfmt,https://github.com/jhpratt/powerfmt,MIT OR Apache-2.0,Jacob Pratt ppv-lite86,https://github.com/cryptocorrosion/cryptocorrosion,MIT OR Apache-2.0,The CryptoCorrosion Contributors +prettyplease,https://github.com/dtolnay/prettyplease,MIT OR Apache-2.0,David Tolnay proc-macro2,https://github.com/dtolnay/proc-macro2,MIT OR Apache-2.0,"David Tolnay , Alex Crichton " proc-macro2-diagnostics,https://github.com/SergioBenitez/proc-macro2-diagnostics,MIT OR Apache-2.0,Sergio Benitez prost,https://github.com/tokio-rs/prost,Apache-2.0,"Dan Burkert , Lucio Franco , Casper Meijn , Tokio Contributors " @@ -182,6 +186,7 @@ schannel,https://github.com/steffengy/schannel-rs,MIT,"Steven Fackler , Kornel " security-framework-sys,https://github.com/kornelski/rust-security-framework,MIT OR Apache-2.0,"Steven Fackler , Kornel " +semver,https://github.com/dtolnay/semver,MIT OR Apache-2.0,David Tolnay serde,https://github.com/serde-rs/serde,MIT OR Apache-2.0,"Erick Tryzelaar , David Tolnay " serde-aux,https://github.com/iddm/serde-aux,MIT,Victor Polevoy serde-value,https://github.com/arcnmx/serde-value,MIT,arcnmx @@ -253,11 +258,15 @@ value-bag,https://github.com/sval-rs/value-bag,Apache-2.0 OR MIT,Ashley Mannix < want,https://github.com/seanmonstar/want,MIT,Sean McArthur wasi,https://github.com/bytecodealliance/wasi,Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT,The Cranelift Project Developers wasip2,https://github.com/bytecodealliance/wasi-rs,Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT,The wasip2 Authors +wasip3,https://github.com/bytecodealliance/wasi-rs,Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT,The wasip3 Authors wasm-bindgen,https://github.com/wasm-bindgen/wasm-bindgen,MIT OR Apache-2.0,The wasm-bindgen Developers wasm-bindgen-futures,https://github.com/wasm-bindgen/wasm-bindgen/tree/master/crates/futures,MIT OR Apache-2.0,The wasm-bindgen Developers wasm-bindgen-macro,https://github.com/wasm-bindgen/wasm-bindgen/tree/master/crates/macro,MIT OR Apache-2.0,The wasm-bindgen Developers wasm-bindgen-macro-support,https://github.com/wasm-bindgen/wasm-bindgen/tree/master/crates/macro-support,MIT OR Apache-2.0,The wasm-bindgen Developers wasm-bindgen-shared,https://github.com/wasm-bindgen/wasm-bindgen/tree/master/crates/shared,MIT OR Apache-2.0,The wasm-bindgen Developers +wasm-encoder,https://github.com/bytecodealliance/wasm-tools/tree/main/crates/wasm-encoder,Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT,Nick Fitzgerald +wasm-metadata,https://github.com/bytecodealliance/wasm-tools/tree/main/crates/wasm-metadata,Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT,The wasm-metadata Authors +wasmparser,https://github.com/bytecodealliance/wasm-tools/tree/main/crates/wasmparser,Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT,Yury Delendik web-sys,https://github.com/wasm-bindgen/wasm-bindgen/tree/master/crates/web-sys,MIT OR Apache-2.0,The wasm-bindgen Developers web-time,https://github.com/daxpedda/web-time,MIT OR Apache-2.0,The web-time Authors webpki-roots,https://github.com/rustls/webpki-roots,CDLA-Permissive-2.0,The webpki-roots Authors @@ -283,6 +292,11 @@ windows_x86_64_gnullvm,https://github.com/microsoft/windows-rs,MIT OR Apache-2.0 windows_x86_64_msvc,https://github.com/microsoft/windows-rs,MIT OR Apache-2.0,Microsoft windows_x86_64_msvc,https://github.com/microsoft/windows-rs,MIT OR Apache-2.0,The windows_x86_64_msvc Authors wit-bindgen,https://github.com/bytecodealliance/wit-bindgen,Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT,Alex Crichton +wit-bindgen-core,https://github.com/bytecodealliance/wit-bindgen,Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT,Alex Crichton +wit-bindgen-rust,https://github.com/bytecodealliance/wit-bindgen,Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT,Alex Crichton +wit-bindgen-rust-macro,https://github.com/bytecodealliance/wit-bindgen,Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT,Alex Crichton +wit-component,https://github.com/bytecodealliance/wasm-tools/tree/main/crates/wit-component,Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT,Peter Huene +wit-parser,https://github.com/bytecodealliance/wasm-tools/tree/main/crates/wit-parser,Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT,Alex Crichton writeable,https://github.com/unicode-org/icu4x,Unicode-3.0,The ICU4X Project Developers yansi,https://github.com/SergioBenitez/yansi,MIT OR Apache-2.0,Sergio Benitez yoke,https://github.com/unicode-org/icu4x,Unicode-3.0,Manish Goregaokar diff --git a/bottlecap/src/bin/bottlecap/main.rs b/bottlecap/src/bin/bottlecap/main.rs index 185001f20..9b9bdfe03 100644 --- a/bottlecap/src/bin/bottlecap/main.rs +++ b/bottlecap/src/bin/bottlecap/main.rs @@ -450,10 +450,8 @@ async fn extension_loop_active( // Wait for any pending flushes flushing_service.await_handles().await; // Final flush to capture any data that accumulated since the last - // spawn_non_blocking(). We pass force_stats=true since this is our - // last opportunity to send data before shutdown. - let mut locked_metrics = flushing_service.metrics_flushers().lock().await; - flushing_service.flush_blocking(true, &mut locked_metrics).await; + // spawn_non_blocking(). This is our last opportunity to send data. + flushing_service.flush_blocking_final().await; break; } } @@ -635,19 +633,13 @@ async fn extension_loop_active( } } _ = race_flush_interval.tick() => { - let mut locked_metrics = metrics_flushers.lock().await; - flushing_service - .flush_blocking(false, &mut locked_metrics) - .await; + flushing_service.flush_blocking().await; race_flush_interval.reset(); } } } // flush - let mut locked_metrics = metrics_flushers.lock().await; - flushing_service - .flush_blocking(false, &mut locked_metrics) - .await; + flushing_service.flush_blocking().await; race_flush_interval.reset(); let next_response = extension::next_event(client, &aws_config.runtime_api, &r.extension_id).await; @@ -664,10 +656,7 @@ async fn extension_loop_active( } } FlushDecision::Periodic => { - let mut locked_metrics = metrics_flushers.lock().await; - flushing_service - .flush_blocking(false, &mut locked_metrics) - .await; + flushing_service.flush_blocking().await; race_flush_interval.reset(); } _ => { @@ -695,10 +684,7 @@ async fn extension_loop_active( } _ = race_flush_interval.tick() => { if flush_control.flush_strategy == FlushStrategy::Default { - let mut locked_metrics = metrics_flushers.lock().await; - flushing_service - .flush_blocking(false, &mut locked_metrics) - .await; + flushing_service.flush_blocking().await; race_flush_interval.reset(); } } @@ -744,11 +730,8 @@ async fn extension_loop_active( &lifecycle_listener_shutdown_token, ); - // Final flush with force_stats=true since this is our last opportunity - let mut locked_metrics = metrics_flushers.lock().await; - flushing_service - .flush_blocking(true, &mut locked_metrics) - .await; + // Final flush - this is our last opportunity to send data before shutdown + flushing_service.flush_blocking_final().await; // Even though we're shutting down, we need to reset the flush interval to prevent any future flushes race_flush_interval.reset(); @@ -1178,7 +1161,7 @@ async fn start_dogstatsd( api_key_factory: Arc, config: &Arc, ) -> ( - Arc>>, + Arc>, MetricsAggregatorHandle, CancellationToken, ) { @@ -1200,17 +1183,20 @@ async fn start_dogstatsd( }); // Get flushers with aggregator handle - let flushers = Arc::new(TokioMutex::new(start_metrics_flushers( + let flushers = Arc::new(start_metrics_flushers( Arc::clone(&api_key_factory), &aggregator_handle, config, - ))); + )); // Create Dogstatsd server let dogstatsd_config = DogStatsDConfig { host: EXTENSION_HOST.to_string(), port: DOGSTATSD_PORT, metric_namespace: config.statsd_metric_namespace.clone(), + so_rcvbuf: config.dogstatsd_so_rcvbuf, + buffer_size: config.dogstatsd_buffer_size, + queue_size: config.dogstatsd_queue_size, }; let cancel_token = tokio_util::sync::CancellationToken::new(); let dogstatsd_agent = DogStatsD::new( diff --git a/bottlecap/src/config/env.rs b/bottlecap/src/config/env.rs index 0bbc199ef..59f673571 100644 --- a/bottlecap/src/config/env.rs +++ b/bottlecap/src/config/env.rs @@ -277,6 +277,24 @@ pub struct EnvConfig { #[serde(deserialize_with = "deserialize_optional_string")] pub statsd_metric_namespace: Option, + /// @env `DD_DOGSTATSD_SO_RCVBUF` + /// Size of the receive buffer for `DogStatsD` UDP packets, in bytes (`SO_RCVBUF`). + /// Increase to reduce packet loss under high-throughput metric bursts. + #[serde(deserialize_with = "deserialize_option_lossless")] + pub dogstatsd_so_rcvbuf: Option, + + /// @env `DD_DOGSTATSD_BUFFER_SIZE` + /// Maximum size of a single read from any transport (UDP or named pipe), in bytes. + /// Defaults to 8192. + #[serde(deserialize_with = "deserialize_option_lossless")] + pub dogstatsd_buffer_size: Option, + + /// @env `DD_DOGSTATSD_QUEUE_SIZE` + /// Internal queue capacity between the socket reader and metric processor. + /// Defaults to 1024. Increase if the processor can't keep up with burst traffic. + #[serde(deserialize_with = "deserialize_option_lossless")] + pub dogstatsd_queue_size: Option, + // OTLP // // - APM / Traces @@ -554,6 +572,11 @@ fn merge_config(config: &mut Config, env_config: &EnvConfig) { config.statsd_metric_namespace = parse_metric_namespace(namespace); } + // DogStatsD + merge_option!(config, env_config, dogstatsd_so_rcvbuf); + merge_option!(config, env_config, dogstatsd_buffer_size); + merge_option!(config, env_config, dogstatsd_queue_size); + // OTLP merge_option_to_value!(config, env_config, otlp_config_traces_enabled); merge_option_to_value!( @@ -830,6 +853,11 @@ mod tests { ); jail.set_env("DD_OTLP_CONFIG_LOGS_ENABLED", "true"); + // DogStatsD + jail.set_env("DD_DOGSTATSD_SO_RCVBUF", "1048576"); + jail.set_env("DD_DOGSTATSD_BUFFER_SIZE", "65507"); + jail.set_env("DD_DOGSTATSD_QUEUE_SIZE", "2048"); + // AWS Lambda jail.set_env( "DD_API_KEY_SECRET_ARN", @@ -984,6 +1012,9 @@ mod tests { otlp_config_traces_probabilistic_sampler_sampling_percentage: Some(50), otlp_config_logs_enabled: true, statsd_metric_namespace: None, + dogstatsd_so_rcvbuf: Some(1048576), + dogstatsd_buffer_size: Some(65507), + dogstatsd_queue_size: Some(2048), api_key_secret_arn: "arn:aws:secretsmanager:region:account:secret:datadog-api-key" .to_string(), kms_api_key: "test-kms-key".to_string(), @@ -1170,4 +1201,43 @@ mod tests { Ok(()) }); } + + #[test] + fn test_dogstatsd_config_from_env() { + figment::Jail::expect_with(|jail| { + jail.clear_env(); + jail.set_env("DD_DOGSTATSD_SO_RCVBUF", "1048576"); + jail.set_env("DD_DOGSTATSD_BUFFER_SIZE", "65507"); + jail.set_env("DD_DOGSTATSD_QUEUE_SIZE", "2048"); + + let mut config = Config::default(); + let env_config_source = EnvConfigSource; + env_config_source + .load(&mut config) + .expect("Failed to load config"); + + assert_eq!(config.dogstatsd_so_rcvbuf, Some(1048576)); + assert_eq!(config.dogstatsd_buffer_size, Some(65507)); + assert_eq!(config.dogstatsd_queue_size, Some(2048)); + Ok(()) + }); + } + + #[test] + fn test_dogstatsd_config_defaults_to_none() { + figment::Jail::expect_with(|jail| { + jail.clear_env(); + + let mut config = Config::default(); + let env_config_source = EnvConfigSource; + env_config_source + .load(&mut config) + .expect("Failed to load config"); + + assert_eq!(config.dogstatsd_so_rcvbuf, None); + assert_eq!(config.dogstatsd_buffer_size, None); + assert_eq!(config.dogstatsd_queue_size, None); + Ok(()) + }); + } } diff --git a/bottlecap/src/config/mod.rs b/bottlecap/src/config/mod.rs index 264816088..7ef0d40bd 100644 --- a/bottlecap/src/config/mod.rs +++ b/bottlecap/src/config/mod.rs @@ -303,6 +303,17 @@ pub struct Config { // Metrics pub metrics_config_compression_level: i32, pub statsd_metric_namespace: Option, + /// Size of the receive buffer for `DogStatsD` UDP packets, in bytes (`SO_RCVBUF`). + /// Increase to reduce packet loss under high-throughput metric bursts. + /// If None, uses the OS default. + pub dogstatsd_so_rcvbuf: Option, + /// Maximum size of a single read from any transport (UDP or named pipe), in bytes. + /// Defaults to 8192. For UDP, the client must batch metrics into packets of + /// this size for the increase to take effect. + pub dogstatsd_buffer_size: Option, + /// Internal queue capacity between the socket reader and metric processor. + /// Defaults to 1024. Increase if the processor can't keep up with burst traffic. + pub dogstatsd_queue_size: Option, // OTLP // @@ -421,6 +432,14 @@ impl Default for Config { metrics_config_compression_level: 3, statsd_metric_namespace: None, + // DogStatsD + // Defaults to None, which uses the OS default. + dogstatsd_so_rcvbuf: None, + // Defaults to 8192 internally. + dogstatsd_buffer_size: None, + // Defaults to 1024 internally. + dogstatsd_queue_size: None, + // OTLP otlp_config_traces_enabled: true, otlp_config_traces_span_name_as_resource_name: false, diff --git a/bottlecap/src/config/yaml.rs b/bottlecap/src/config/yaml.rs index dbac692b2..31278db89 100644 --- a/bottlecap/src/config/yaml.rs +++ b/bottlecap/src/config/yaml.rs @@ -93,6 +93,17 @@ pub struct YamlConfig { // Metrics pub metrics_config: MetricsConfig, + // DogStatsD + /// Size of the receive buffer for `DogStatsD` UDP packets, in bytes (`SO_RCVBUF`). + #[serde(deserialize_with = "deserialize_option_lossless")] + pub dogstatsd_so_rcvbuf: Option, + /// Maximum size of a single read from any transport (UDP or named pipe), in bytes. + #[serde(deserialize_with = "deserialize_option_lossless")] + pub dogstatsd_buffer_size: Option, + /// Internal queue capacity between the socket reader and metric processor. + #[serde(deserialize_with = "deserialize_option_lossless")] + pub dogstatsd_queue_size: Option, + // OTLP pub otlp_config: Option, @@ -477,6 +488,11 @@ fn merge_config(config: &mut Config, yaml_config: &YamlConfig) { compression_level ); + // DogStatsD + merge_option!(config, yaml_config, dogstatsd_so_rcvbuf); + merge_option!(config, yaml_config, dogstatsd_buffer_size); + merge_option!(config, yaml_config, dogstatsd_queue_size); + // APM merge_hashmap!(config, yaml_config, service_mapping); merge_string!(config, apm_dd_url, yaml_config.apm_config, apm_dd_url); @@ -814,6 +830,10 @@ trace_aws_service_representation_enabled: true metrics_config: compression_level: 3 +dogstatsd_so_rcvbuf: 1048576 +dogstatsd_buffer_size: 65507 +dogstatsd_queue_size: 2048 + # OTLP otlp_config: receiver: @@ -1009,6 +1029,9 @@ api_security_sample_delay: 60 # Seconds apm_filter_tags_regex_require: None, apm_filter_tags_regex_reject: None, statsd_metric_namespace: None, + dogstatsd_so_rcvbuf: Some(1048576), + dogstatsd_buffer_size: Some(65507), + dogstatsd_queue_size: Some(2048), }; // Assert that @@ -1017,4 +1040,51 @@ api_security_sample_delay: 60 # Seconds Ok(()) }); } + + #[test] + fn test_yaml_dogstatsd_config() { + figment::Jail::expect_with(|jail| { + jail.clear_env(); + jail.create_file( + "datadog.yaml", + r#" +dogstatsd_so_rcvbuf: 524288 +dogstatsd_buffer_size: 16384 +dogstatsd_queue_size: 512 +"#, + )?; + let mut config = Config::default(); + let yaml_config_source = YamlConfigSource { + path: Path::new("datadog.yaml").to_path_buf(), + }; + yaml_config_source + .load(&mut config) + .expect("Failed to load config"); + + assert_eq!(config.dogstatsd_so_rcvbuf, Some(524288)); + assert_eq!(config.dogstatsd_buffer_size, Some(16384)); + assert_eq!(config.dogstatsd_queue_size, Some(512)); + Ok(()) + }); + } + + #[test] + fn test_yaml_dogstatsd_config_defaults_to_none() { + figment::Jail::expect_with(|jail| { + jail.clear_env(); + jail.create_file("datadog.yaml", "")?; + let mut config = Config::default(); + let yaml_config_source = YamlConfigSource { + path: Path::new("datadog.yaml").to_path_buf(), + }; + yaml_config_source + .load(&mut config) + .expect("Failed to load config"); + + assert_eq!(config.dogstatsd_so_rcvbuf, None); + assert_eq!(config.dogstatsd_buffer_size, None); + assert_eq!(config.dogstatsd_queue_size, None); + Ok(()) + }); + } } diff --git a/bottlecap/src/flushing/service.rs b/bottlecap/src/flushing/service.rs index 046f65649..973a72cfc 100644 --- a/bottlecap/src/flushing/service.rs +++ b/bottlecap/src/flushing/service.rs @@ -2,7 +2,6 @@ use std::sync::Arc; -use tokio::sync::Mutex as TokioMutex; use tracing::{debug, error}; use dogstatsd::{ @@ -29,7 +28,7 @@ pub struct FlushingService { trace_flusher: Arc, stats_flusher: Arc, proxy_flusher: Arc, - metrics_flushers: Arc>>, + metrics_flushers: Arc>, // Metrics aggregator handle for getting data to flush metrics_aggr_handle: MetricsAggregatorHandle, @@ -46,7 +45,7 @@ impl FlushingService { trace_flusher: Arc, stats_flusher: Arc, proxy_flusher: Arc, - metrics_flushers: Arc>>, + metrics_flushers: Arc>, metrics_aggr_handle: MetricsAggregatorHandle, ) -> Self { Self { @@ -90,22 +89,17 @@ impl FlushingService { // Spawn metrics flush // First get the data from aggregator, then spawn flush tasks for each flusher - let (metrics_flushers_copy, series, sketches) = { - let locked_metrics = self.metrics_flushers.lock().await; - let flush_response = self - .metrics_aggr_handle - .clone() - .flush() - .await - .expect("can't flush metrics handle"); - ( - locked_metrics.clone(), - flush_response.series, - flush_response.distributions, - ) - }; + let flush_response = self + .metrics_aggr_handle + .clone() + .flush() + .await + .expect("can't flush metrics handle"); + let series = flush_response.series; + let sketches = flush_response.distributions; - for (idx, mut flusher) in metrics_flushers_copy.into_iter().enumerate() { + for (idx, flusher) in self.metrics_flushers.iter().enumerate() { + let flusher = flusher.clone(); let series_clone = series.clone(); let sketches_clone = sketches.clone(); let handle = tokio::spawn(async move { @@ -240,8 +234,7 @@ impl FlushingService { retry_batch.sketches.len() ); joinset.spawn(async move { - let mut locked_flushers = mf.lock().await; - if let Some(flusher) = locked_flushers.get_mut(retry_batch.flusher_id) { + if let Some(flusher) = mf.get(retry_batch.flusher_id) { flusher .flush_metrics(retry_batch.series, retry_batch.sketches) .await; @@ -288,34 +281,42 @@ impl FlushingService { flush_error } - /// Performs a blocking flush of all data. + /// Performs a blocking flush of all telemetry data. /// - /// This method flushes all data synchronously using `tokio::join!` for parallelism. - /// Unlike `spawn_non_blocking`, this waits for all flushes to complete before returning. + /// Flushes logs, metrics (series and distributions), traces, stats, and APM proxy + /// data in parallel using `tokio::join!`. Unlike `spawn_non_blocking`, this waits + /// for all flushes to complete before returning. /// - /// # Arguments + /// The stats flusher respects its normal timing constraints (time-based bucketing), + /// which may result in some stats being held back until the next flush cycle. + pub async fn flush_blocking(&self) { + self.flush_blocking_inner(false).await; + } + + /// Performs a final blocking flush of all telemetry data before shutdown. /// - /// * `force_stats` - If `true`, forces the stats flusher to flush immediately - /// regardless of timing constraints. - /// * `metrics_flushers` - Mutable slice of metrics flushers. The caller must acquire - /// the lock before calling this method. + /// Flushes logs, metrics (series and distributions), traces, stats, and APM proxy + /// data in parallel. Unlike `flush_blocking`, this forces the stats flusher to + /// flush immediately regardless of its normal timing constraints. /// - /// # Note + /// Use this during shutdown when this is the last opportunity to send data. + pub async fn flush_blocking_final(&self) { + self.flush_blocking_inner(true).await; + } + + /// Internal implementation for blocking flush operations. /// - /// TODO: The caller must acquire the lock on `metrics_flushers` and pass a mutable slice - /// because `MetricsFlusher::flush_metrics` requires `&mut self`. This creates awkward - /// ergonomics. Consider modifying the `dogstatsd` crate to use interior mutability - /// (e.g., `Arc>` internally) so `flush_metrics` can take `&self`, allowing - /// this method to handle locking internally. - pub async fn flush_blocking(&self, force_stats: bool, metrics_flushers: &mut [MetricsFlusher]) { + /// Fetches metrics from the aggregator and flushes all data types in parallel. + async fn flush_blocking_inner(&self, force_stats: bool) { let flush_response = self .metrics_aggr_handle .flush() .await .expect("can't flush metrics aggr handle"); - let metrics_futures: Vec<_> = metrics_flushers - .iter_mut() + let metrics_futures: Vec<_> = self + .metrics_flushers + .iter() .map(|f| { f.flush_metrics( flush_response.series.clone(), @@ -332,15 +333,6 @@ impl FlushingService { self.proxy_flusher.flush(None), ); } - - /// Returns a reference to the metrics flushers mutex for external locking. - /// - /// This is useful when you need to lock the metrics flushers and pass them - /// to `flush_blocking` or `flush_blocking_with_interval`. - #[must_use] - pub fn metrics_flushers(&self) -> &Arc>> { - &self.metrics_flushers - } } impl std::fmt::Debug for FlushingService { diff --git a/bottlecap/tests/metrics_integration_test.rs b/bottlecap/tests/metrics_integration_test.rs index c7ca6b134..2a6c4ae58 100644 --- a/bottlecap/tests/metrics_integration_test.rs +++ b/bottlecap/tests/metrics_integration_test.rs @@ -57,7 +57,7 @@ async fn test_enhanced_metrics() { retry_strategy: dogstatsd::datadog::RetryStrategy::Immediate(1), compression_level: 6, }; - let mut metrics_flusher = MetricsFlusher::new(flusher_config); + let metrics_flusher = MetricsFlusher::new(flusher_config); let lambda_enhanced_metrics = enhanced_metrics::new(metrics_aggr_handle.clone(), Arc::clone(&arc_config));