diff --git a/Cargo.lock b/Cargo.lock index f0c6e516a..88cbc82eb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1298,15 +1298,12 @@ dependencies = [ "bytes", "criterion", "datadog-ddsketch", - "datadog-trace-normalization", - "datadog-trace-obfuscation", "datadog-trace-protobuf", "datadog-trace-utils", "ddcommon", "ddtelemetry", "dogstatsd-client", "either", - "futures", "httpmock", "hyper 0.14.31", "log", @@ -1642,8 +1639,6 @@ dependencies = [ "arrayref", "base64 0.22.1", "bincode", - "bytes", - "cadence", "chrono", "console-subscriber", "data-pipeline", @@ -1654,30 +1649,23 @@ dependencies = [ "datadog-live-debugger", "datadog-remote-config", "datadog-sidecar-macros", - "datadog-trace-normalization", - "datadog-trace-protobuf", "datadog-trace-utils", "ddcommon", "ddtelemetry", "dogstatsd-client", "futures", - "hashbrown 0.14.5", "http 0.2.12", "httpmock", "hyper 0.14.31", - "io-lifetimes", "lazy_static", "libc", "manual_future", "memory-stats", "microseh", "nix 0.27.1", - "pin-project", "prctl", "priority-queue", "rand", - "regex", - "rmp-serde", "sendfd", "serde", "serde_json", @@ -1685,7 +1673,6 @@ dependencies = [ "sha2", "simd-json", "spawn_worker", - "sys-info", "tempfile", "tinybytes", "tokio", @@ -1693,7 +1680,6 @@ dependencies = [ "tracing", "tracing-log", "tracing-subscriber", - "uuid", "winapi 0.3.9", "windows", "windows-sys 0.52.0", @@ -2083,12 +2069,10 @@ version = "16.0.3" dependencies = [ "anyhow", "cadence", - "datadog-ddsketch", - "datadog-trace-normalization", - "datadog-trace-protobuf", "ddcommon", "http 0.2.12", "serde", + "tokio", "tracing", ] diff --git a/LICENSE-3rdparty.yml b/LICENSE-3rdparty.yml index dadda3ffe..b4d0ec187 100644 --- a/LICENSE-3rdparty.yml +++ b/LICENSE-3rdparty.yml @@ -1,4 +1,4 @@ -root_name: datadog-alloc, builder, build_common, tools, datadog-crashtracker, ddcommon, ddtelemetry, datadog-ddsketch, datadog-crashtracker-ffi, ddcommon-ffi, datadog-profiling, datadog-profiling-ffi, data-pipeline-ffi, data-pipeline, datadog-trace-normalization, datadog-trace-protobuf, datadog-trace-obfuscation, datadog-trace-utils, tinybytes, dogstatsd-client, datadog-library-config-ffi, datadog-library-config, ddtelemetry-ffi, symbolizer-ffi, datadog-profiling-replayer, dogstatsd, datadog-ipc, datadog-ipc-macros, tarpc, tarpc-plugins, spawn_worker, cc_utils, datadog-live-debugger, datadog-live-debugger-ffi, datadog-remote-config, datadog-dynamic-configuration, datadog-sidecar, datadog-sidecar-macros, datadog-sidecar-ffi, sidecar_mockgen, test_spawn_from_lib, datadog-serverless-trace-mini-agent, datadog-trace-mini-agent +root_name: datadog-alloc, builder, build_common, tools, datadog-crashtracker, ddcommon, ddtelemetry, datadog-ddsketch, datadog-crashtracker-ffi, ddcommon-ffi, datadog-profiling, datadog-profiling-ffi, data-pipeline-ffi, data-pipeline, datadog-trace-protobuf, datadog-trace-utils, datadog-trace-normalization, tinybytes, dogstatsd-client, datadog-library-config-ffi, datadog-library-config, ddtelemetry-ffi, symbolizer-ffi, datadog-profiling-replayer, dogstatsd, datadog-ipc, datadog-ipc-macros, tarpc, tarpc-plugins, spawn_worker, cc_utils, datadog-live-debugger, datadog-live-debugger-ffi, datadog-remote-config, datadog-dynamic-configuration, datadog-sidecar, datadog-sidecar-macros, datadog-sidecar-ffi, sidecar_mockgen, datadog-trace-obfuscation, test_spawn_from_lib, datadog-serverless-trace-mini-agent, datadog-trace-mini-agent third_party_libraries: - package_name: addr2line package_version: 0.24.2 @@ -22378,16 +22378,16 @@ third_party_libraries: - package_name: ring package_version: 0.16.20 repository: https://github.com/briansmith/ring - license: License specified in file ($CARGO_HOME/registry/src/index.crates.io-6f17d22bba15001f/ring-0.16.20/LICENSE) + license: License specified in file ($CARGO_HOME/registry/src/index.crates.io-1949cf8c6b5b557f/ring-0.16.20/LICENSE) licenses: - - license: License specified in file ($CARGO_HOME/registry/src/index.crates.io-6f17d22bba15001f/ring-0.16.20/LICENSE) + - license: License specified in file ($CARGO_HOME/registry/src/index.crates.io-1949cf8c6b5b557f/ring-0.16.20/LICENSE) text: "Note that it is easy for this file to get out of sync with the licenses in the\nsource code files. It's recommended to compare the licenses in the source code\nwith what's mentioned here.\n\n*ring* is derived from BoringSSL, so the licensing situation in *ring* is\nsimilar to BoringSSL.\n\n*ring* uses an ISC-style license like BoringSSL for code in new files,\nincluding in particular all the Rust code:\n\n Copyright 2015-2016 Brian Smith.\n\n Permission to use, copy, modify, and/or distribute this software for any\n purpose with or without fee is hereby granted, provided that the above\n copyright notice and this permission notice appear in all copies.\n\n THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHORS DISCLAIM ALL WARRANTIES\n WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\n MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY\n SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\n WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION\n OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN\n CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n\nBoringSSL is a fork of OpenSSL. As such, large parts of it fall under OpenSSL\nlicensing. Files that are completely new have a Google copyright and an ISC\nlicense. This license is reproduced at the bottom of this file.\n\nContributors to BoringSSL are required to follow the CLA rules for Chromium:\nhttps://cla.developers.google.com/clas\n\nFiles in third_party/ have their own licenses, as described therein. The MIT\nlicense, for third_party/fiat, which, unlike other third_party directories, is\ncompiled into non-test libraries, is included below.\n\nThe OpenSSL toolkit stays under a dual license, i.e. both the conditions of the\nOpenSSL License and the original SSLeay license apply to the toolkit. See below\nfor the actual license texts. Actually both licenses are BSD-style Open Source\nlicenses. In case of any license issues related to OpenSSL please contact\nopenssl-core@openssl.org.\n\nThe following are Google-internal bug numbers where explicit permission from\nsome authors is recorded for use of their work:\n 27287199\n 27287880\n 27287883\n\n OpenSSL License\n ---------------\n\n/* ====================================================================\n * Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer. \n *\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in\n * the documentation and/or other materials provided with the\n * distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n * software must display the following acknowledgment:\n * \"This product includes software developed by the OpenSSL Project\n * for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n * endorse or promote products derived from this software without\n * prior written permission. For written permission, please contact\n * openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n * nor may \"OpenSSL\" appear in their names without prior written\n * permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n * acknowledgment:\n * \"This product includes software developed by the OpenSSL Project\n * for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com). This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n Original SSLeay License\n -----------------------\n\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n * \n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to. The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code. The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n * \n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n * \n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n * must display the following acknowledgement:\n * \"This product includes cryptographic software written by\n * Eric Young (eay@cryptsoft.com)\"\n * The word 'cryptographic' can be left out if the rouines from the library\n * being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from \n * the apps directory (application code) you must include an acknowledgement:\n * \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n * \n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n * \n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed. i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n\nISC license used for completely new code in BoringSSL:\n\n/* Copyright (c) 2015, Google Inc.\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\n * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\n * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY\n * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\n * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION\n * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN\n * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */\n\n\nThe code in third_party/fiat carries the MIT license:\n\nCopyright (c) 2015-2016 the fiat-crypto authors (see\nhttps://github.com/mit-plv/fiat-crypto/blob/master/AUTHORS).\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n" - package_name: ring package_version: 0.17.8 repository: https://github.com/briansmith/ring - license: License specified in file ($CARGO_HOME/registry/src/index.crates.io-6f17d22bba15001f/ring-0.17.8/LICENSE) + license: License specified in file ($CARGO_HOME/registry/src/index.crates.io-1949cf8c6b5b557f/ring-0.17.8/LICENSE) licenses: - - license: License specified in file ($CARGO_HOME/registry/src/index.crates.io-6f17d22bba15001f/ring-0.17.8/LICENSE) + - license: License specified in file ($CARGO_HOME/registry/src/index.crates.io-1949cf8c6b5b557f/ring-0.17.8/LICENSE) text: "Note that it is easy for this file to get out of sync with the licenses in the\nsource code files. It's recommended to compare the licenses in the source code\nwith what's mentioned here.\n\n*ring* is derived from BoringSSL, so the licensing situation in *ring* is\nsimilar to BoringSSL.\n\n*ring* uses an ISC-style license like BoringSSL for code in new files,\nincluding in particular all the Rust code:\n\n Copyright 2015-2016 Brian Smith.\n\n Permission to use, copy, modify, and/or distribute this software for any\n purpose with or without fee is hereby granted, provided that the above\n copyright notice and this permission notice appear in all copies.\n\n THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHORS DISCLAIM ALL WARRANTIES\n WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\n MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY\n SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\n WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION\n OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN\n CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n\nBoringSSL is a fork of OpenSSL. As such, large parts of it fall under OpenSSL\nlicensing. Files that are completely new have a Google copyright and an ISC\nlicense. This license is reproduced at the bottom of this file.\n\nContributors to BoringSSL are required to follow the CLA rules for Chromium:\nhttps://cla.developers.google.com/clas\n\nFiles in third_party/ have their own licenses, as described therein. The MIT\nlicense, for third_party/fiat, which, unlike other third_party directories, is\ncompiled into non-test libraries, is included below.\n\nThe OpenSSL toolkit stays under a dual license, i.e. both the conditions of the\nOpenSSL License and the original SSLeay license apply to the toolkit. See below\nfor the actual license texts. Actually both licenses are BSD-style Open Source\nlicenses. In case of any license issues related to OpenSSL please contact\nopenssl-core@openssl.org.\n\nThe following are Google-internal bug numbers where explicit permission from\nsome authors is recorded for use of their work:\n 27287199\n 27287880\n 27287883\n\n OpenSSL License\n ---------------\n\n/* ====================================================================\n * Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer. \n *\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in\n * the documentation and/or other materials provided with the\n * distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n * software must display the following acknowledgment:\n * \"This product includes software developed by the OpenSSL Project\n * for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n * endorse or promote products derived from this software without\n * prior written permission. For written permission, please contact\n * openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n * nor may \"OpenSSL\" appear in their names without prior written\n * permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n * acknowledgment:\n * \"This product includes software developed by the OpenSSL Project\n * for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com). This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n Original SSLeay License\n -----------------------\n\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n * \n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to. The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code. The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n * \n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n * \n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n * must display the following acknowledgement:\n * \"This product includes cryptographic software written by\n * Eric Young (eay@cryptsoft.com)\"\n * The word 'cryptographic' can be left out if the rouines from the library\n * being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from \n * the apps directory (application code) you must include an acknowledgement:\n * \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n * \n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n * \n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed. i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n\nISC license used for completely new code in BoringSSL:\n\n/* Copyright (c) 2015, Google Inc.\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\n * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\n * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY\n * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\n * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION\n * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN\n * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */\n\n\nThe code in third_party/fiat carries the MIT license:\n\nCopyright (c) 2015-2016 the fiat-crypto authors (see\nhttps://github.com/mit-plv/fiat-crypto/blob/master/AUTHORS).\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n" - package_name: rmp package_version: 0.8.14 @@ -34017,9 +34017,9 @@ third_party_libraries: - package_name: webpki package_version: 0.21.4 repository: https://github.com/briansmith/webpki - license: License specified in file ($CARGO_HOME/registry/src/index.crates.io-6f17d22bba15001f/webpki-0.21.4/LICENSE) + license: License specified in file ($CARGO_HOME/registry/src/index.crates.io-1949cf8c6b5b557f/webpki-0.21.4/LICENSE) licenses: - - license: License specified in file ($CARGO_HOME/registry/src/index.crates.io-6f17d22bba15001f/webpki-0.21.4/LICENSE) + - license: License specified in file ($CARGO_HOME/registry/src/index.crates.io-1949cf8c6b5b557f/webpki-0.21.4/LICENSE) text: | Except as otherwise noted, this project is licensed under the following (ISC-style) terms: diff --git a/crashtracker-ffi/src/collector/spans.rs b/crashtracker-ffi/src/collector/spans.rs index e9f356961..e9801df0d 100644 --- a/crashtracker-ffi/src/collector/spans.rs +++ b/crashtracker-ffi/src/collector/spans.rs @@ -57,7 +57,7 @@ pub unsafe extern "C" fn ddog_crasht_clear_trace_ids() -> VoidResult { /// No safety concerns. pub unsafe extern "C" fn ddog_crasht_insert_trace_id(id_high: u64, id_low: u64) -> Result { wrap_with_ffi_result!({ - let id: u128 = (id_high as u128) << 64 | (id_low as u128); + let id: u128 = ((id_high as u128) << 64) | (id_low as u128); datadog_crashtracker::insert_trace(id) }) } @@ -86,7 +86,7 @@ pub unsafe extern "C" fn ddog_crasht_insert_trace_id(id_high: u64, id_low: u64) /// No safety concerns. pub unsafe extern "C" fn ddog_crasht_insert_span_id(id_high: u64, id_low: u64) -> Result { wrap_with_ffi_result!({ - let id: u128 = (id_high as u128) << 64 | (id_low as u128); + let id: u128 = ((id_high as u128) << 64) | (id_low as u128); datadog_crashtracker::insert_span(id) }) } @@ -120,7 +120,7 @@ pub unsafe extern "C" fn ddog_crasht_remove_span_id( idx: usize, ) -> VoidResult { wrap_with_void_ffi_result!({ - let id: u128 = (id_high as u128) << 64 | (id_low as u128); + let id: u128 = ((id_high as u128) << 64) | (id_low as u128); datadog_crashtracker::remove_span(id, idx)? }) } @@ -154,7 +154,7 @@ pub unsafe extern "C" fn ddog_crasht_remove_trace_id( idx: usize, ) -> VoidResult { wrap_with_void_ffi_result!({ - let id: u128 = (id_high as u128) << 64 | (id_low as u128); + let id: u128 = ((id_high as u128) << 64) | (id_low as u128); datadog_crashtracker::remove_trace(id, idx)? }) } diff --git a/data-pipeline/Cargo.toml b/data-pipeline/Cargo.toml index 92294eeff..f4c6c2e6c 100644 --- a/data-pipeline/Cargo.toml +++ b/data-pipeline/Cargo.toml @@ -12,7 +12,6 @@ autobenches = false [dependencies] anyhow = { version = "1.0" } arc-swap = "1.7.1" -futures = { version = "0.3", default-features = false } hyper = {version = "0.14", features = ["client", "server", "runtime", "backports", "deprecated"], default-features = false} log = "0.4" rmp-serde = "1.1.1" @@ -26,10 +25,8 @@ ddcommon = { path = "../ddcommon" } ddtelemetry = { path = "../ddtelemetry" } datadog-trace-protobuf = { path = "../trace-protobuf" } datadog-trace-utils = { path = "../trace-utils" } -datadog-trace-normalization = { path = "../trace-normalization" } datadog-ddsketch = { path = "../ddsketch"} dogstatsd-client = { path = "../dogstatsd-client"} -datadog-trace-obfuscation = { path = "../trace-obfuscation" } uuid = { version = "1.10.0", features = ["v4"] } tokio-util = "0.7.11" tinybytes = { path = "../tinybytes", features = ["bytes_string", "serialization"] } diff --git a/data-pipeline/src/trace_exporter/mod.rs b/data-pipeline/src/trace_exporter/mod.rs index 0b7f36927..46ea28abe 100644 --- a/data-pipeline/src/trace_exporter/mod.rs +++ b/data-pipeline/src/trace_exporter/mod.rs @@ -23,7 +23,7 @@ use ddcommon::header::{ }; use ddcommon::tag::Tag; use ddcommon::{connector, tag, Endpoint}; -use dogstatsd_client::{new_flusher, Client, DogStatsDAction}; +use dogstatsd_client::{new, Client, DogStatsDAction}; use either::Either; use hyper::body::HttpBody; use hyper::http::uri::PathAndQuery; @@ -921,8 +921,8 @@ impl TraceExporterBuilder { .build()?; let dogstatsd = self.dogstatsd_url.and_then(|u| { - new_flusher(Endpoint::from_slice(&u)).ok() // If we couldn't set the endpoint return - // None + new(Endpoint::from_slice(&u)).ok() // If we couldn't set the endpoint return + // None }); let base_url = self.url.as_deref().unwrap_or(DEFAULT_AGENT_URL); diff --git a/dogstatsd-client/Cargo.toml b/dogstatsd-client/Cargo.toml index cc50c2122..2327761ec 100644 --- a/dogstatsd-client/Cargo.toml +++ b/dogstatsd-client/Cargo.toml @@ -11,11 +11,12 @@ bench = false [dependencies] ddcommon = { path = "../ddcommon" } -datadog-trace-protobuf = { path = "../trace-protobuf" } -datadog-trace-normalization = { path = "../trace-normalization" } -datadog-ddsketch = { path = "../ddsketch"} cadence = "1.3.0" serde = { version = "1.0", features = ["derive", "rc"] } tracing = { version = "0.1", default-features = false } anyhow = { version = "1.0" } http = "0.2" + + +[dev-dependencies] +tokio = {version = "1.23", features = ["rt", "time", "test-util", "rt-multi-thread"], default-features = false} diff --git a/dogstatsd-client/src/lib.rs b/dogstatsd-client/src/lib.rs index ffa186aa8..c595bf13f 100644 --- a/dogstatsd-client/src/lib.rs +++ b/dogstatsd-client/src/lib.rs @@ -9,7 +9,7 @@ use ddcommon::tag::Tag; use ddcommon::Endpoint; use serde::{Deserialize, Serialize}; use std::fmt::Debug; -use tracing::{debug, error, info}; +use tracing::error; use anyhow::anyhow; use cadence::prelude::*; @@ -21,6 +21,7 @@ use ddcommon::connector::uds::socket_path_from_uri; use std::net::{ToSocketAddrs, UdpSocket}; #[cfg(unix)] use std::os::unix::net::UnixDatagram; +use std::sync::{Arc, Mutex}; // Queue with a maximum capacity of 32K elements const QUEUE_SIZE: usize = 32 * 1024; @@ -67,62 +68,57 @@ pub enum DogStatsDAction<'a, T: AsRef, V: IntoIterator> { Set(T, i64, V), } -/// A dogstatsd-client that flushes stats to a given endpoint. Use `new_flusher` to build one. -#[derive(Debug)] +/// A dogstatsd-client that flushes stats to a given endpoint. +#[derive(Debug, Default)] pub struct Client { - client: StatsdClient, + client: Mutex>>, + endpoint: Option, } /// Build a new flusher instance pointed at the provided endpoint. /// Returns error if the provided endpoint is not valid. -pub fn new_flusher(endpoint: Endpoint) -> anyhow::Result { +pub fn new(endpoint: Endpoint) -> anyhow::Result { + // defer initialization of the client until the first metric is sent and we definitely know the + // client is going to be used to communicate with the endpoint. Ok(Client { - client: create_client(&endpoint)?, + endpoint: Some(endpoint), + ..Default::default() }) } impl Client { - /// Set the destination for dogstatsd metrics, if an API Key is provided the client is disabled - /// as dogstatsd is not allowed in agentless mode. Returns an error if the provided endpoint - /// is invalid. - pub fn set_endpoint(&mut self, endpoint: Endpoint) -> anyhow::Result<()> { - self.client = match endpoint.api_key { - Some(_) => { - info!("DogStatsD is not available in agentless mode"); - anyhow::bail!("DogStatsD is not available in agentless mode"); - } - None => { - debug!("Updating DogStatsD endpoint to {}", endpoint.url); - create_client(&endpoint)? - } - }; - Ok(()) - } - /// Send a vector of DogStatsDActionOwned, this is the same as `send` except it uses the "owned" /// version of DogStatsDAction. See the docs for DogStatsDActionOwned for details. pub fn send_owned(&self, actions: Vec) { - let client = &self.client; + let client_opt = match self.get_or_init_client() { + Ok(guard) => guard, + Err(e) => { + error!("Failed to get client: {}", e); + return; + } + }; - for action in actions { - if let Err(err) = match action { - DogStatsDActionOwned::Count(metric, value, tags) => { - do_send(client.count_with_tags(metric.as_ref(), value), &tags) - } - DogStatsDActionOwned::Distribution(metric, value, tags) => { - do_send(client.distribution_with_tags(metric.as_ref(), value), &tags) - } - DogStatsDActionOwned::Gauge(metric, value, tags) => { - do_send(client.gauge_with_tags(metric.as_ref(), value), &tags) + if let Some(client) = &*client_opt { + for action in actions { + if let Err(err) = match action { + DogStatsDActionOwned::Count(metric, value, tags) => { + do_send(client.count_with_tags(metric.as_ref(), value), &tags) + } + DogStatsDActionOwned::Distribution(metric, value, tags) => { + do_send(client.distribution_with_tags(metric.as_ref(), value), &tags) + } + DogStatsDActionOwned::Gauge(metric, value, tags) => { + do_send(client.gauge_with_tags(metric.as_ref(), value), &tags) + } + DogStatsDActionOwned::Histogram(metric, value, tags) => { + do_send(client.histogram_with_tags(metric.as_ref(), value), &tags) + } + DogStatsDActionOwned::Set(metric, value, tags) => { + do_send(client.set_with_tags(metric.as_ref(), value), &tags) + } + } { + error!("Error while sending metric: {}", err); } - DogStatsDActionOwned::Histogram(metric, value, tags) => { - do_send(client.histogram_with_tags(metric.as_ref(), value), &tags) - } - DogStatsDActionOwned::Set(metric, value, tags) => { - do_send(client.set_with_tags(metric.as_ref(), value), &tags) - } - } { - error!("Error while sending metric: {}", err); } } } @@ -133,31 +129,55 @@ impl Client { &self, actions: Vec>, ) { - let client = &self.client; - - for action in actions { - if let Err(err) = match action { - DogStatsDAction::Count(metric, value, tags) => { - let metric_builder = client.count_with_tags(metric.as_ref(), value); - do_send(metric_builder, tags) - } - DogStatsDAction::Distribution(metric, value, tags) => { - do_send(client.distribution_with_tags(metric.as_ref(), value), tags) - } - DogStatsDAction::Gauge(metric, value, tags) => { - do_send(client.gauge_with_tags(metric.as_ref(), value), tags) - } - DogStatsDAction::Histogram(metric, value, tags) => { - do_send(client.histogram_with_tags(metric.as_ref(), value), tags) - } - DogStatsDAction::Set(metric, value, tags) => { - do_send(client.set_with_tags(metric.as_ref(), value), tags) + let client_opt = match self.get_or_init_client() { + Ok(guard) => guard, + Err(e) => { + error!("Failed to get client: {}", e); + return; + } + }; + if let Some(client) = &*client_opt { + for action in actions { + if let Err(err) = match action { + DogStatsDAction::Count(metric, value, tags) => { + let metric_builder = client.count_with_tags(metric.as_ref(), value); + do_send(metric_builder, tags) + } + DogStatsDAction::Distribution(metric, value, tags) => { + do_send(client.distribution_with_tags(metric.as_ref(), value), tags) + } + DogStatsDAction::Gauge(metric, value, tags) => { + do_send(client.gauge_with_tags(metric.as_ref(), value), tags) + } + DogStatsDAction::Histogram(metric, value, tags) => { + do_send(client.histogram_with_tags(metric.as_ref(), value), tags) + } + DogStatsDAction::Set(metric, value, tags) => { + do_send(client.set_with_tags(metric.as_ref(), value), tags) + } + } { + error!("Error while sending metric: {}", err); } - } { - error!("Error while sending metric: {}", err); } } } + + fn get_or_init_client(&self) -> anyhow::Result>> { + if let Some(endpoint) = &self.endpoint { + let mut client_guard = self.client.lock().map_err(|e| { + anyhow!("Failed to acquire dogstatsd client lock: {}", e.to_string()) + })?; + return if client_guard.is_some() { + Ok(client_guard.clone()) + } else { + let client = Arc::new(Some(create_client(endpoint)?)); + *client_guard = client.clone(); + Ok(client) + }; + } + + Ok(None.into()) + } } fn do_send<'m, 't, T, V: IntoIterator>( @@ -229,13 +249,14 @@ fn create_client(endpoint: &Endpoint) -> anyhow::Result { #[cfg(test)] mod test { use crate::DogStatsDAction::{Count, Distribution, Gauge, Histogram, Set}; - use crate::{create_client, new_flusher, DogStatsDActionOwned}; + use crate::{create_client, new, DogStatsDActionOwned}; #[cfg(unix)] use ddcommon::connector::uds::socket_path_to_uri; use ddcommon::{tag, Endpoint}; #[cfg(unix)] use http::Uri; use std::net; + use std::sync::Arc; use std::time::Duration; #[test] @@ -244,7 +265,7 @@ mod test { let socket = net::UdpSocket::bind("127.0.0.1:0").expect("failed to bind host socket"); let _ = socket.set_read_timeout(Some(Duration::from_millis(500))); - let flusher = new_flusher(Endpoint::from_slice( + let flusher = new(Endpoint::from_slice( socket.local_addr().unwrap().to_string().as_str(), )) .unwrap(); @@ -333,7 +354,6 @@ mod test { Histogram(_, _, _) => {} Set(_, _, _) => {} } - // TODO: when std::mem::variant_count is in stable we can do this instead // assert_eq!( // std::mem::variant_count::(), @@ -341,4 +361,48 @@ mod test { // "DogStatsDActionOwned and DogStatsDAction should have the same number of variants, // did you forget to update one?", ); } + + #[tokio::test] + #[cfg_attr(miri, ignore)] + async fn test_thread_safety() { + let socket = net::UdpSocket::bind("127.0.0.1:0").expect("failed to bind host socket"); + let _ = socket.set_read_timeout(Some(Duration::from_millis(500))); + let endpoint = Endpoint::from_slice(socket.local_addr().unwrap().to_string().as_str()); + let flusher = Arc::new(new(endpoint.clone()).unwrap()); + + { + let client = flusher + .client + .lock() + .expect("failed to obtain lock on client"); + assert!(client.is_none()); + } + + let tasks: Vec<_> = (0..10) + .map(|_| { + let flusher_clone = Arc::clone(&flusher); + tokio::spawn(async move { + flusher_clone.send(vec![ + Count("test_count", 3, &vec![tag!("foo", "bar")]), + Count("test_neg_count", -2, &vec![]), + Distribution("test_distribution", 4.2, &vec![]), + Gauge("test_gauge", 7.6, &vec![]), + Histogram("test_histogram", 8.0, &vec![]), + Set("test_set", 9, &vec![tag!("the", "end")]), + Set("test_neg_set", -1, &vec![]), + ]); + + let client = flusher_clone + .client + .lock() + .expect("failed to obtain lock on client within send thread"); + assert!(client.is_some()); + }) + }) + .collect(); + + for task in tasks { + task.await.unwrap(); + } + } } diff --git a/dogstatsd/src/datadog.rs b/dogstatsd/src/datadog.rs index 41c40a511..e2641738b 100644 --- a/dogstatsd/src/datadog.rs +++ b/dogstatsd/src/datadog.rs @@ -3,12 +3,14 @@ //!Types to serialize data into the Datadog API +use crate::flusher::ShippingError; use datadog_protos::metrics::SketchPayload; use derive_more::{Display, Into}; use lazy_static::lazy_static; use protobuf::Message; use regex::Regex; use reqwest; +use reqwest::{Client, Response}; use serde::{Serialize, Serializer}; use serde_json; use std::time::Duration; @@ -114,16 +116,16 @@ impl MetricsIntakeUrlPrefix { #[inline] fn from_site(site: Site) -> Self { - Self(format!("https://api.{}", site)) + Self(format!("https://api.{site}")) } } /// Interface for the `DogStatsD` metrics intake API. -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct DdApi { api_key: String, metrics_intake_url_prefix: MetricsIntakeUrlPrefix, - client: reqwest::Client, + client: Option, } impl DdApi { @@ -134,13 +136,11 @@ impl DdApi { https_proxy: Option, timeout: Duration, ) -> Self { - let client = match Self::build_client(https_proxy, timeout) { - Ok(client) => client, - Err(e) => { - error!("Unable to parse proxy URL, no proxy will be used. {:?}", e); - reqwest::Client::new() - } - }; + let client = build_client(https_proxy, timeout) + .inspect_err(|e| { + error!("Unable to create client {:?}", e); + }) + .ok(); DdApi { api_key, metrics_intake_url_prefix, @@ -149,40 +149,25 @@ impl DdApi { } /// Ship a serialized series to the API, blocking - pub async fn ship_series(&self, series: &Series) { - let body = serde_json::to_vec(&series).expect("failed to serialize series"); - debug!("Sending body: {:?}", &series); - + pub async fn ship_series(&self, series: &Series) -> Result { let url = format!("{}/api/v2/series", &self.metrics_intake_url_prefix); - let resp = self - .client - .post(&url) - .header("DD-API-KEY", &self.api_key) - .header("Content-Type", "application/json") - .body(body) - .send() - .await; - - match resp { - Ok(resp) => match resp.status() { - reqwest::StatusCode::ACCEPTED => {} - unexpected_status_code => { - debug!( - "{}: Failed to push to API: {:?}", - unexpected_status_code, - resp.text().await.unwrap_or_default() - ); - } - }, - Err(e) => { - debug!("500: Failed to push to API: {:?}", e); - } - }; + let safe_body = serde_json::to_vec(&series) + .map_err(|e| ShippingError::Payload(format!("Failed to serialize series: {e}")))?; + debug!("Sending body: {:?}", &series); + self.ship_data(url, safe_body, "application/json").await } - pub async fn ship_distributions(&self, sketches: &SketchPayload) { + pub async fn ship_distributions( + &self, + sketches: &SketchPayload, + ) -> Result { let url = format!("{}/api/beta/sketches", &self.metrics_intake_url_prefix); + let safe_body = sketches + .write_to_bytes() + .map_err(|e| ShippingError::Payload(format!("Failed to serialize series: {e}")))?; debug!("Sending distributions: {:?}", &sketches); + self.ship_data(url, safe_body, "application/x-protobuf") + .await // TODO maybe go to coded output stream if we incrementally // add sketch payloads to the buffer // something like this, but fix the utf-8 encoding issue @@ -192,41 +177,40 @@ impl DdApi { // let _ = output_stream.write_message_no_tag(&sketches); // TODO not working, has utf-8 encoding issue in dist-intake //} - let resp = self + } + + async fn ship_data( + &self, + url: String, + body: Vec, + content_type: &str, + ) -> Result { + let client = &self .client + .as_ref() + .ok_or_else(|| ShippingError::Destination(None, "No client".to_string()))?; + let start = std::time::Instant::now(); + + let resp = client .post(&url) .header("DD-API-KEY", &self.api_key) - .header("Content-Type", "application/x-protobuf") - .body(sketches.write_to_bytes().expect("can't write to buffer")) + .header("Content-Type", content_type) + .body(body) .send() .await; - match resp { - Ok(resp) => match resp.status() { - reqwest::StatusCode::ACCEPTED => {} - unexpected_status_code => { - debug!( - "{}: Failed to push to API: {:?}", - unexpected_status_code, - resp.text().await.unwrap_or_default() - ); - } - }, - Err(e) => { - debug!("500: Failed to push to API: {:?}", e); - } - }; + + let elapsed = start.elapsed(); + debug!("Request to {} took {}ms", url, elapsed.as_millis()); + resp.map_err(|e| ShippingError::Destination(e.status(), format!("Cannot reach {url}"))) } +} - fn build_client( - https_proxy: Option, - timeout: Duration, - ) -> Result { - let mut builder = reqwest::Client::builder().timeout(timeout); - if let Some(proxy) = https_proxy { - builder = builder.proxy(reqwest::Proxy::https(proxy)?); - } - builder.build() +fn build_client(https_proxy: Option, timeout: Duration) -> Result { + let mut builder = Client::builder().timeout(timeout); + if let Some(proxy) = https_proxy { + builder = builder.proxy(reqwest::Proxy::https(proxy)?); } + builder.build() } #[derive(Debug, Serialize, Clone, Copy)] diff --git a/dogstatsd/src/flusher.rs b/dogstatsd/src/flusher.rs index 98875b209..92a0d8c85 100644 --- a/dogstatsd/src/flusher.rs +++ b/dogstatsd/src/flusher.rs @@ -4,9 +4,10 @@ use crate::aggregator::Aggregator; use crate::datadog; use datadog::{DdApi, MetricsIntakeUrlPrefix}; +use reqwest::{Response, StatusCode}; use std::sync::{Arc, Mutex}; use std::time::Duration; -use tracing::debug; +use tracing::{debug, error}; pub struct Flusher { dd_api: DdApi, @@ -50,14 +51,63 @@ impl Flusher { debug!("Flushing {n_series} series and {n_distributions} distributions"); - // TODO: client timeout is for each invocation, so NxM times with N time series batches and - // M distro batches - for a_batch in all_series { - self.dd_api.ship_series(&a_batch).await; - // TODO(astuyve) retry and do not panic + let dd_api_clone = self.dd_api.clone(); + let series_handle = tokio::spawn(async move { + for a_batch in all_series { + let continue_shipping = + should_try_next_batch(dd_api_clone.ship_series(&a_batch).await).await; + if !continue_shipping { + break; + } + } + }); + let dd_api_clone = self.dd_api.clone(); + let distributions_handle = tokio::spawn(async move { + for a_batch in all_distributions { + let continue_shipping = + should_try_next_batch(dd_api_clone.ship_distributions(&a_batch).await).await; + if !continue_shipping { + break; + } + } + }); + + match tokio::try_join!(series_handle, distributions_handle) { + Ok(_) => { + debug!("Successfully flushed {n_series} series and {n_distributions} distributions") + } + Err(err) => { + error!("Failed to flush metrics{err}") + } + }; + } +} + +pub enum ShippingError { + Payload(String), + Destination(Option, String), +} + +async fn should_try_next_batch(resp: Result) -> bool { + match resp { + Ok(resp_payload) => match resp_payload.status() { + StatusCode::ACCEPTED => true, + unexpected_status_code => { + error!( + "{}: Failed to push to API: {:?}", + unexpected_status_code, + resp_payload.text().await.unwrap_or_default() + ); + true + } + }, + Err(ShippingError::Payload(msg)) => { + error!("Failed to prepare payload. Data dropped: {}", msg); + true } - for a_batch in all_distributions { - self.dd_api.ship_distributions(&a_batch).await; + Err(ShippingError::Destination(sc, msg)) => { + error!("Error shipping data: {:?} {}", sc, msg); + false } } } diff --git a/remote-config/src/fetch/fetcher.rs b/remote-config/src/fetch/fetcher.rs index 249acb6e1..276fabb69 100644 --- a/remote-config/src/fetch/fetcher.rs +++ b/remote-config/src/fetch/fetcher.rs @@ -855,7 +855,7 @@ pub mod tests { assert_eq!(state.encoded_capabilities.len(), 4); assert_eq!( state.encoded_capabilities, - (2u32 | 1 << 24 | 1 << 31).to_be_bytes() + (2u32 | (1 << 24) | (1 << 31)).to_be_bytes() ); } } diff --git a/sidecar/Cargo.toml b/sidecar/Cargo.toml index 8389d69ab..7b6d3e733 100644 --- a/sidecar/Cargo.toml +++ b/sidecar/Cargo.toml @@ -15,16 +15,13 @@ tokio-console = ["tokio/full", "tokio/tracing", "console-subscriber"] [dependencies] anyhow = { version = "1.0" } arrayref = "0.3.7" -bytes = "1.4" priority-queue = "2.1.1" ddcommon = { path = "../ddcommon" } datadog-sidecar-macros = { path = "macros" } ddtelemetry = { path = "../ddtelemetry", features = ["tracing"] } data-pipeline = { path = "../data-pipeline" } -datadog-trace-protobuf = { path = "../trace-protobuf" } datadog-trace-utils = { path = "../trace-utils" } -datadog-trace-normalization = { path = "../trace-normalization" } datadog-remote-config = { path = "../remote-config" } datadog-live-debugger = { path = "../live-debugger" } datadog-crashtracker = { path = "../crashtracker" } @@ -36,23 +33,19 @@ manual_future = "0.1.1" http = "0.2" hyper = { version = "0.14", features = ["client", "backports", "deprecated"], default-features = false } lazy_static = "1.4" -pin-project = "1" datadog-ipc = { path = "../ipc", features = ["tiny-bytes"] } datadog-ipc-macros = { path = "../ipc/macros" } rand = "0.8.3" -regex = { version = "1" } serde = { version = "1.0", features = ["derive", "rc"] } serde_with = "3.6.0" bincode = { version = "1.3.3" } serde_json = "1.0" -rmp-serde = "1.1.1" base64 = "0.22.1" spawn_worker = { path = "../spawn_worker" } zwohash = "0.1.2" sha2 = "0.10" -sys-info = { version = "0.9.0" } tokio = { version = "1.35.1", features = [ "fs", "sync", @@ -63,7 +56,6 @@ tokio = { version = "1.35.1", features = [ tokio-util = { version = "0.7", features = ["codec"] } prctl = "1.0.0" -io-lifetimes = { version = "1.0" } tracing = { version = "0.1", default-features = false } tracing-log = { version = "0.2.0", optional = true } tracing-subscriber = { version = "0.3", default-features = false, features = [ @@ -73,13 +65,10 @@ tracing-subscriber = { version = "0.3", default-features = false, features = [ ], optional = true } chrono = "0.4.31" console-subscriber = { version = "0.1", optional = true } -uuid = { version = "1.3", features = ["v4"] } -hashbrown = { version = "0.14", features = ["raw"] } libc = { version = "0.2" } # watchdog and self telemetry memory-stats = { version = "1.0.0" } -cadence = "1.3.0" [dependencies.windows] features = [ diff --git a/sidecar/src/service/sidecar_server.rs b/sidecar/src/service/sidecar_server.rs index a87f8f103..f8e047007 100644 --- a/sidecar/src/service/sidecar_server.rs +++ b/sidecar/src/service/sidecar_server.rs @@ -54,7 +54,7 @@ use datadog_live_debugger::sender::DebuggerType; use datadog_remote_config::fetch::{ConfigInvariants, MultiTargetStats}; use datadog_trace_utils::tracer_header_tags::TracerHeaderTags; use ddcommon::tag::Tag; -use dogstatsd_client::{new_flusher, DogStatsDActionOwned}; +use dogstatsd_client::{new, DogStatsDActionOwned}; use tinybytes; type NoResponse = Ready<()>; @@ -706,7 +706,7 @@ impl SidecarInterface for SidecarServer { cfg.set_endpoint(endpoint).ok(); }); session.configure_dogstatsd(|dogstatsd| { - let d = new_flusher(config.dogstatsd_endpoint.clone()).ok(); + let d = new(config.dogstatsd_endpoint.clone()).ok(); *dogstatsd = d; }); session.modify_debugger_config(|cfg| { diff --git a/trace-normalization/src/utf8_helpers.rs b/trace-normalization/src/utf8_helpers.rs index 9868362cf..4bd52a91c 100644 --- a/trace-normalization/src/utf8_helpers.rs +++ b/trace-normalization/src/utf8_helpers.rs @@ -40,14 +40,14 @@ pub(crate) fn next_code_point<'a, I: Iterator>(bytes: &mut I) -> // so the iterator must produce a value here. let z = *bytes.next()?; let y_z = utf8_acc_cont_byte((y & CONT_MASK) as u32, z); - ch = init << 12 | y_z; + ch = (init << 12) | y_z; if x >= 0xF0 { // [x y z w] case // use only the lower 3 bits of `init` // SAFETY: `bytes` produces an UTF-8-like string, // so the iterator must produce a value here. let w = *bytes.next()?; - ch = (init & 7) << 18 | utf8_acc_cont_byte(y_z, w); + ch = ((init & 7) << 18) | utf8_acc_cont_byte(y_z, w); } }