diff --git a/Cargo.lock b/Cargo.lock index b7ee818b7..b18d2fe64 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -724,7 +724,7 @@ dependencies = [ "serde_json", "serde_repr", "serde_urlencoded", - "thiserror", + "thiserror 1.0.68", "tokio", "tokio-util", "tower-service", @@ -823,7 +823,7 @@ dependencies = [ "semver", "serde", "serde_json", - "thiserror", + "thiserror 1.0.68", ] [[package]] @@ -1001,18 +1001,17 @@ checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" [[package]] name = "common-multipart-rfc7578" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22328b3864f1d8dbe7036f3f2fdfdcb1f367af43dca418943d396fbf8c4b8021" +version = "0.6.0" +source = "git+https://github.com/jothan/rust-hyper-multipart-rfc7578.git?rev=4d3064a7a8c0062b485d50e4460cb7ad71c83d35#4d3064a7a8c0062b485d50e4460cb7ad71c83d35" dependencies = [ "bytes", "futures-core", "futures-util", - "http 0.2.12", + "http 1.1.0", "mime", "mime_guess", "rand", - "thiserror", + "thiserror 1.0.68", ] [[package]] @@ -1489,14 +1488,11 @@ dependencies = [ "criterion", "datadog-alloc", "ddcommon", + "ddcommon-net", "derivative", "futures", - "futures-core", - "futures-util", "hashbrown 0.14.5", - "http 0.2.12", - "http-body 0.4.6", - "hyper 0.14.31", + "http-body-util", "hyper-multipart-rfc7578", "indexmap 2.6.0", "libc", @@ -1525,7 +1521,7 @@ dependencies = [ "ddcommon-ffi", "ddtelemetry-ffi", "futures", - "hyper 0.14.31", + "http-body-util", "libc", "serde_json", "symbolic-common", @@ -1837,6 +1833,22 @@ dependencies = [ "serde", ] +[[package]] +name = "ddcommon-net" +version = "14.3.0" +dependencies = [ + "ddcommon", + "hex", + "http 1.1.0", + "hyper 1.5.0", + "hyper-util", + "serde", + "thiserror 2.0.3", + "tokio", + "tokio-rustls 0.26.0", + "tokio-util", +] + [[package]] name = "ddsketch-agent" version = "0.1.0" @@ -2013,7 +2025,7 @@ dependencies = [ "reqwest", "serde", "serde_json", - "thiserror", + "thiserror 1.0.68", "tokio", "tokio-util", "tracing", @@ -2714,15 +2726,14 @@ dependencies = [ [[package]] name = "hyper-multipart-rfc7578" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63ca8108ac0ae98d310d41cddb11c6b822e8aca865dbe421366934e6f7f72e10" +version = "0.8.0" +source = "git+https://github.com/jothan/rust-hyper-multipart-rfc7578.git?rev=4d3064a7a8c0062b485d50e4460cb7ad71c83d35#4d3064a7a8c0062b485d50e4460cb7ad71c83d35" dependencies = [ "bytes", "common-multipart-rfc7578", "futures-core", - "http 0.2.12", - "hyper 0.14.31", + "http 1.1.0", + "hyper 1.5.0", ] [[package]] @@ -3626,7 +3637,7 @@ dependencies = [ "percent-encoding", "pin-project", "rand", - "thiserror", + "thiserror 1.0.68", "tokio", "tokio-stream", ] @@ -3641,7 +3652,7 @@ dependencies = [ "lazy_static", "opentelemetry", "opentelemetry-semantic-conventions", - "thiserror", + "thiserror 1.0.68", "thrift", "tokio", ] @@ -4171,7 +4182,7 @@ dependencies = [ "bytes", "once_cell", "protobuf-support", - "thiserror", + "thiserror 1.0.68", ] [[package]] @@ -4186,7 +4197,7 @@ dependencies = [ "protobuf-parse", "regex", "tempfile", - "thiserror", + "thiserror 1.0.68", ] [[package]] @@ -4201,7 +4212,7 @@ dependencies = [ "protobuf", "protobuf-support", "tempfile", - "thiserror", + "thiserror 1.0.68", "which", ] @@ -4211,7 +4222,7 @@ version = "3.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b088fd20b938a875ea00843b6faf48579462630015c3788d397ad6a786663252" dependencies = [ - "thiserror", + "thiserror 1.0.68", ] [[package]] @@ -4290,7 +4301,7 @@ dependencies = [ "rustc-hash 2.0.0", "rustls 0.23.16", "socket2", - "thiserror", + "thiserror 1.0.68", "tokio", "tracing", ] @@ -4307,7 +4318,7 @@ dependencies = [ "rustc-hash 2.0.0", "rustls 0.23.16", "slab", - "thiserror", + "thiserror 1.0.68", "tinyvec", "tracing", ] @@ -4411,7 +4422,7 @@ checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" dependencies = [ "getrandom", "libredox", - "thiserror", + "thiserror 1.0.68", ] [[package]] @@ -4657,6 +4668,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eee87ff5d9b36712a58574e12e9f0ea80f915a5b0ac518d322b24a465617925e" dependencies = [ "aws-lc-rs", + "log", "once_cell", "ring 0.17.8", "rustls-pki-types", @@ -4755,7 +4767,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a15e661f0f9dac21f3494fe5d23a6338c0ac116a2d22c2b63010acd89467ffe" dependencies = [ "byteorder", - "thiserror", + "thiserror 1.0.68", "twox-hash", ] @@ -5385,7 +5397,7 @@ dependencies = [ "serde_bytes", "static_assertions", "tarpc-plugins", - "thiserror", + "thiserror 1.0.68", "tokio", "tokio-serde", "tokio-util", @@ -5493,7 +5505,7 @@ dependencies = [ "serde", "serde_json", "serde_with", - "thiserror", + "thiserror 1.0.68", "tokio", "tokio-stream", "tokio-util", @@ -5506,7 +5518,16 @@ version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "02dd99dc800bbb97186339685293e1cc5d9df1f8fae2d0aecd9ff1c77efea892" dependencies = [ - "thiserror-impl", + "thiserror-impl 1.0.68", +] + +[[package]] +name = "thiserror" +version = "2.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c006c85c7651b3cf2ada4584faa36773bd07bac24acfb39f3c431b36d7e667aa" +dependencies = [ + "thiserror-impl 2.0.3", ] [[package]] @@ -5520,6 +5541,17 @@ dependencies = [ "syn 2.0.87", ] +[[package]] +name = "thiserror-impl" +version = "2.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f077553d607adc1caf65430528a576c757a71ed73944b66ebb58ef2bbd243568" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "thread_local" version = "1.1.8" diff --git a/Cargo.toml b/Cargo.toml index 196bc1376..d1d23a6df 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,7 @@ members = [ "profiling-replayer", "ddcommon", "ddcommon-ffi", + "ddcommon-net", "ddtelemetry", "ddtelemetry-ffi", "dogstatsd", diff --git a/LICENSE-3rdparty.yml b/LICENSE-3rdparty.yml index 103f3821d..048113222 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, 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, ddcommon-net, datadog-profiling-ffi, data-pipeline-ffi, data-pipeline, datadog-trace-normalization, datadog-trace-protobuf, datadog-trace-obfuscation, datadog-trace-utils, tinybytes, dogstatsd-client, 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 third_party_libraries: - package_name: addr2line package_version: 0.24.2 @@ -7006,14 +7006,37 @@ third_party_libraries: limitations under the License. - package_name: common-multipart-rfc7578 - package_version: 0.5.0 + package_version: 0.6.0 repository: https://github.com/ferristseng/rust-multipart-rfc7578 license: MIT OR Apache-2.0 licenses: - license: MIT - text: NOT FOUND + text: | + Permission is hereby granted, free of charge, to any + person obtaining a copy of this software and associated + documentation files (the "Software"), to deal in the + Software without restriction, including without + limitation the rights to use, copy, modify, merge, + publish, distribute, sublicense, and/or sell copies of + the Software, and to permit persons to whom the Software + is furnished to do so, subject to the following + conditions: + + The above copyright notice and this permission notice + shall be included in all copies or substantial portions + of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF + ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED + TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT + SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR + IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. - license: Apache-2.0 - text: NOT FOUND + text: " Apache License\n Version 2.0, January 2004\n http://www.apache.org/licenses/\n\nTERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n1. Definitions.\n\n \"License\" shall mean the terms and conditions for use, reproduction,\n and distribution as defined by Sections 1 through 9 of this document.\n\n \"Licensor\" shall mean the copyright owner or entity authorized by\n the copyright owner that is granting the License.\n\n \"Legal Entity\" shall mean the union of the acting entity and all\n other entities that control, are controlled by, or are under common\n control with that entity. For the purposes of this definition,\n \"control\" means (i) the power, direct or indirect, to cause the\n direction or management of such entity, whether by contract or\n otherwise, or (ii) ownership of fifty percent (50%) or more of the\n outstanding shares, or (iii) beneficial ownership of such entity.\n\n \"You\" (or \"Your\") shall mean an individual or Legal Entity\n exercising permissions granted by this License.\n\n \"Source\" form shall mean the preferred form for making modifications,\n including but not limited to software source code, documentation\n source, and configuration files.\n\n \"Object\" form shall mean any form resulting from mechanical\n transformation or translation of a Source form, including but\n not limited to compiled object code, generated documentation,\n and conversions to other media types.\n\n \"Work\" shall mean the work of authorship, whether in Source or\n Object form, made available under the License, as indicated by a\n copyright notice that is included in or attached to the work\n (an example is provided in the Appendix below).\n\n \"Derivative Works\" shall mean any work, whether in Source or Object\n form, that is based on (or derived from) the Work and for which the\n editorial revisions, annotations, elaborations, or other modifications\n represent, as a whole, an original work of authorship. For the purposes\n of this License, Derivative Works shall not include works that remain\n separable from, or merely link (or bind by name) to the interfaces of,\n the Work and Derivative Works thereof.\n\n \"Contribution\" shall mean any work of authorship, including\n the original version of the Work and any modifications or additions\n to that Work or Derivative Works thereof, that is intentionally\n submitted to Licensor for inclusion in the Work by the copyright owner\n or by an individual or Legal Entity authorized to submit on behalf of\n the copyright owner. For the purposes of this definition, \"submitted\"\n means any form of electronic, verbal, or written communication sent\n to the Licensor or its representatives, including but not limited to\n communication on electronic mailing lists, source code control systems,\n and issue tracking systems that are managed by, or on behalf of, the\n Licensor for the purpose of discussing and improving the Work, but\n excluding communication that is conspicuously marked or otherwise\n designated in writing by the copyright owner as \"Not a Contribution.\"\n\n \"Contributor\" shall mean Licensor and any individual or Legal Entity\n on behalf of whom a Contribution has been received by Licensor and\n subsequently incorporated within the Work.\n\n2. Grant of Copyright License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n copyright license to reproduce, prepare Derivative Works of,\n publicly display, publicly perform, sublicense, and distribute the\n Work and such Derivative Works in Source or Object form.\n\n3. Grant of Patent License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n (except as stated in this section) patent license to make, have made,\n use, offer to sell, sell, import, and otherwise transfer the Work,\n where such license applies only to those patent claims licensable\n by such Contributor that are necessarily infringed by their\n Contribution(s) alone or by combination of their Contribution(s)\n with the Work to which such Contribution(s) was submitted. If You\n institute patent litigation against any entity (including a\n cross-claim or counterclaim in a lawsuit) alleging that the Work\n or a Contribution incorporated within the Work constitutes direct\n or contributory patent infringement, then any patent licenses\n granted to You under this License for that Work shall terminate\n as of the date such litigation is filed.\n\n4. Redistribution. You may reproduce and distribute copies of the\n Work or Derivative Works thereof in any medium, with or without\n modifications, and in Source or Object form, provided that You\n meet the following conditions:\n\n (a) You must give any other recipients of the Work or\n Derivative Works a copy of this License; and\n\n (b) You must cause any modified files to carry prominent notices\n stating that You changed the files; and\n\n (c) You must retain, in the Source form of any Derivative Works\n that You distribute, all copyright, patent, trademark, and\n attribution notices from the Source form of the Work,\n excluding those notices that do not pertain to any part of\n the Derivative Works; and\n\n (d) If the Work includes a \"NOTICE\" text file as part of its\n distribution, then any Derivative Works that You distribute must\n include a readable copy of the attribution notices contained\n within such NOTICE file, excluding those notices that do not\n pertain to any part of the Derivative Works, in at least one\n of the following places: within a NOTICE text file distributed\n as part of the Derivative Works; within the Source form or\n documentation, if provided along with the Derivative Works; or,\n within a display generated by the Derivative Works, if and\n wherever such third-party notices normally appear. The contents\n of the NOTICE file are for informational purposes only and\n do not modify the License. You may add Your own attribution\n notices within Derivative Works that You distribute, alongside\n or as an addendum to the NOTICE text from the Work, provided\n that such additional attribution notices cannot be construed\n as modifying the License.\n\n You may add Your own copyright statement to Your modifications and\n may provide additional or different license terms and conditions\n for use, reproduction, or distribution of Your modifications, or\n for any such Derivative Works as a whole, provided Your use,\n reproduction, and distribution of the Work otherwise complies with\n the conditions stated in this License.\n\n5. Submission of Contributions. Unless You explicitly state otherwise,\n any Contribution intentionally submitted for inclusion in the Work\n by You to the Licensor shall be under the terms and conditions of\n this License, without any additional terms or conditions.\n Notwithstanding the above, nothing herein shall supersede or modify\n the terms of any separate license agreement you may have executed\n with Licensor regarding such Contributions.\n\n6. Trademarks. This License does not grant permission to use the trade\n names, trademarks, service marks, or product names of the Licensor,\n except as required for reasonable and customary use in describing the\n origin of the Work and reproducing the content of the NOTICE file.\n\n7. Disclaimer of Warranty. Unless required by applicable law or\n agreed to in writing, Licensor provides the Work (and each\n Contributor provides its Contributions) on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n implied, including, without limitation, any warranties or conditions\n of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n PARTICULAR PURPOSE. You are solely responsible for determining the\n appropriateness of using or redistributing the Work and assume any\n risks associated with Your exercise of permissions under this License.\n\n8. Limitation of Liability. In no event and under no legal theory,\n whether in tort (including negligence), contract, or otherwise,\n unless required by applicable law (such as deliberate and grossly\n negligent acts) or agreed to in writing, shall any Contributor be\n liable to You for damages, including any direct, indirect, special,\n incidental, or consequential damages of any character arising as a\n result of this License or out of the use or inability to use the\n Work (including but not limited to damages for loss of goodwill,\n work stoppage, computer failure or malfunction, or any and all\n other commercial damages or losses), even if such Contributor\n has been advised of the possibility of such damages.\n\n9. Accepting Warranty or Additional Liability. While redistributing\n the Work or Derivative Works thereof, You may choose to offer,\n and charge a fee for, acceptance of support, warranty, indemnity,\n or other liability obligations and/or rights consistent with this\n License. However, in accepting such obligations, You may act only\n on Your own behalf and on Your sole responsibility, not on behalf\n of any other Contributor, and only if You agree to indemnify,\n defend, and hold each Contributor harmless for any liability\n incurred by, or claims asserted against, such Contributor by reason\n of your accepting any such warranty or additional liability.\n\nEND OF TERMS AND CONDITIONS\n\nAPPENDIX: How to apply the Apache License to your work.\n\n To apply the Apache License to your work, attach the following\n boilerplate notice, with the fields enclosed by brackets \"[]\"\n replaced with your own identifying information. (Don't include\n the brackets!) The text should be enclosed in the appropriate\n comment syntax for the file format. We also recommend that a\n file or class name and description of purpose be included on the\n same \"printed page\" as the copyright notice for easier\n identification within third-party archives.\n\nCopyright [yyyy] [name of copyright owner]\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n\thttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n" - package_name: concurrent-queue package_version: 2.5.0 repository: https://github.com/smol-rs/concurrent-queue @@ -13225,14 +13248,37 @@ third_party_libraries: OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - package_name: hyper-multipart-rfc7578 - package_version: 0.7.0 + package_version: 0.8.0 repository: https://github.com/ferristseng/rust-multipart-rfc7578 license: MIT OR Apache-2.0 licenses: - license: MIT - text: NOT FOUND + text: | + Permission is hereby granted, free of charge, to any + person obtaining a copy of this software and associated + documentation files (the "Software"), to deal in the + Software without restriction, including without + limitation the rights to use, copy, modify, merge, + publish, distribute, sublicense, and/or sell copies of + the Software, and to permit persons to whom the Software + is furnished to do so, subject to the following + conditions: + + The above copyright notice and this permission notice + shall be included in all copies or substantial portions + of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF + ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED + TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT + SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR + IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. - license: Apache-2.0 - text: NOT FOUND + text: " Apache License\n Version 2.0, January 2004\n http://www.apache.org/licenses/\n\nTERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n1. Definitions.\n\n \"License\" shall mean the terms and conditions for use, reproduction,\n and distribution as defined by Sections 1 through 9 of this document.\n\n \"Licensor\" shall mean the copyright owner or entity authorized by\n the copyright owner that is granting the License.\n\n \"Legal Entity\" shall mean the union of the acting entity and all\n other entities that control, are controlled by, or are under common\n control with that entity. For the purposes of this definition,\n \"control\" means (i) the power, direct or indirect, to cause the\n direction or management of such entity, whether by contract or\n otherwise, or (ii) ownership of fifty percent (50%) or more of the\n outstanding shares, or (iii) beneficial ownership of such entity.\n\n \"You\" (or \"Your\") shall mean an individual or Legal Entity\n exercising permissions granted by this License.\n\n \"Source\" form shall mean the preferred form for making modifications,\n including but not limited to software source code, documentation\n source, and configuration files.\n\n \"Object\" form shall mean any form resulting from mechanical\n transformation or translation of a Source form, including but\n not limited to compiled object code, generated documentation,\n and conversions to other media types.\n\n \"Work\" shall mean the work of authorship, whether in Source or\n Object form, made available under the License, as indicated by a\n copyright notice that is included in or attached to the work\n (an example is provided in the Appendix below).\n\n \"Derivative Works\" shall mean any work, whether in Source or Object\n form, that is based on (or derived from) the Work and for which the\n editorial revisions, annotations, elaborations, or other modifications\n represent, as a whole, an original work of authorship. For the purposes\n of this License, Derivative Works shall not include works that remain\n separable from, or merely link (or bind by name) to the interfaces of,\n the Work and Derivative Works thereof.\n\n \"Contribution\" shall mean any work of authorship, including\n the original version of the Work and any modifications or additions\n to that Work or Derivative Works thereof, that is intentionally\n submitted to Licensor for inclusion in the Work by the copyright owner\n or by an individual or Legal Entity authorized to submit on behalf of\n the copyright owner. For the purposes of this definition, \"submitted\"\n means any form of electronic, verbal, or written communication sent\n to the Licensor or its representatives, including but not limited to\n communication on electronic mailing lists, source code control systems,\n and issue tracking systems that are managed by, or on behalf of, the\n Licensor for the purpose of discussing and improving the Work, but\n excluding communication that is conspicuously marked or otherwise\n designated in writing by the copyright owner as \"Not a Contribution.\"\n\n \"Contributor\" shall mean Licensor and any individual or Legal Entity\n on behalf of whom a Contribution has been received by Licensor and\n subsequently incorporated within the Work.\n\n2. Grant of Copyright License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n copyright license to reproduce, prepare Derivative Works of,\n publicly display, publicly perform, sublicense, and distribute the\n Work and such Derivative Works in Source or Object form.\n\n3. Grant of Patent License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n (except as stated in this section) patent license to make, have made,\n use, offer to sell, sell, import, and otherwise transfer the Work,\n where such license applies only to those patent claims licensable\n by such Contributor that are necessarily infringed by their\n Contribution(s) alone or by combination of their Contribution(s)\n with the Work to which such Contribution(s) was submitted. If You\n institute patent litigation against any entity (including a\n cross-claim or counterclaim in a lawsuit) alleging that the Work\n or a Contribution incorporated within the Work constitutes direct\n or contributory patent infringement, then any patent licenses\n granted to You under this License for that Work shall terminate\n as of the date such litigation is filed.\n\n4. Redistribution. You may reproduce and distribute copies of the\n Work or Derivative Works thereof in any medium, with or without\n modifications, and in Source or Object form, provided that You\n meet the following conditions:\n\n (a) You must give any other recipients of the Work or\n Derivative Works a copy of this License; and\n\n (b) You must cause any modified files to carry prominent notices\n stating that You changed the files; and\n\n (c) You must retain, in the Source form of any Derivative Works\n that You distribute, all copyright, patent, trademark, and\n attribution notices from the Source form of the Work,\n excluding those notices that do not pertain to any part of\n the Derivative Works; and\n\n (d) If the Work includes a \"NOTICE\" text file as part of its\n distribution, then any Derivative Works that You distribute must\n include a readable copy of the attribution notices contained\n within such NOTICE file, excluding those notices that do not\n pertain to any part of the Derivative Works, in at least one\n of the following places: within a NOTICE text file distributed\n as part of the Derivative Works; within the Source form or\n documentation, if provided along with the Derivative Works; or,\n within a display generated by the Derivative Works, if and\n wherever such third-party notices normally appear. The contents\n of the NOTICE file are for informational purposes only and\n do not modify the License. You may add Your own attribution\n notices within Derivative Works that You distribute, alongside\n or as an addendum to the NOTICE text from the Work, provided\n that such additional attribution notices cannot be construed\n as modifying the License.\n\n You may add Your own copyright statement to Your modifications and\n may provide additional or different license terms and conditions\n for use, reproduction, or distribution of Your modifications, or\n for any such Derivative Works as a whole, provided Your use,\n reproduction, and distribution of the Work otherwise complies with\n the conditions stated in this License.\n\n5. Submission of Contributions. Unless You explicitly state otherwise,\n any Contribution intentionally submitted for inclusion in the Work\n by You to the Licensor shall be under the terms and conditions of\n this License, without any additional terms or conditions.\n Notwithstanding the above, nothing herein shall supersede or modify\n the terms of any separate license agreement you may have executed\n with Licensor regarding such Contributions.\n\n6. Trademarks. This License does not grant permission to use the trade\n names, trademarks, service marks, or product names of the Licensor,\n except as required for reasonable and customary use in describing the\n origin of the Work and reproducing the content of the NOTICE file.\n\n7. Disclaimer of Warranty. Unless required by applicable law or\n agreed to in writing, Licensor provides the Work (and each\n Contributor provides its Contributions) on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n implied, including, without limitation, any warranties or conditions\n of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n PARTICULAR PURPOSE. You are solely responsible for determining the\n appropriateness of using or redistributing the Work and assume any\n risks associated with Your exercise of permissions under this License.\n\n8. Limitation of Liability. In no event and under no legal theory,\n whether in tort (including negligence), contract, or otherwise,\n unless required by applicable law (such as deliberate and grossly\n negligent acts) or agreed to in writing, shall any Contributor be\n liable to You for damages, including any direct, indirect, special,\n incidental, or consequential damages of any character arising as a\n result of this License or out of the use or inability to use the\n Work (including but not limited to damages for loss of goodwill,\n work stoppage, computer failure or malfunction, or any and all\n other commercial damages or losses), even if such Contributor\n has been advised of the possibility of such damages.\n\n9. Accepting Warranty or Additional Liability. While redistributing\n the Work or Derivative Works thereof, You may choose to offer,\n and charge a fee for, acceptance of support, warranty, indemnity,\n or other liability obligations and/or rights consistent with this\n License. However, in accepting such obligations, You may act only\n on Your own behalf and on Your sole responsibility, not on behalf\n of any other Contributor, and only if You agree to indemnify,\n defend, and hold each Contributor harmless for any liability\n incurred by, or claims asserted against, such Contributor by reason\n of your accepting any such warranty or additional liability.\n\nEND OF TERMS AND CONDITIONS\n\nAPPENDIX: How to apply the Apache License to your work.\n\n To apply the Apache License to your work, attach the following\n boilerplate notice, with the fields enclosed by brackets \"[]\"\n replaced with your own identifying information. (Don't include\n the brackets!) The text should be enclosed in the appropriate\n comment syntax for the file format. We also recommend that a\n file or class name and description of purpose be included on the\n same \"printed page\" as the copyright notice for easier\n identification within third-party archives.\n\nCopyright [yyyy] [name of copyright owner]\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n\thttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n" - package_name: hyper-named-pipe package_version: 0.1.0 repository: https://github.com/fussybeaver/hyper-named-pipe @@ -28782,6 +28828,214 @@ third_party_libraries: incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. + END OF TERMS AND CONDITIONS +- package_name: thiserror + package_version: 2.0.3 + repository: https://github.com/dtolnay/thiserror + license: MIT OR Apache-2.0 + licenses: + - license: MIT + text: | + Permission is hereby granted, free of charge, to any + person obtaining a copy of this software and associated + documentation files (the "Software"), to deal in the + Software without restriction, including without + limitation the rights to use, copy, modify, merge, + publish, distribute, sublicense, and/or sell copies of + the Software, and to permit persons to whom the Software + is furnished to do so, subject to the following + conditions: + + The above copyright notice and this permission notice + shall be included in all copies or substantial portions + of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF + ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED + TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT + SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR + IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + - license: Apache-2.0 + text: |2 + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + END OF TERMS AND CONDITIONS - package_name: thiserror-impl package_version: 1.0.68 @@ -28990,6 +29244,214 @@ third_party_libraries: incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. + END OF TERMS AND CONDITIONS +- package_name: thiserror-impl + package_version: 2.0.3 + repository: https://github.com/dtolnay/thiserror + license: MIT OR Apache-2.0 + licenses: + - license: MIT + text: | + Permission is hereby granted, free of charge, to any + person obtaining a copy of this software and associated + documentation files (the "Software"), to deal in the + Software without restriction, including without + limitation the rights to use, copy, modify, merge, + publish, distribute, sublicense, and/or sell copies of + the Software, and to permit persons to whom the Software + is furnished to do so, subject to the following + conditions: + + The above copyright notice and this permission notice + shall be included in all copies or substantial portions + of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF + ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED + TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT + SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR + IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + - license: Apache-2.0 + text: |2 + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + END OF TERMS AND CONDITIONS - package_name: thread_local package_version: 1.1.8 diff --git a/ddcommon-net/Cargo.toml b/ddcommon-net/Cargo.toml new file mode 100644 index 000000000..d617a8fb0 --- /dev/null +++ b/ddcommon-net/Cargo.toml @@ -0,0 +1,21 @@ +# Copyright 2024-Present Datadog, Inc. https://www.datadoghq.com/ +# SPDX-License-Identifier: Apache-2.0 + +[package] +name = "ddcommon-net" +rust-version.workspace = true +edition.workspace = true +version.workspace = true +license.workspace = true + +[dependencies] +ddcommon = { path = "../ddcommon" } +hex = { version = "0.4" } +http = { version = "1" } +hyper = { version = "1", default-features = false } +hyper-util = { version = "0.1", default-features = false, features = ["tokio"] } +serde = { version = "1.0", features = ["derive"] } +thiserror = { version = "2" } +tokio = { version = "1.41" } +tokio-rustls = { version = "0.26" } +tokio-util = { version = "0.7" } diff --git a/ddcommon-net/src/compat.rs b/ddcommon-net/src/compat.rs new file mode 100644 index 000000000..1cedb7722 --- /dev/null +++ b/ddcommon-net/src/compat.rs @@ -0,0 +1,132 @@ +// Copyright 2021-Present Datadog, Inc. https://www.datadoghq.com/ +// SPDX-License-Identifier: Apache-2.0 + +use ddcommon::entity_id; +use http::request::Builder as HttpRequestBuilder; +use http::{HeaderValue, Uri}; +use serde::{Deserialize, Deserializer, Serialize, Serializer}; +use std::borrow::Cow; +use std::ops::Deref; + +// todo: why do we need to serialize and deserialize endpoints? +#[derive(Clone, PartialEq, Eq, Hash, Debug, Serialize, Deserialize)] +pub struct Endpoint { + #[serde(serialize_with = "serialize_uri", deserialize_with = "deserialize_uri")] + pub url: Uri, + pub api_key: Option>, + pub timeout_ms: u64, + /// Sets X-Datadog-Test-Session-Token header on any request + pub test_token: Option>, +} + +#[derive(serde::Deserialize, serde::Serialize)] +struct SerializedUri<'a> { + scheme: Option>, + authority: Option>, + path_and_query: Option>, +} + +fn serialize_uri(uri: &Uri, serializer: S) -> Result +where + S: Serializer, +{ + let parts = uri.clone().into_parts(); + let uri = SerializedUri { + scheme: parts.scheme.as_ref().map(|s| Cow::Borrowed(s.as_str())), + authority: parts.authority.as_ref().map(|s| Cow::Borrowed(s.as_str())), + path_and_query: parts + .path_and_query + .as_ref() + .map(|s| Cow::Borrowed(s.as_str())), + }; + uri.serialize(serializer) +} + +fn deserialize_uri<'de, D>(deserializer: D) -> Result +where + D: Deserializer<'de>, +{ + let uri = SerializedUri::deserialize(deserializer)?; + let mut builder = hyper::Uri::builder(); + if let Some(v) = uri.authority { + builder = builder.authority(v.deref()); + } + if let Some(v) = uri.scheme { + builder = builder.scheme(v.deref()); + } + if let Some(v) = uri.path_and_query { + builder = builder.path_and_query(v.deref()); + } + + builder.build().map_err(serde::de::Error::custom) +} + +impl Endpoint { + /// Default value for the timeout field in milliseconds. + pub const DEFAULT_TIMEOUT: u64 = 3_000; + + /// Return a request builder with the following headers: + /// - User agent + /// - Api key + /// - Container Id/Entity Id + pub fn to_request_builder(&self, user_agent: &str) -> Result { + let mut builder = hyper::Request::builder() + .uri(self.url.clone()) + .header(hyper::header::USER_AGENT, user_agent); + + // Add the Api key header if available + if let Some(api_key) = &self.api_key { + builder = builder.header(header::DATADOG_API_KEY, HeaderValue::from_str(api_key)?); + } + + // Add the test session token if available + if let Some(token) = &self.test_token { + builder = builder.header( + header::X_DATADOG_TEST_SESSION_TOKEN, + HeaderValue::from_str(token)?, + ); + } + + // Add the Container Id header if available + if let Some(container_id) = entity_id::get_container_id() { + builder = builder.header(header::DATADOG_CONTAINER_ID, container_id); + } + + // Add the Entity Id header if available + if let Some(entity_id) = entity_id::get_entity_id() { + builder = builder.header(header::DATADOG_ENTITY_ID, entity_id); + } + + // Add the External Env header if available + if let Some(external_env) = entity_id::get_external_env() { + builder = builder.header(header::DATADOG_EXTERNAL_ENV, external_env); + } + + Ok(builder) + } +} + +impl From for Endpoint { + fn from(uri: Uri) -> Self { + Self { + url: uri, + api_key: None, + timeout_ms: Endpoint::DEFAULT_TIMEOUT, + test_token: None, + } + } +} + +pub mod header { + #![allow(clippy::declare_interior_mutable_const)] + use hyper::{header::HeaderName, http::HeaderValue}; + pub const DATADOG_CONTAINER_ID: HeaderName = HeaderName::from_static("datadog-container-id"); + pub const DATADOG_ENTITY_ID: HeaderName = HeaderName::from_static("datadog-entity-id"); + pub const DATADOG_EXTERNAL_ENV: HeaderName = HeaderName::from_static("datadog-external-env"); + pub const DATADOG_TRACE_COUNT: HeaderName = HeaderName::from_static("x-datadog-trace-count"); + pub const DATADOG_API_KEY: HeaderName = HeaderName::from_static("dd-api-key"); + pub const APPLICATION_JSON: HeaderValue = HeaderValue::from_static("application/json"); + pub const APPLICATION_MSGPACK: HeaderValue = HeaderValue::from_static("application/msgpack"); + pub const X_DATADOG_TEST_SESSION_TOKEN: HeaderName = + HeaderName::from_static("x-datadog-test-session-token"); +} diff --git a/ddcommon-net/src/http.rs b/ddcommon-net/src/http.rs new file mode 100644 index 000000000..32ec9c6cf --- /dev/null +++ b/ddcommon-net/src/http.rs @@ -0,0 +1,304 @@ +// Copyright 2024-Present Datadog, Inc. https://www.datadoghq.com/ +// SPDX-License-Identifier: Apache-2.0 + +use hex::FromHex; +use http::{Request, Response, Uri}; +use hyper::body::{Body, Incoming}; +use hyper::rt::{Read, Write}; +use hyper_util::rt::TokioIo; +use std::result::Result as StdResult; +use std::{io, path, sync, time}; +use tokio::net::TcpStream; +use tokio::time::error::Elapsed; +use tokio_rustls::rustls; +use tokio_rustls::rustls::pki_types::ServerName; +use tokio_util::sync::CancellationToken; + +pub trait UriExt { + fn from_path(scheme: S, path: P) -> http::Result + where + http::uri::Scheme: TryFrom, + >::Error: Into, + P: AsRef; +} + +impl UriExt for Uri { + /// Encode the [path::Path] into a URI with the provided scheme. Since file + /// system paths are not valid "authority"s in URIs, the path is + /// hex-encoded. + fn from_path(scheme: S, path: P) -> http::Result + where + http::uri::Scheme: TryFrom, + >::Error: Into, + P: AsRef, + { + let path = path.as_ref(); + let hex_encoded_path = { + // On Unix we can convert the Path's OsStr into &[u8] using a + // trait from the prelude. This is possible because OsStr on Unix + // are basically just byte strings anyway. + #[cfg(unix)] + { + use std::os::unix::prelude::*; + hex::encode(path.as_os_str().as_bytes()) + } + + #[cfg(not(unix))] + // But on other platforms, notably Windows, there is not an API + // for this. So we have to either convert it to UTF lossily, or + // panic, or handle in some other way the conversion. + // This chooses to panic because that's what the implementation in + // ddcommon did. + { + hex::encode(path.to_str().unwrap().as_bytes()) + } + }; + Uri::builder() + .scheme(scheme) + .authority(hex_encoded_path) + .build() + } +} + +#[derive(Debug, thiserror::Error)] +pub enum Error { + #[error(transparent)] + Dns(#[from] rustls::pki_types::InvalidDnsNameError), + + #[error(transparent)] + Http(#[from] http::Error), + + #[error(transparent)] + Hyper(#[from] hyper::Error), + + #[error(transparent)] + Io(#[from] io::Error), + + #[error(transparent)] + Rustls(#[from] rustls::Error), + + #[error(transparent)] + Timeout(#[from] Elapsed), + + #[error("unsupported scheme: `{0}`")] + UnsupportedScheme(String), + + #[error("user requested cancellation")] + UserRequestedCancellation, +} + +/// Sends a blocking HTTP request using the provided runtime, inferring the +/// connector type to use from the request's URI scheme. This is the primary +/// API for sending an infrequent HTTP request, such as once per minute for +/// profilers. +pub fn one_shot( + runtime: &tokio::runtime::Runtime, + request: Request, + cancel: Option<&CancellationToken>, + timeout: Option, +) -> StdResult, Error> +where + B: Body + Send + 'static, + B::Data: Send, + B::Error: Into>, +{ + runtime.block_on(async move { + tokio::select! { + result = async { match timeout { + Some(t) => tokio::time::timeout(t, send_and_infer_connector(request)).await?, + None => send_and_infer_connector(request).await, + }} + => result, + _ = async { match cancel { + Some(token) => token.cancelled().await, + // If no token is provided, future::pending() provides a no-op future that never resolves + None => std::future::pending().await, + }} + => Err(Error::UserRequestedCancellation), + } + }) +} + +pub async fn send_and_infer_connector( + request: Request, +) -> StdResult, Error> +where + B: Body + Send + 'static, + B::Data: Send, + B::Error: Into>, +{ + let uri = request.uri(); + match uri.scheme() { + None => Err(Error::UnsupportedScheme(String::new())), + Some(scheme) => match scheme.as_str() { + "http" => send_http(request).await, + "https" => send_https(request).await, + #[cfg(unix)] + "unix" => send_via_unix_socket(request).await, + #[cfg(windows)] + "windows" => send_via_named_pipe(request).await, + scheme => Err(Error::UnsupportedScheme(String::from(scheme))), + }, + } +} + +#[cfg(unix)] +pub async fn send_via_unix_socket(request: Request) -> StdResult, Error> +where + B: Body + Send + 'static, + B::Data: Send, + B::Error: Into>, +{ + let path = parse_path_from_uri(request.uri())?; + let unix_stream = tokio::net::UnixStream::connect(path).await?; + let hyper_wrapper = TokioIo::new(unix_stream); + + Ok(send_via_io(request, hyper_wrapper).await?) +} + +#[cfg(windows)] +pub async fn send_via_named_pipe(request: Request) -> StdResult, Error> +where + B: Body + Send + 'static, + B::Data: Send, + B::Error: Into>, +{ + let _path = parse_path_from_uri(request.uri())?; + todo!("re-implement named pipes on Windows") +} + +pub async fn send_http(request: Request) -> StdResult, Error> +where + B: Body + Send + 'static, + B::Data: Send, + B::Error: Into>, +{ + // This _should_ be a redundant check, caller should only call this if + // they expect it's an http connection to begin with. + let scheme_str = request.uri().scheme_str(); + if scheme_str != Some("http") { + let base = "URI scheme must be http"; + let msg = if let Some(scheme) = scheme_str { + format!("{base}, given {scheme}") + } else { + format!("{base}, empty scheme found") + }; + let err = io::Error::new(io::ErrorKind::InvalidInput, msg); + return Err(Error::from(err)); + } + + let authority = request + .uri() + .authority() + .ok_or(Error::Io(io::Error::new( + io::ErrorKind::InvalidInput, + "URI must have host", + )))? + .as_str(); + let stream = TcpStream::connect(authority).await?; + let hyper_wrapper = TokioIo::new(stream); + + Ok(send_via_io(request, hyper_wrapper).await?) +} + +pub async fn send_https(request: Request) -> StdResult, Error> +where + B: Body + Send + 'static, + B::Data: Send, + B::Error: Into>, +{ + let uri = request.uri(); + + // This _should_ be a redundant check, caller should only call this if + // they expect it's an https connection to begin with. + let scheme_str = request.uri().scheme_str(); + if scheme_str != Some("https") { + let base = "URI scheme must be https"; + let msg = if let Some(scheme) = scheme_str { + format!("{base}, given {scheme}") + } else { + format!("{base}, empty scheme found") + }; + let err = io::Error::new(io::ErrorKind::InvalidInput, msg); + return Err(Error::from(err)); + } + + let server_name = ServerName::try_from(uri.to_string())?; + let connector = { + let config = rustls::ClientConfig::builder() + .with_root_certificates(rustls::RootCertStore::empty()) + .with_no_client_auth(); + tokio_rustls::TlsConnector::from(sync::Arc::new(config)) + }; + + let tcp_stream = { + let authority = uri.authority().ok_or(Error::Io(io::Error::new( + io::ErrorKind::InvalidInput, + "URI must have a host", + )))?; + TcpStream::connect(authority.as_str()).await? + }; + + let stream = connector.connect(server_name, tcp_stream).await?; + let hyper_wrapper = TokioIo::new(stream); + Ok(send_via_io(request, hyper_wrapper).await?) +} + +async fn send_via_io( + request: Request, + io: T, +) -> StdResult, hyper::Error> +where + T: Read + Write + Send + Unpin + 'static, + B: Body + Send + 'static, + B::Data: Send, + B::Error: Into>, +{ + let (mut sender, connection) = hyper::client::conn::http1::handshake(io).await?; + + // The docs say we need to poll this to drive it to completion, but they + // never directly use the return type or anything: + // https://hyper.rs/guides/1/client/basic/ + let _todo = tokio::spawn(connection); + + sender.send_request(request).await +} + +pub fn parse_path_from_uri(uri: &Uri) -> io::Result { + // This _should_ be a redundant check, caller should only call this if + // they expect it's a unix domain socket or windows named pipe. + let scheme_str = uri.scheme_str(); + if scheme_str != Some("unix") || scheme_str != Some("windows") { + let base = "URI scheme must be unix or windows"; + let msg = if let Some(scheme) = scheme_str { + format!("{base}, given {scheme}") + } else { + format!("{base}, empty scheme found") + }; + return Err(io::Error::new(io::ErrorKind::InvalidInput, msg)); + } + + if let Some(host) = uri.host() { + let bytes = Vec::from_hex(host).map_err(|err| { + io::Error::new( + io::ErrorKind::InvalidInput, + format!("URI host must be a hex-encoded path: {err}"), + ) + })?; + let str = match std::str::from_utf8(&bytes) { + Ok(s) => s, + Err(err) => { + return Err(io::Error::new( + io::ErrorKind::InvalidInput, + format!("URI is invalid: {err}"), + )) + } + }; + Ok(path::PathBuf::from(str)) + } else { + Err(io::Error::new( + io::ErrorKind::InvalidInput, + "URI is missing host", + )) + } +} diff --git a/ddcommon-net/src/lib.rs b/ddcommon-net/src/lib.rs new file mode 100644 index 000000000..d087cb294 --- /dev/null +++ b/ddcommon-net/src/lib.rs @@ -0,0 +1,40 @@ +// Copyright 2024-Present Datadog, Inc. https://www.datadoghq.com/ +// SPDX-License-Identifier: Apache-2.0 + +/// Provides _some_ migration paths from the ddcommon +pub mod compat; + +/// The http module has types and functions for working with HTTP requests +/// through hyper and tokio. Generally, we do not need asynchronous execution, +/// but we do need features like HTTP over UNIX Domain Sockets (UDS) and +/// Windows Named Pipes. This aims to provide a simple API for doing blocking, +/// synchronous HTTP calls with all the different connectors we support. +pub mod http; + +/// This module exports some dependencies so that crates depending on this +/// one do not also have to directly depend on and manage the versions. +pub mod dep { + pub use hex; + pub use http; + pub use hyper; + pub use tokio; +} + +/// Holds a function to create a Tokio Runtime for the current thread. +/// Note that currently it will still use a thread pool for certain operations +/// which block. +pub mod rt { + use std::io; + use tokio::runtime; + use tokio_util::sync::CancellationToken; + + /// Creates a tokio runtime for the current thread. This is the expected + /// way to create a runtime used by this crate. + pub fn create_current_thread_runtime() -> io::Result { + runtime::Builder::new_current_thread().enable_all().build() + } + + pub fn create_cancellation_token() -> CancellationToken { + CancellationToken::new() + } +} diff --git a/ddcommon/Cargo.toml b/ddcommon/Cargo.toml index c947a6f35..c529f05ad 100644 --- a/ddcommon/Cargo.toml +++ b/ddcommon/Cargo.toml @@ -30,16 +30,16 @@ hyper = { version = "0.14", features = [ cc = "=1.1.31" hyper-util = "0.1.3" lazy_static = "1.4" +libc = "0.2" log = { version = "0.4" } pin-project = "1" regex = "1.5" rustls = { version = "0.23", default-features = false } rustls-native-certs = { version = "0.7" } -tokio = { version = "1.23", features = ["rt", "macros"] } -tokio-rustls = { version = "0.26", default-features = false } serde = { version = "1.0", features = ["derive"] } static_assertions = "1.1.0" -libc = "0.2" +tokio = { version = "1.23", features = ["rt", "macros"] } +tokio-rustls = { version = "0.26", default-features = false } [target.'cfg(windows)'.dependencies.windows-sys] version = "0.52" diff --git a/profiling-ffi/Cargo.toml b/profiling-ffi/Cargo.toml index 2e1e62c5f..02151f9ae 100644 --- a/profiling-ffi/Cargo.toml +++ b/profiling-ffi/Cargo.toml @@ -34,15 +34,17 @@ build_common = { path = "../build-common" } anyhow = "1.0" datadog-crashtracker-ffi = { path = "../crashtracker-ffi", default-features = false, optional = true} datadog-profiling = { path = "../profiling" } -hyper = { version = "0.14", features = ["backports", "deprecated"], default-features = false } +data-pipeline-ffi = { path = "../data-pipeline-ffi", default-features = false, optional = true } ddcommon = { path = "../ddcommon"} ddcommon-ffi = { path = "../ddcommon-ffi", default-features = false } ddtelemetry-ffi = { path = "../ddtelemetry-ffi", default-features = false, optional = true, features = ["expanded_builder_macros"] } +futures = { version = "0.3", default-features = false } libc = "0.2" -tokio-util = "0.7.1" serde_json = { version = "1.0" } -futures = { version = "0.3", default-features = false } symbolizer-ffi = { path = "../symbolizer-ffi", optional = true, default-features = false } symbolic-demangle = { version = "12.8.0", default-features = false, features = ["rust", "cpp", "msvc"] } symbolic-common = "12.8.0" -data-pipeline-ffi = { path = "../data-pipeline-ffi", default-features = false, optional = true } +tokio-util = "0.7.1" + +[dev-dependencies] +http-body-util = "0.1" diff --git a/profiling-ffi/src/exporter.rs b/profiling-ffi/src/exporter.rs index e1cc5db11..f2f94fb4f 100644 --- a/profiling-ffi/src/exporter.rs +++ b/profiling-ffi/src/exporter.rs @@ -4,13 +4,12 @@ #![allow(renamed_and_removed_lints)] #![allow(clippy::box_vec)] -use datadog_profiling::exporter; -use datadog_profiling::exporter::{ProfileExporter, Request}; +use datadog_profiling::exporter::config::{self, EndpointExt}; +use datadog_profiling::exporter::{self, Endpoint, ProfileExporter, Request, Uri}; use datadog_profiling::internal::ProfiledEndpointsStats; use ddcommon::tag::Tag; use ddcommon_ffi::slice::{AsBytes, ByteSlice, CharSlice, Slice}; use ddcommon_ffi::{Error, MaybeError, Timespec}; -use std::borrow::Cow; use std::ptr::NonNull; use std::str::FromStr; @@ -93,38 +92,39 @@ pub extern "C" fn ddog_prof_Endpoint_agentless<'a>( pub extern "C" fn endpoint_file(filename: CharSlice) -> ProfilingEndpoint { ProfilingEndpoint::File(filename) } -unsafe fn try_to_url(slice: CharSlice) -> anyhow::Result { + +unsafe fn try_to_url(slice: CharSlice) -> anyhow::Result { let str: &str = slice.try_to_utf8()?; #[cfg(unix)] if let Some(path) = str.strip_prefix("unix://") { - return Ok(exporter::socket_path_to_uri(path.as_ref())?); + return Ok(config::try_socket_path_to_uri(path.as_ref())?); } #[cfg(windows)] if let Some(path) = str.strip_prefix("windows:") { - return Ok(exporter::named_pipe_path_to_uri(path.as_ref())?); + return Ok(config::try_named_pipe_path_to_uri(path.as_ref())?); } - Ok(hyper::Uri::from_str(str)?) + Ok(Uri::from_str(str)?) } -pub unsafe fn try_to_endpoint(endpoint: ProfilingEndpoint) -> anyhow::Result { +pub unsafe fn try_to_endpoint(endpoint: ProfilingEndpoint) -> anyhow::Result { // convert to utf8 losslessly -- URLs and API keys should all be ASCII, so // a failed result is likely to be an error. match endpoint { ProfilingEndpoint::Agent(url) => { let base_url = try_to_url(url)?; - exporter::config::agent(base_url) + Ok(Endpoint::profiling_agent(base_url)?) } ProfilingEndpoint::Agentless(site, api_key) => { let site_str = site.try_to_utf8()?; let api_key_str = api_key.try_to_utf8()?; - exporter::config::agentless( - Cow::Owned(site_str.to_owned()), - Cow::Owned(api_key_str.to_owned()), - ) + Ok(Endpoint::profiling_agentless( + site_str, + api_key_str.to_owned(), + )?) } ProfilingEndpoint::File(filename) => { let filename = filename.try_to_utf8()?; - exporter::config::file(filename) + Ok(Endpoint::profiling_file(filename)?) } } } @@ -481,7 +481,7 @@ mod tests { use super::*; use ddcommon::tag; use ddcommon_ffi::Slice; - use hyper::body::HttpBody; + use http_body_util::BodyExt; use serde_json::json; fn profiling_library_name() -> CharSlice<'static> { @@ -512,6 +512,7 @@ mod tests { // alternative. If you do figure out a better way, there's another copy of this code // in the profiling tests, please update there too :) let body = request.body(); + let body_bytes: String = String::from_utf8_lossy( &futures::executor::block_on(body.collect()) .unwrap() @@ -968,7 +969,10 @@ mod tests { }; let build_result = Result::from(build_result); - build_result.unwrap_err(); + assert!( + build_result.is_err(), + "ddog_prof_Exporter_Request_build returned Ok when it should have errored" + ); } #[test] diff --git a/profiling/Cargo.toml b/profiling/Cargo.toml index 667bb8bcb..6677ba568 100644 --- a/profiling/Cargo.toml +++ b/profiling/Cargo.toml @@ -20,19 +20,15 @@ harness = false [dependencies] anyhow = "1.0" bitmaps = "3.2.0" +byteorder = { version = "1.5", features = ["std"] } bytes = "1.1" chrono = {version = "0.4", default-features = false, features = ["std", "clock"]} datadog-alloc = {path = "../alloc"} ddcommon = {path = "../ddcommon"} +ddcommon-net = { path = "../ddcommon-net" } derivative = "2.2.0" -futures = { version = "0.3", default-features = false } -futures-core = {version = "0.3.0", default-features = false} -futures-util = {version = "0.3.0", default-features = false} hashbrown = { version = "0.14", default-features = false, features = ["allocator-api2"] } -http = "0.2" -http-body = "0.4" -hyper = {version = "0.14", features = ["client", "backports", "deprecated"], default-features = false} -hyper-multipart-rfc7578 = "0.7.0" +hyper-multipart-rfc7578 = { git = "https://github.com/jothan/rust-hyper-multipart-rfc7578.git", rev = "4d3064a7a8c0062b485d50e4460cb7ad71c83d35" } indexmap = "2.2" libc = "0.2" lz4_flex = { version = "0.9", default-features = false, features = ["std", "safe-encode", "frame"] } @@ -45,9 +41,10 @@ serde = {version = "1.0", features = ["derive"]} serde_json = {version = "1.0"} tokio = {version = "1.23", features = ["rt", "macros"]} tokio-util = "0.7.1" -byteorder = { version = "1.5", features = ["std"] } [dev-dependencies] bolero = "0.10.1" bolero-generator = "0.10.2" criterion = "0.5.1" +futures = { version = "0.3", default-features = false } +http-body-util = "0.1" diff --git a/profiling/src/exporter/config.rs b/profiling/src/exporter/config.rs index affb49d2a..a738599ff 100644 --- a/profiling/src/exporter/config.rs +++ b/profiling/src/exporter/config.rs @@ -1,76 +1,80 @@ // Copyright 2021-Present Datadog, Inc. https://www.datadoghq.com/ // SPDX-License-Identifier: Apache-2.0 -#[cfg(unix)] -use ddcommon::connector::uds; -use ddcommon::Endpoint; - -#[cfg(windows)] -use ddcommon::connector::named_pipe; - -use http::Uri; +use crate::exporter::Uri; +use ddcommon_net::compat::Endpoint; +use ddcommon_net::{dep::http, http::UriExt}; use std::borrow::Cow; +use std::path::Path; use std::str::FromStr; -/// Creates an Endpoint for talking to the Datadog agent. -/// -/// # Arguments -/// * `base_url` - has protocol, host, and port e.g. http://localhost:8126/ -pub fn agent(base_url: Uri) -> anyhow::Result { - let mut parts = base_url.into_parts(); - let p_q = match parts.path_and_query { - None => None, - Some(pq) => { - let path = pq.path(); - let path = path.strip_suffix('/').unwrap_or(path); - Some(format!("{path}/profiling/v1/input").parse()?) - } - }; - parts.path_and_query = p_q; - let url = Uri::from_parts(parts)?; - Ok(Endpoint::from_url(url)) -} +pub trait EndpointExt { + fn profiling_agentless( + site: impl AsRef, + api_key: impl Into>, + ) -> http::Result; -/// Creates an Endpoint for talking to the Datadog agent though a unix socket. -/// -/// # Arguments -/// * `socket_path` - file system path to the socket -#[cfg(unix)] -pub fn agent_uds(path: &std::path::Path) -> anyhow::Result { - let base_url = uds::socket_path_to_uri(path)?; - agent(base_url) -} + fn profiling_agent>(uri: U) -> Result + where + http::Error: From; -/// Creates an Endpoint for talking to the Datadog agent though a windows named pipe. -/// -/// # Arguments -/// * `path` - file system path to the named pipe -#[cfg(windows)] -pub fn agent_named_pipe(path: &std::path::Path) -> anyhow::Result { - let base_url = named_pipe::named_pipe_path_to_uri(path)?; - agent(base_url) + fn profiling_file(path: impl AsRef) -> http::Result; } -/// Creates an Endpoint for talking to Datadog intake without using the agent. -/// This is an experimental feature. -/// -/// # Arguments -/// * `site` - e.g. "datadoghq.com". -/// * `api_key` -pub fn agentless, IntoCow: Into>>( - site: AsStrRef, - api_key: IntoCow, -) -> anyhow::Result { - let intake_url: String = format!("https://intake.profile.{}/api/v2/profile", site.as_ref()); +impl EndpointExt for Endpoint { + fn profiling_agentless( + site: impl AsRef, + api_key: impl Into>, + ) -> http::Result { + let intake_url = format!("https://intake.profile.{}/api/v2/profile", site.as_ref()); + Ok(Self { + url: Uri::try_from(intake_url)?, + api_key: Some(api_key.into()), + timeout_ms: 0, + test_token: None, + }) + } + + fn profiling_agent>(uri: U) -> Result + where + http::Error: From, + { + let mut parts = uri.try_into()?.into_parts(); + parts.path_and_query = Some(http::uri::PathAndQuery::from_str("/profiling/v1/input")?); + let url = Uri::from_parts(parts)?; + Ok(Self { + url, + api_key: None, + timeout_ms: 0, + test_token: None, + }) + } - Ok(Endpoint { - url: Uri::from_str(intake_url.as_str())?, - api_key: Some(api_key.into()), - ..Default::default() - }) + fn profiling_file(path: impl AsRef) -> http::Result { + let raw_url = format!("file://{}", path.as_ref()); + let url = Uri::from_str(&raw_url)?; + Ok(Self::from(url)) + } } -pub fn file(path: impl AsRef) -> anyhow::Result { - let url: String = format!("file://{}", path.as_ref()); - Ok(Endpoint::from_slice(&url)) +#[cfg(unix)] +/// Creates a new Uri, with the `unix` scheme, and the path to the socket +/// encoded as a hex string, to prevent special characters in the url authority +pub fn try_socket_path_to_uri(path: &Path) -> http::Result { + Uri::from_path("unix", path) +} + +#[cfg(windows)] +/// Windows Named Pipe +/// https://docs.microsoft.com/en-us/windows/win32/ipc/named-pipes +/// +/// The form a windows named pipe path is either local to the computer: +/// \\.\pipe\pipename +/// or targeting a remote server +/// \\ServerName\pipe\pipename +/// +/// Build a URI from a Path representing a named pipe +/// `path` - named pipe path. ex: \\.\pipe\pipename +pub fn try_named_pipe_path_to_uri(path: &Path) -> http::Result { + Uri::from_path("windows", path) } diff --git a/profiling/src/exporter/mod.rs b/profiling/src/exporter/mod.rs index 14c985109..598248dbe 100644 --- a/profiling/src/exporter/mod.rs +++ b/profiling/src/exporter/mod.rs @@ -1,21 +1,23 @@ // Copyright 2021-Present Datadog, Inc. https://www.datadoghq.com/ // SPDX-License-Identifier: Apache-2.0 -use std::borrow::Cow; -use std::future; -use std::io::{Cursor, Write}; - -use bytes::Bytes; -pub use chrono::{DateTime, Utc}; -pub use ddcommon::tag::Tag; -pub use hyper::Uri; use hyper_multipart_rfc7578::client::multipart; use lz4_flex::frame::FrameEncoder; use serde_json::json; -use tokio::runtime::Runtime; +use std::borrow::Cow; +use std::io::{Cursor, Write}; use tokio_util::sync::CancellationToken; -use ddcommon::{azure_app_services, connector, Endpoint, HttpClient, HttpResponse}; +use crate::internal::ProfiledEndpointsStats; +use ddcommon::{azure_app_services, connector}; +use ddcommon_net::dep::{http, hyper, tokio}; + +use hyper::body::Incoming; + +pub use chrono::{DateTime, Utc}; +pub use ddcommon::tag::Tag; +pub use ddcommon_net::compat::Endpoint; +pub use http::Uri; pub mod config; mod errors; @@ -26,22 +28,15 @@ pub use connector::uds::{socket_path_from_uri, socket_path_to_uri}; #[cfg(windows)] pub use connector::named_pipe::{named_pipe_path_from_uri, named_pipe_path_to_uri}; -use crate::internal::ProfiledEndpointsStats; - const DURATION_ZERO: std::time::Duration = std::time::Duration::from_millis(0); -pub struct Exporter { - client: HttpClient, - runtime: Runtime, -} - pub struct Fields { pub start: DateTime, pub end: DateTime, } pub struct ProfileExporter { - exporter: Exporter, + runtime: tokio::runtime::Runtime, endpoint: Endpoint, family: Cow<'static, str>, profiling_library_name: Cow<'static, str>, @@ -54,14 +49,13 @@ pub struct File<'a> { pub bytes: &'a [u8], } -#[derive(Debug)] pub struct Request { timeout: Option, - req: hyper::Request, + req: hyper::Request, } -impl From> for Request { - fn from(req: hyper::Request) -> Self { +impl From> for Request { + fn from(req: hyper::Request) -> Self { Self { req, timeout: None } } } @@ -80,7 +74,7 @@ impl Request { &self.timeout } - pub fn uri(&self) -> &hyper::Uri { + pub fn uri(&self) -> &Uri { self.req.uri() } @@ -88,32 +82,9 @@ impl Request { self.req.headers() } - pub fn body(self) -> hyper::Body { + pub fn body(self) -> multipart::Body { self.req.into_body() } - - async fn send( - self, - client: &HttpClient, - cancel: Option<&CancellationToken>, - ) -> anyhow::Result> { - tokio::select! { - _ = async { match cancel { - Some(cancellation_token) => cancellation_token.cancelled().await, - // If no token is provided, future::pending() provides a no-op future that never resolves - None => future::pending().await, - }} - => Err(crate::exporter::errors::Error::UserRequestedCancellation.into()), - result = async { - Ok(match self.timeout { - Some(t) => tokio::time::timeout(t, client.request(self.req)) - .await - .map_err(|_| crate::exporter::errors::Error::OperationTimedOut)?, - None => client.request(self.req).await, - }?)} - => result, - } - } } impl ProfileExporter { @@ -141,7 +112,7 @@ impl ProfileExporter { V: Into>, { Ok(Self { - exporter: Exporter::new()?, + runtime: ddcommon_net::rt::create_current_thread_runtime()?, endpoint, family: family.into(), profiling_library_name: profiling_library_name.into(), @@ -273,66 +244,35 @@ impl ProfileExporter { let builder = self .endpoint - .into_request_builder(concat!("DDProf/", env!("CARGO_PKG_VERSION")))? - .method(http::Method::POST) - .header("Connection", "close") + .to_request_builder(concat!("DDProf/", env!("CARGO_PKG_VERSION")))? + .method(http::Method::POST.as_str()) + .header(http::header::CONNECTION.as_str(), "close") .header("DD-EVP-ORIGIN", self.profiling_library_name.as_ref()) .header( "DD-EVP-ORIGIN-VERSION", self.profiling_library_version.as_ref(), ); - Ok( - Request::from(form.set_body_convert::(builder)?) - .with_timeout(std::time::Duration::from_millis(self.endpoint.timeout_ms)), - ) + let request = form.set_body::(builder)?; + + Ok(Request::from(request) + .with_timeout(std::time::Duration::from_millis(self.endpoint.timeout_ms))) } pub fn send( &self, request: Request, cancel: Option<&CancellationToken>, - ) -> anyhow::Result { - self.exporter - .runtime - .block_on(request.send(&self.exporter.client, cancel)) + ) -> anyhow::Result> { + Ok(ddcommon_net::http::one_shot( + &self.runtime, + request.req, + cancel, + request.timeout, + )?) } pub fn set_timeout(&mut self, timeout_ms: u64) { self.endpoint.timeout_ms = timeout_ms; } } - -impl Exporter { - /// Creates a new Exporter, initializing the TLS stack. - pub fn new() -> anyhow::Result { - // Set idle to 0, which prevents the pipe being broken every 2nd request - let client = hyper::Client::builder() - .pool_max_idle_per_host(0) - .build(connector::Connector::default()); - let runtime = tokio::runtime::Builder::new_current_thread() - .enable_all() - .build()?; - Ok(Self { client, runtime }) - } - - pub fn send( - &self, - http_method: http::Method, - url: &str, - mut headers: hyper::header::HeaderMap, - body: &[u8], - timeout: std::time::Duration, - ) -> anyhow::Result> { - self.runtime.block_on(async { - let mut request = hyper::Request::builder() - .method(http_method) - .uri(url) - .body(hyper::Body::from(Bytes::copy_from_slice(body)))?; - std::mem::swap(request.headers_mut(), &mut headers); - - let request: Request = request.into(); - request.with_timeout(timeout).send(&self.client, None).await - }) - } -} diff --git a/profiling/tests/form.rs b/profiling/tests/form.rs index 4eed33d21..d6c6ecc6f 100644 --- a/profiling/tests/form.rs +++ b/profiling/tests/form.rs @@ -59,9 +59,9 @@ fn multipart( #[cfg(test)] mod tests { use crate::multipart; + use datadog_profiling::exporter::config::EndpointExt; use datadog_profiling::exporter::*; use ddcommon::tag; - use hyper::body::HttpBody; use serde_json::json; fn default_tags() -> Vec { @@ -69,6 +69,7 @@ mod tests { } fn parsed_event_json(request: Request) -> serde_json::Value { + use http_body_util::BodyExt; // Really hacky way of getting the event.json file contents, because I didn't want to // implement a full multipart parser and didn't find a particularly good // alternative. If you do figure out a better way, there's another copy of this code @@ -96,8 +97,8 @@ mod tests { fn multipart_agent() { let profiling_library_name = "dd-trace-foo"; let profiling_library_version = "1.2.3"; - let base_url = "http://localhost:8126".parse().expect("url to parse"); - let endpoint = config::agent(base_url).expect("endpoint to construct"); + let endpoint = + Endpoint::profiling_agent("http://localhost:8126").expect("endpoint to construct"); let mut exporter = ProfileExporter::new( profiling_library_name, profiling_library_version, @@ -145,8 +146,8 @@ mod tests { fn including_internal_metadata() { let profiling_library_name = "dd-trace-foo"; let profiling_library_version = "1.2.3"; - let base_url = "http://localhost:8126".parse().expect("url to parse"); - let endpoint = config::agent(base_url).expect("endpoint to construct"); + let endpoint = + Endpoint::profiling_agent("http://localhost:8126").expect("endpoint to construct"); let mut exporter = ProfileExporter::new( profiling_library_name, profiling_library_version, @@ -174,8 +175,8 @@ mod tests { fn including_info() { let profiling_library_name = "dd-trace-foo"; let profiling_library_version = "1.2.3"; - let base_url = "http://localhost:8126".parse().expect("url to parse"); - let endpoint = config::agent(base_url).expect("endpoint to construct"); + let endpoint = + Endpoint::profiling_agent("http://localhost:8126").expect("endpoint to construct"); let mut exporter = ProfileExporter::new( profiling_library_name, profiling_library_version, @@ -214,8 +215,9 @@ mod tests { fn multipart_agentless() { let profiling_library_name = "dd-trace-foo"; let profiling_library_version = "1.2.3"; + let site = "datadoghq.com"; let api_key = "1234567890123456789012"; - let endpoint = config::agentless("datadoghq.com", api_key).expect("endpoint to construct"); + let endpoint = Endpoint::profiling_agentless(site, api_key).expect("endpoint to construct"); let mut exporter = ProfileExporter::new( profiling_library_name, profiling_library_version, diff --git a/tools/docker/Dockerfile.build b/tools/docker/Dockerfile.build index b6f744fc7..68a1120fb 100644 --- a/tools/docker/Dockerfile.build +++ b/tools/docker/Dockerfile.build @@ -74,6 +74,7 @@ COPY "crashtracker/Cargo.toml" "crashtracker/" COPY "crashtracker-ffi/Cargo.toml" "crashtracker-ffi/" COPY "ddcommon/Cargo.toml" "ddcommon/" COPY "ddcommon-ffi/Cargo.toml" "ddcommon-ffi/" +COPY "ddcommon-net/Cargo.toml" "ddcommon-net/" COPY "ddtelemetry/Cargo.toml" "ddtelemetry/" COPY "ddtelemetry-ffi/Cargo.toml" "ddtelemetry-ffi/" COPY "ddsketch/Cargo.toml" "ddsketch/"