diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..3b4650a --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,10 @@ +# Changelog + +## v1.0.0 + +- Lambda support +- Support to hyper 1.0.0 and axum 0.7.3 + +## v0.0.3 + +- Support to axum 0.6.x \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 08fdfd7..05aa786 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,43 +2,53 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "aho-corasick" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +dependencies = [ + "memchr", +] + [[package]] name = "anyhow" -version = "1.0.69" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "224afbd727c3d6e4b90103ece64b8d1b67fbb1973b1046c2281eed3f3803f800" +checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca" [[package]] -name = "async-stream" -version = "0.3.4" +name = "assert2" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad445822218ce64be7a341abfb0b1ea43b5c23aa83902542a4542e78309d8e5e" +checksum = "eaf98d1183406dcb8f8b545e1f24829d75c1a9d35eec4b86309a22aa8b6d8e95" dependencies = [ - "async-stream-impl", - "futures-core", - "pin-project-lite", + "assert2-macros", + "is-terminal", + "yansi", ] [[package]] -name = "async-stream-impl" -version = "0.3.4" +name = "assert2-macros" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4655ae1a7b0cdf149156f780c5bf3f1352bc53cbd9e0a361a7ef7b22947e965" +checksum = "6c55bdf3e6f792f8f1c750bb6886b7ca40fa5a354ddb7a4dee550b93985a9235" dependencies = [ "proc-macro2", "quote", + "rustc_version", "syn 1.0.109", ] [[package]] name = "async-trait" -version = "0.1.66" +version = "0.1.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b84f9ebcc6c1f5b8cb160f6990096a5c127f423fcb6e1ccc46c370cbdfb75dfc" +checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.48", ] [[package]] @@ -49,18 +59,47 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "axum" -version = "0.6.11" +version = "0.6.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" +dependencies = [ + "async-trait", + "axum-core 0.3.4", + "bitflags 1.3.2", + "bytes", + "futures-util", + "http 0.2.9", + "http-body 0.4.5", + "hyper 0.14.25", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "sync_wrapper", + "tower", + "tower-layer", + "tower-service", +] + +[[package]] +name = "axum" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13d8068b6ccb8b34db9de397c7043f91db8b4c66414952c6db944f238c4d3db3" +checksum = "1236b4b292f6c4d6dc34604bb5120d85c3fe1d1aa596bd5cc52ca054d13e7b9e" dependencies = [ "async-trait", - "axum-core", - "bitflags", + "axum-core 0.4.3", "bytes", "futures-util", - "http", - "http-body", - "hyper", + "http 1.0.0", + "http-body 1.0.0", + "http-body-util", + "hyper 1.1.0", + "hyper-util", "itoa", "matchit", "memchr", @@ -77,19 +116,20 @@ dependencies = [ "tower", "tower-layer", "tower-service", + "tracing", ] [[package]] name = "axum-core" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2f958c80c248b34b9a877a643811be8dbca03ca5ba827f2b63baf3a81e5fc4e" +checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c" dependencies = [ "async-trait", "bytes", "futures-util", - "http", - "http-body", + "http 0.2.9", + "http-body 0.4.5", "mime", "rustversion", "tower-layer", @@ -97,30 +137,26 @@ dependencies = [ ] [[package]] -name = "axum-tracing-opentelemetry" -version = "0.9.0" +name = "axum-core" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a43f5b506fc945900d08e541de14b5b9c82860637702ae082888b0fc2654d86" +checksum = "a15c63fd72d41492dc4f497196f5da1fb04fb7529e631d73630d1b491e47a2e3" dependencies = [ - "axum", - "futures", - "http", - "opentelemetry", - "opentelemetry-otlp", - "opentelemetry-semantic-conventions", - "opentelemetry-zipkin", - "tower", - "tower-http", + "async-trait", + "bytes", + "futures-util", + "http 1.0.0", + "http-body 1.0.0", + "http-body-util", + "mime", + "pin-project-lite", + "rustversion", + "sync_wrapper", + "tower-layer", + "tower-service", "tracing", - "tracing-opentelemetry", ] -[[package]] -name = "base64" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" - [[package]] name = "base64" version = "0.21.0" @@ -133,6 +169,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" + [[package]] name = "bumpalo" version = "3.12.0" @@ -192,24 +234,11 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "dashmap" -version = "5.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "907076dfda823b0b36d2a1bb5f90c96660a5bbcd7729e10727f07858f22c4edc" -dependencies = [ - "cfg-if", - "hashbrown", - "lock_api", - "once_cell", - "parking_lot_core", -] - [[package]] name = "either" -version = "1.8.1" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" [[package]] name = "encoding_rs" @@ -220,6 +249,12 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + [[package]] name = "errno" version = "0.2.8" @@ -231,6 +266,16 @@ dependencies = [ "winapi", ] +[[package]] +name = "errno" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + [[package]] name = "errno-dragonfly" version = "0.1.2" @@ -250,12 +295,6 @@ dependencies = [ "instant", ] -[[package]] -name = "fixedbitset" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" - [[package]] name = "fnv" version = "1.0.7" @@ -288,9 +327,9 @@ dependencies = [ [[package]] name = "futures" -version = "0.3.27" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "531ac96c6ff5fd7c62263c5e3c67a603af4fcaee2e1a0ae5565ba3a11e69e549" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" dependencies = [ "futures-channel", "futures-core", @@ -303,9 +342,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.27" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "164713a5a0dcc3e7b4b1ed7d3b433cabc18025386f9339346e8daf15963cf7ac" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" dependencies = [ "futures-core", "futures-sink", @@ -313,15 +352,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.27" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86d7a0c1aa76363dac491de0ee99faf6941128376f1cf96f07db7603b7de69dd" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" [[package]] name = "futures-executor" -version = "0.3.27" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1997dd9df74cdac935c76252744c1ed5794fac083242ea4fe77ef3ed60ba0f83" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" dependencies = [ "futures-core", "futures-task", @@ -330,38 +369,44 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.27" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89d422fa3cbe3b40dca574ab087abb5bc98258ea57eea3fd6f1fa7162c778b91" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" [[package]] name = "futures-macro" -version = "0.3.27" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3eb14ed937631bd8b8b8977f2c198443447a8355b6e3ca599f38c975e5a963b6" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.48", ] [[package]] name = "futures-sink" -version = "0.3.27" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec93083a4aecafb2a80a885c9de1f0ccae9dbd32c2bb54b0c3a65690e0b8d2f2" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" [[package]] name = "futures-task" -version = "0.3.27" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd65540d33b37b16542a0438c12e6aeead10d4ac5d05bd3f805b8f35ab592879" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" + +[[package]] +name = "futures-timer" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" [[package]] name = "futures-util" -version = "0.3.27" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ef6b17e481503ec85211fed8f39d1970f128935ca1f814cd32ac4a6842e84ab" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ "futures-channel", "futures-core", @@ -386,6 +431,12 @@ dependencies = [ "wasi", ] +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + [[package]] name = "h2" version = "0.3.16" @@ -397,8 +448,27 @@ dependencies = [ "futures-core", "futures-sink", "futures-util", - "http", - "indexmap", + "http 0.2.9", + "indexmap 1.9.2", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "h2" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1d308f63daf4181410c242d34c11f928dcb3aa105852019e043c9d1f4e4368a" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http 1.0.0", + "indexmap 2.1.0", "slab", "tokio", "tokio-util", @@ -412,10 +482,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] -name = "heck" -version = "0.4.1" +name = "hashbrown" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" [[package]] name = "hermit-abi" @@ -426,6 +496,12 @@ dependencies = [ "libc", ] +[[package]] +name = "hermit-abi" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" + [[package]] name = "http" version = "0.2.9" @@ -437,6 +513,17 @@ dependencies = [ "itoa", ] +[[package]] +name = "http" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b32afd38673a8016f7c9ae69e5af41a58f81b1d31689040f2f1959594ce194ea" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + [[package]] name = "http-body" version = "0.4.5" @@ -444,15 +531,32 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" dependencies = [ "bytes", - "http", + "http 0.2.9", "pin-project-lite", ] [[package]] -name = "http-range-header" -version = "0.3.0" +name = "http-body" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bfe8eed0a9285ef776bb792479ea3834e8b94e13d615c2f66d03dd50a435a29" +checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" +dependencies = [ + "bytes", + "http 1.0.0", +] + +[[package]] +name = "http-body-util" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41cb79eb393015dadd30fc252023adb0b2400a0caee0fa2a077e6e21a551e840" +dependencies = [ + "bytes", + "futures-util", + "http 1.0.0", + "http-body 1.0.0", + "pin-project-lite", +] [[package]] name = "httparse" @@ -476,27 +580,47 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "h2", - "http", - "http-body", + "h2 0.3.16", + "http 0.2.9", + "http-body 0.4.5", "httparse", "httpdate", "itoa", "pin-project-lite", - "socket2", + "socket2 0.4.9", "tokio", "tower-service", "tracing", "want", ] +[[package]] +name = "hyper" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5aa53871fc917b1a9ed87b683a5d86db645e23acb32c2e0785a353e522fb75" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "h2 0.4.0", + "http 1.0.0", + "http-body 1.0.0", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "tokio", + "want", +] + [[package]] name = "hyper-timeout" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" dependencies = [ - "hyper", + "hyper 0.14.25", "pin-project-lite", "tokio", "tokio-io-timeout", @@ -509,12 +633,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" dependencies = [ "bytes", - "hyper", + "hyper 0.14.25", "native-tls", "tokio", "tokio-native-tls", ] +[[package]] +name = "hyper-util" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdea9aac0dbe5a9240d68cfd9501e2db94222c6dc06843e06640b9e07f0fdc67" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http 1.0.0", + "http-body 1.0.0", + "hyper 1.1.0", + "pin-project-lite", + "socket2 0.5.5", + "tokio", + "tracing", +] + [[package]] name = "idna" version = "0.3.0" @@ -532,7 +674,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" dependencies = [ "autocfg", - "hashbrown", + "hashbrown 0.12.3", +] + +[[package]] +name = "indexmap" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" +dependencies = [ + "equivalent", + "hashbrown 0.14.3", ] [[package]] @@ -560,6 +712,17 @@ version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "30e22bd8629359895450b59ea7a776c850561b96a3b1d31321c1949d9e6c9146" +[[package]] +name = "is-terminal" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bad00257d07be169d870ab665980b06cdb366d792ad690bf2e76876dc503455" +dependencies = [ + "hermit-abi 0.3.3", + "rustix 0.38.28", + "windows-sys 0.52.0", +] + [[package]] name = "itertools" version = "0.10.5" @@ -577,9 +740,9 @@ checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" [[package]] name = "js-sys" -version = "0.3.61" +version = "0.3.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" +checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca" dependencies = [ "wasm-bindgen", ] @@ -592,9 +755,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.140" +version = "0.2.152" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" +checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" [[package]] name = "linux-raw-sys" @@ -603,14 +766,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" [[package]] -name = "lock_api" -version = "0.4.9" +name = "linux-raw-sys" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" -dependencies = [ - "autocfg", - "scopeguard", -] +checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" [[package]] name = "log" @@ -627,7 +786,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" dependencies = [ - "regex-automata", + "regex-automata 0.1.10", ] [[package]] @@ -660,12 +819,6 @@ dependencies = [ "windows-sys 0.45.0", ] -[[package]] -name = "multimap" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" - [[package]] name = "native-tls" version = "0.2.11" @@ -684,13 +837,32 @@ dependencies = [ "tempfile", ] +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", +] + +[[package]] +name = "num-traits" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +dependencies = [ + "autocfg", +] + [[package]] name = "num_cpus" version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" dependencies = [ - "hermit-abi", + "hermit-abi 0.2.6", "libc", ] @@ -706,7 +878,7 @@ version = "0.10.45" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b102428fd03bc5edf97f62620f7298614c45cedf287c271e7ed450bbaf83f2e1" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cfg-if", "foreign-types", "libc", @@ -747,40 +919,47 @@ dependencies = [ [[package]] name = "opentelemetry" -version = "0.18.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69d6c3d7288a106c0a363e4b0e8d308058d56902adefb16f4936f417ffef086e" +checksum = "1e32339a5dc40459130b3bd269e9892439f55b33e772d2a9d402a789baaf4e8a" dependencies = [ - "opentelemetry_api 0.18.0", - "opentelemetry_sdk", + "futures-core", + "futures-sink", + "indexmap 2.1.0", + "js-sys", + "once_cell", + "pin-project-lite", + "thiserror", + "urlencoding", ] [[package]] name = "opentelemetry-http" -version = "0.7.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1edc79add46364183ece1a4542592ca593e6421c60807232f5b8f7a31703825d" +checksum = "7f51189ce8be654f9b5f7e70e49967ed894e84a06fc35c6c042e64ac1fc5399e" dependencies = [ "async-trait", "bytes", - "http", - "opentelemetry_api 0.18.0", + "http 0.2.9", + "opentelemetry", "reqwest", ] [[package]] name = "opentelemetry-otlp" -version = "0.11.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1c928609d087790fc936a1067bdc310ae702bdf3b090c3f281b713622c8bbde" +checksum = "f24cda83b20ed2433c68241f918d0f6fdec8b1d43b7a9590ab4420c5095ca930" dependencies = [ "async-trait", - "futures", - "futures-util", - "http", + "futures-core", + "http 0.2.9", "opentelemetry", "opentelemetry-http", "opentelemetry-proto", + "opentelemetry-semantic-conventions", + "opentelemetry_sdk", "prost", "thiserror", "tokio", @@ -789,40 +968,39 @@ dependencies = [ [[package]] name = "opentelemetry-proto" -version = "0.1.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d61a2f56df5574508dd86aaca016c917489e589ece4141df1b5e349af8d66c28" +checksum = "a2e155ce5cc812ea3d1dffbd1539aed653de4bf4882d60e6e04dcf0901d674e1" dependencies = [ - "futures", - "futures-util", "opentelemetry", + "opentelemetry_sdk", "prost", "tonic", - "tonic-build", ] [[package]] name = "opentelemetry-semantic-conventions" -version = "0.10.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b02e0230abb0ab6636d18e2ba8fa02903ea63772281340ccac18e0af3ec9eeb" +checksum = "f5774f1ef1f982ef2a447f6ee04ec383981a3ab99c8e77a1a7b30182e65bbc84" dependencies = [ "opentelemetry", ] [[package]] name = "opentelemetry-zipkin" -version = "0.16.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bd6a5d672fe50f682d801f6737a54a633834cf8c91be419c0c9cae8ac85bf4d" +checksum = "9c2bee3ec1be4d0088378e0eb1dd54c113cbd7ec5622cc4f26181debf1d4d7b5" dependencies = [ "async-trait", "futures-core", - "http", + "http 0.2.9", "once_cell", "opentelemetry", "opentelemetry-http", "opentelemetry-semantic-conventions", + "opentelemetry_sdk", "reqwest", "serde", "serde_json", @@ -832,50 +1010,35 @@ dependencies = [ [[package]] name = "opentelemetry_api" -version = "0.18.0" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c24f96e21e7acc813c7a8394ee94978929db2bcc46cf6b5014fc612bf7760c22" +checksum = "8a81f725323db1b1206ca3da8bb19874bbd3f57c3bcd59471bfb04525b265b9b" dependencies = [ - "fnv", "futures-channel", "futures-util", - "indexmap", + "indexmap 1.9.2", "js-sys", "once_cell", "pin-project-lite", "thiserror", -] - -[[package]] -name = "opentelemetry_api" -version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed41783a5bf567688eb38372f2b7a8530f5a607a4b49d38dd7573236c23ca7e2" -dependencies = [ - "futures-channel", - "futures-util", - "indexmap", - "once_cell", - "pin-project-lite", - "thiserror", "urlencoding", ] [[package]] name = "opentelemetry_sdk" -version = "0.18.0" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ca41c4933371b61c2a2f214bf16931499af4ec90543604ec828f7a625c09113" +checksum = "2f16aec8a98a457a52664d69e0091bac3a0abd18ead9b641cb00202ba4e0efe4" dependencies = [ "async-trait", "crossbeam-channel", - "dashmap", - "fnv", "futures-channel", "futures-executor", "futures-util", + "glob", "once_cell", - "opentelemetry_api 0.18.0", + "opentelemetry", + "ordered-float", "percent-encoding", "rand", "thiserror", @@ -884,33 +1047,25 @@ dependencies = [ ] [[package]] -name = "parking_lot_core" -version = "0.9.7" +name = "ordered-float" +version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" +checksum = "a76df7075c7d4d01fdcb46c912dd17fba5b60c78ea480b475f2b6ab6f666584e" dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-sys 0.45.0", + "num-traits", ] [[package]] -name = "percent-encoding" -version = "2.2.0" +name = "overload" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" [[package]] -name = "petgraph" -version = "0.6.3" +name = "percent-encoding" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dd7d28ee937e54fe3080c91faa1c3a46c06de6252988a7f4592ba2310ef22a4" -dependencies = [ - "fixedbitset", - "indexmap", -] +checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" [[package]] name = "pin-project" @@ -956,62 +1111,30 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" -[[package]] -name = "prettyplease" -version = "0.1.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ebcd279d20a4a0a2404a33056388e950504d891c855c7975b9a8fef75f3bf04" -dependencies = [ - "proc-macro2", - "syn 1.0.109", -] - [[package]] name = "proc-macro2" -version = "1.0.52" +version = "1.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d0e1ae9e836cc3beddd63db0df682593d7e2d3d891ae8c9083d2113e1744224" +checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c" dependencies = [ "unicode-ident", ] [[package]] name = "prost" -version = "0.11.8" +version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e48e50df39172a3e7eb17e14642445da64996989bc212b583015435d39a58537" +checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd" dependencies = [ "bytes", "prost-derive", ] -[[package]] -name = "prost-build" -version = "0.11.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c828f93f5ca4826f97fedcbd3f9a536c16b12cff3dbbb4a007f932bbad95b12" -dependencies = [ - "bytes", - "heck", - "itertools", - "lazy_static", - "log", - "multimap", - "petgraph", - "prettyplease", - "prost", - "prost-types", - "regex", - "syn 1.0.109", - "tempfile", - "which", -] - [[package]] name = "prost-derive" -version = "0.11.8" +version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ea9b0f8cbe5e15a8a042d030bd96668db28ecb567ec37d691971ff5731d2b1b" +checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4" dependencies = [ "anyhow", "itertools", @@ -1020,20 +1143,11 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "prost-types" -version = "0.11.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "379119666929a1afd7a043aa6cf96fa67a6dce9af60c88095a4686dbce4c9c88" -dependencies = [ - "prost", -] - [[package]] name = "quote" -version = "1.0.26" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] @@ -1074,16 +1188,19 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] name = "regex" -version = "1.7.1" +version = "1.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" +checksum = "12de2eff854e5fa4b1295edd650e227e9d8fb0c9e90b12e7f36d6a6811791a29" dependencies = [ - "regex-syntax", + "aho-corasick", + "memchr", + "regex-automata 0.3.7", + "regex-syntax 0.7.5", ] [[package]] @@ -1092,7 +1209,18 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" dependencies = [ - "regex-syntax", + "regex-syntax 0.6.28", +] + +[[package]] +name = "regex-automata" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49530408a136e16e5b486e883fbb6ba058e8e4e8ae6621a77b048b314336e629" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax 0.7.5", ] [[package]] @@ -1101,21 +1229,33 @@ version = "0.6.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" +[[package]] +name = "regex-syntax" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" + +[[package]] +name = "relative-path" +version = "1.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e898588f33fdd5b9420719948f9f2a32c922a246964576f71ba7f24f80610fbc" + [[package]] name = "reqwest" version = "0.11.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "21eed90ec8570952d53b772ecf8f206aa1ec9a3d76b2521c56c42973f2d91ee9" dependencies = [ - "base64 0.21.0", + "base64", "bytes", "encoding_rs", "futures-core", "futures-util", - "h2", - "http", - "http-body", - "hyper", + "h2 0.3.16", + "http 0.2.9", + "http-body 0.4.5", + "hyper 0.14.25", "hyper-tls", "ipnet", "js-sys", @@ -1138,20 +1278,71 @@ dependencies = [ "winreg", ] +[[package]] +name = "rstest" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97eeab2f3c0a199bc4be135c36c924b6590b88c377d416494288c14f2db30199" +dependencies = [ + "futures", + "futures-timer", + "rstest_macros", + "rustc_version", +] + +[[package]] +name = "rstest_macros" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d428f8247852f894ee1be110b375111b586d4fa431f6c46e64ba5a0dcccbe605" +dependencies = [ + "cfg-if", + "glob", + "proc-macro2", + "quote", + "regex", + "relative-path", + "rustc_version", + "syn 2.0.48", + "unicode-ident", +] + +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver", +] + [[package]] name = "rustix" version = "0.36.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd5c6ff11fecd55b40746d1995a02f2eb375bf8c00d192d521ee09f42bef37bc" dependencies = [ - "bitflags", - "errno", + "bitflags 1.3.2", + "errno 0.2.8", "io-lifetimes", "libc", - "linux-raw-sys", + "linux-raw-sys 0.1.4", "windows-sys 0.45.0", ] +[[package]] +name = "rustix" +version = "0.38.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316" +dependencies = [ + "bitflags 2.4.1", + "errno 0.3.8", + "libc", + "linux-raw-sys 0.4.12", + "windows-sys 0.52.0", +] + [[package]] name = "rustversion" version = "1.0.12" @@ -1173,19 +1364,13 @@ dependencies = [ "windows-sys 0.42.0", ] -[[package]] -name = "scopeguard" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" - [[package]] name = "security-framework" version = "2.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a332be01508d814fed64bf28f798a146d73792121129962fdf335bb3c49a4254" dependencies = [ - "bitflags", + "bitflags 1.3.2", "core-foundation", "core-foundation-sys", "libc", @@ -1202,31 +1387,37 @@ dependencies = [ "libc", ] +[[package]] +name = "semver" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0" + [[package]] name = "serde" -version = "1.0.163" +version = "1.0.195" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2113ab51b87a539ae008b5c6c02dc020ffa39afd2d83cffcb3f4eb2722cebec2" +checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.163" +version = "1.0.195" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c805777e3930c8883389c602315a24224bcc738b63905ef87cd1420353ea93e" +checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.12", + "syn 2.0.48", ] [[package]] name = "serde_json" -version = "1.0.96" +version = "1.0.111" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" +checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4" dependencies = [ "itoa", "ryu", @@ -1288,6 +1479,16 @@ dependencies = [ "winapi", ] +[[package]] +name = "socket2" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" +dependencies = [ + "libc", + "windows-sys 0.48.0", +] + [[package]] name = "syn" version = "1.0.109" @@ -1301,9 +1502,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.12" +version = "2.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79d9531f94112cfc3e4c8f5f02cb2b58f72c97b7efd85f70203cc6d8efda5927" +checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" dependencies = [ "proc-macro2", "quote", @@ -1318,20 +1519,30 @@ checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" [[package]] name = "telemetry-rust" -version = "0.3.0" +version = "1.0.0" dependencies = [ - "axum-tracing-opentelemetry", - "http", - "hyper", + "assert2", + "axum 0.7.4", + "futures-util", + "http 1.0.0", + "http-body-util", + "hyper 1.1.0", "opentelemetry", "opentelemetry-http", + "opentelemetry-otlp", + "opentelemetry-semantic-conventions", "opentelemetry-zipkin", - "opentelemetry_api 0.19.0", + "opentelemetry_api", + "opentelemetry_sdk", + "pin-project-lite", "rand", + "rstest", "serde", "serde_json", + "tower", "tracing", "tracing-opentelemetry", + "tracing-opentelemetry-instrumentation-sdk", "tracing-subscriber", ] @@ -1344,7 +1555,7 @@ dependencies = [ "cfg-if", "fastrand", "redox_syscall", - "rustix", + "rustix 0.36.9", "windows-sys 0.42.0", ] @@ -1406,7 +1617,7 @@ dependencies = [ "mio", "num_cpus", "pin-project-lite", - "socket2", + "socket2 0.4.9", "tokio-macros", "windows-sys 0.45.0", ] @@ -1444,9 +1655,9 @@ dependencies = [ [[package]] name = "tokio-stream" -version = "0.1.12" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fb52b74f05dbf495a8fba459fdc331812b96aa086d9eb78101fa0d4569c3313" +checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" dependencies = [ "futures-core", "pin-project-lite", @@ -1469,47 +1680,30 @@ dependencies = [ [[package]] name = "tonic" -version = "0.8.3" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f219fad3b929bef19b1f86fbc0358d35daed8f2cac972037ac0dc10bbb8d5fb" +checksum = "3082666a3a6433f7f511c7192923fa1fe07c69332d3c6a2e6bb040b569199d5a" dependencies = [ - "async-stream", "async-trait", - "axum", - "base64 0.13.1", + "axum 0.6.20", + "base64", "bytes", "futures-core", "futures-util", - "h2", - "http", - "http-body", - "hyper", + "h2 0.3.16", + "http 0.2.9", + "http-body 0.4.5", + "hyper 0.14.25", "hyper-timeout", "percent-encoding", "pin-project", "prost", - "prost-derive", "tokio", "tokio-stream", - "tokio-util", "tower", "tower-layer", "tower-service", "tracing", - "tracing-futures", -] - -[[package]] -name = "tonic-build" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bf5e9b9c0f7e0a7c027dcfaba7b2c60816c7049171f679d99ee2ff65d0de8c4" -dependencies = [ - "prettyplease", - "proc-macro2", - "prost-build", - "quote", - "syn 1.0.109", ] [[package]] @@ -1520,7 +1714,7 @@ checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" dependencies = [ "futures-core", "futures-util", - "indexmap", + "indexmap 1.9.2", "pin-project", "pin-project-lite", "rand", @@ -1532,25 +1726,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "tower-http" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f873044bf02dd1e8239e9c1293ea39dad76dc594ec16185d0a1bf31d8dc8d858" -dependencies = [ - "bitflags", - "bytes", - "futures-core", - "futures-util", - "http", - "http-body", - "http-range-header", - "pin-project-lite", - "tower-layer", - "tower-service", - "tracing", -] - [[package]] name = "tower-layer" version = "0.3.2" @@ -1565,11 +1740,10 @@ checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" [[package]] name = "tracing" -version = "0.1.37" +version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ - "cfg-if", "log", "pin-project-lite", "tracing-attributes", @@ -1578,58 +1752,64 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.23" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.48", ] [[package]] name = "tracing-core" -version = "0.1.30" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", "valuable", ] -[[package]] -name = "tracing-futures" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2" -dependencies = [ - "pin-project", - "tracing", -] - [[package]] name = "tracing-log" -version = "0.1.3" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" dependencies = [ - "lazy_static", "log", + "once_cell", "tracing-core", ] [[package]] name = "tracing-opentelemetry" -version = "0.18.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21ebb87a95ea13271332df069020513ab70bdb5637ca42d6e492dc3bbbad48de" +checksum = "c67ac25c5407e7b961fafc6f7e9aa5958fd297aada2d20fa2ae1737357e55596" dependencies = [ + "js-sys", "once_cell", "opentelemetry", + "opentelemetry_sdk", + "smallvec", "tracing", "tracing-core", "tracing-log", "tracing-subscriber", + "web-time", +] + +[[package]] +name = "tracing-opentelemetry-instrumentation-sdk" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9920abb6a3ee3a2af7d30c9ff02900f8481935d36723c3da95cf807468218e8c" +dependencies = [ + "http 1.0.0", + "opentelemetry", + "tracing", + "tracing-opentelemetry", ] [[package]] @@ -1644,11 +1824,12 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.16" +version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6176eae26dd70d0c919749377897b54a9276bd7061339665dd68777926b5a70" +checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" dependencies = [ "matchers", + "nu-ansi-term", "once_cell", "regex", "serde", @@ -1668,9 +1849,9 @@ checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" [[package]] name = "typed-builder" -version = "0.9.1" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a46ee5bd706ff79131be9c94e7edcb82b703c487766a114434e5790361cf08c5" +checksum = "6179333b981641242a768f30f371c9baccbfcc03749627000c500ab88bf4528b" dependencies = [ "proc-macro2", "quote", @@ -1745,9 +1926,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.84" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" +checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -1755,16 +1936,16 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.84" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" +checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.48", "wasm-bindgen-shared", ] @@ -1782,9 +1963,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.84" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" +checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1792,22 +1973,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.84" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" +checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.48", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.84" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" +checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f" [[package]] name = "web-sys" @@ -1820,14 +2001,13 @@ dependencies = [ ] [[package]] -name = "which" -version = "4.4.0" +name = "web-time" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2441c784c52b289a054b7201fc93253e288f094e2f4be9058343127c4226a269" +checksum = "aa30049b1c872b72c89866d458eae9f20380ab280ffd1b1e18df2d3e2d98cfe0" dependencies = [ - "either", - "libc", - "once_cell", + "js-sys", + "wasm-bindgen", ] [[package]] @@ -1858,13 +2038,13 @@ version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", ] [[package]] @@ -1873,7 +2053,25 @@ version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" dependencies = [ - "windows-targets", + "windows-targets 0.42.2", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.0", ] [[package]] @@ -1882,13 +2080,43 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +dependencies = [ + "windows_aarch64_gnullvm 0.52.0", + "windows_aarch64_msvc 0.52.0", + "windows_i686_gnu 0.52.0", + "windows_i686_msvc 0.52.0", + "windows_x86_64_gnu 0.52.0", + "windows_x86_64_gnullvm 0.52.0", + "windows_x86_64_msvc 0.52.0", ] [[package]] @@ -1897,42 +2125,126 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" + [[package]] name = "windows_aarch64_msvc" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" + [[package]] name = "windows_i686_gnu" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" + [[package]] name = "windows_i686_msvc" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" + [[package]] name = "windows_x86_64_gnu" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" + [[package]] name = "windows_x86_64_gnullvm" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" + [[package]] name = "windows_x86_64_msvc" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" + [[package]] name = "winreg" version = "0.10.1" @@ -1941,3 +2253,9 @@ checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" dependencies = [ "winapi", ] + +[[package]] +name = "yansi" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" diff --git a/Cargo.toml b/Cargo.toml index a7175eb..96e732c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,46 +1,64 @@ [package] name = "telemetry-rust" -version = "0.3.0" +version = "1.0.0" edition = "2021" license = "MIT" description = "Open Telemetry fox Axum and Tracing" [dependencies] -http = "0.2.9" -axum-tracing-opentelemetry = { version = "0.9.0", features = ["otlp", "zipkin"] } -opentelemetry = { version = "0.18", features = ["rt-tokio"] } -tracing-opentelemetry = "0.18" -opentelemetry-http = "0.7.0" -opentelemetry-zipkin = "0.16" -tracing = { version = "0.1.37", default-features = false } -tracing-subscriber = { version = "0.3", default-features = false, features = [ +http = "1.0.0" +opentelemetry = { version = "0.21.0", default-features = false, features = [ + "trace", +] } +tracing-opentelemetry = "0.22" +opentelemetry-http = "0.10.0" +opentelemetry-otlp = { version = "0.14", optional = true, features = ["http-proto"] } +opentelemetry-zipkin = { version = "0.19", features = [], optional = true } +opentelemetry_sdk = { version = "0.21", default-features = false, features = [ + "rt-tokio", +] } +opentelemetry-semantic-conventions = { version = "0.13", optional = true } +tracing-opentelemetry-instrumentation-sdk = { version = "0.16.0", features = ["http"], optional = true } +tracing = { version = "0.1.40", default-features = false } +tracing-subscriber = { version = "0.3.18", default-features = false, features = [ "env-filter", "fmt", "json", + "ansi" ] } -serde = { version = "1.0.163", features = ["derive"], optional = true } -serde_json = { version = "1.0.81", optional = true } -opentelemetry_api = { version = "0.19.0", features = ["testing"], optional = true } +serde = { version = "1.0.195", features = ["derive"], optional = true } +serde_json = { version = "1.0.111", optional = true } +opentelemetry_api = { version = "0.20.0", features = ["testing"], optional = true } rand = { version = "0.8.5", optional = true } -hyper = { version = "0.14.24", features = ["full"], optional = true } +tower = { version = "0.4", optional = true } +axum = { version = "0.7.4", optional = true } +pin-project-lite = { version = "0.2", optional = true } +futures-util = { version = "0.3", default_features = false, features = [], optional = true } +hyper = { version = "1.1.0", default-features = false, features = ["http1", "client"], optional = true } +http-body-util = { version = "0.1.0", optional = true } + +[dev-dependencies] +assert2 = "0.3" +rstest = "0.18" [features] full = ["integration_test"] -default = [] -integration_test = ["serde", "serde_json", "opentelemetry_api", "rand", "hyper"] +default = ["otlp", "zipkin"] +zipkin = ["dep:opentelemetry-zipkin"] +otlp = ["opentelemetry-otlp/http-proto", "tracer", "dep:tracing-opentelemetry-instrumentation-sdk"] +tracer = ["dep:opentelemetry-semantic-conventions"] +integration_test = ["axum", "dep:serde", "dep:serde_json", "dep:opentelemetry_api", "dep:rand", "dep:hyper", "dep:http-body-util"] +axum = ["dep:axum", "dep:tower", "dep:futures-util", "dep:pin-project-lite", "dep:tracing-opentelemetry-instrumentation-sdk"] [profile.dev] lto = false -# https://jakedeichert.com/blog/reducing-rust-incremental-compilation-times-on-macos-by-70-percent/ split-debuginfo = "unpacked" -# Use slightly better optimizations opt-level = 0 -# Disable integer overflow checks overflow-checks = false [profile.release] opt-level = 's' -incremental = true +incremental = false lto = true # The Rust compiler splits your crate into multiple codegen units to parallelize (and thus speed up) compilation. However, this might cause it to miss some potential optimizations. codegen-units = 1 diff --git a/README.md b/README.md index 03a1042..534207a 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,19 @@ # telemetry-rust -Telemetry rust provides all logic setled up for start tracing and also TraceLayer provided by [axum-tracing-opentelemetry](https://github.com/davidB/axum-tracing-opentelemetry) - ```rust use tracing::Level::INFO; -use telemetry_rust::{init_tracing, opentelemetry_tracing_layer}; +// middleware::axum is available if feature flag axum is on +use telemetry_rust::{init_tracing, middleware::axum::{ + OtelAxumLayer, OtelInResponseLayer +}; + +#[tracing::instrument] +async fn route_otel() -> impl axum::response::IntoResponse { + let trace_id = + telemetry_rust::tracing_opentelemetry_instrumentation_sdk::find_current_trace_id(); + dbg!(&trace_id); + axum::Json(serde_json::json!({ "trace-id": trace_id })) +} #[tokio::main] async fn main() { @@ -12,5 +21,13 @@ async fn main() { // ... - let app = axum::Router::new().layer(opentelemetry_tracing_layer()) + let app = axum::Router::new() + // request processed inside span + .route("/otel", axum::routing::get(route_otel)) + // include trace context as header into the response + .layer(OtelInResponseLayer::default()) + // start OpenTelemetry trace on incoming request + .layer(OtelAxumLayer::default()); + + // ... ``` diff --git a/rust-toolchain b/rust-toolchain index 832e9af..5e3a425 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.70.0 +1.73.0 diff --git a/src/filter.rs b/src/filter.rs new file mode 100644 index 0000000..bd5e93b --- /dev/null +++ b/src/filter.rs @@ -0,0 +1,39 @@ +use crate::otlp::read_otel_log_level_from_env; +use tracing::{subscriber::Interest, Level, Metadata, Subscriber}; +use tracing_subscriber::layer::{Context, Filter}; + +pub struct OtelFilter { + log_level: Level, +} + +impl OtelFilter { + pub fn new(log_level: Level) -> Self { + Self { log_level } + } + + #[inline(always)] + fn _enabled(&self, meta: &Metadata<'_>) -> bool { + meta.target() == "otel::tracing" || meta.level() <= &self.log_level + } +} + +impl Default for OtelFilter { + fn default() -> Self { + Self::new(read_otel_log_level_from_env()) + } +} + +impl Filter for OtelFilter { + #[inline] + fn enabled(&self, meta: &Metadata<'_>, _: &Context<'_, S>) -> bool { + self._enabled(meta) + } + + fn callsite_enabled(&self, meta: &'static Metadata<'static>) -> Interest { + if self._enabled(meta) { + Interest::always() + } else { + Interest::never() + } + } +} diff --git a/src/http.rs b/src/http.rs new file mode 100644 index 0000000..509d3fe --- /dev/null +++ b/src/http.rs @@ -0,0 +1,61 @@ +// Originally retired from davidB/tracing-opentelemetry-instrumentation-sdk +// which is licensed under CC0 1.0 Universal +// https://github.com/davidB/tracing-opentelemetry-instrumentation-sdk/blob/d3609ac2cc699d3a24fbf89754053cc8e938e3bf/LICENSE + +use opentelemetry::propagation::{Extractor, Injector}; +use opentelemetry::Context; +use tracing_opentelemetry_instrumentation_sdk as otel; + +// copy from crate opentelemetry-http (to not be dependants of on 3rd: http, ...) +pub struct HeaderInjector<'a>(pub &'a mut http::HeaderMap); + +impl<'a> Injector for HeaderInjector<'a> { + /// Set a key and value in the `HeaderMap`. Does nothing if the key or value are not valid inputs. + fn set(&mut self, key: &str, value: String) { + if let Ok(name) = http::header::HeaderName::from_bytes(key.as_bytes()) { + if let Ok(val) = http::header::HeaderValue::from_str(&value) { + self.0.insert(name, val); + } + } + } +} + +pub struct HeaderExtractor<'a>(pub &'a http::HeaderMap); + +impl<'a> Extractor for HeaderExtractor<'a> { + /// Get a value for a key from the `HeaderMap`. If the value is not valid ASCII, returns None. + fn get(&self, key: &str) -> Option<&str> { + self.0.get(key).and_then(|value| value.to_str().ok()) + } + + /// Collect all the keys from the `HeaderMap`. + fn keys(&self) -> Vec<&str> { + self.0 + .keys() + .map(http::HeaderName::as_str) + .collect::>() + } +} + +pub fn inject_context_on_context(context: &Context, headers: &mut http::HeaderMap) { + let mut injector = HeaderInjector(headers); + opentelemetry::global::get_text_map_propagator(|propagator| { + propagator.inject_context(context, &mut injector); + }); +} + +pub fn inject_context(headers: &mut http::HeaderMap) { + let mut injector = HeaderInjector(headers); + opentelemetry::global::get_text_map_propagator(|propagator| { + propagator.inject_context(&otel::find_current_context(), &mut injector); + }); +} + +// If remote request has no span data the propagator defaults to an unsampled context +#[must_use] +pub fn extract_context(headers: &http::HeaderMap) -> Context { + let extractor = HeaderExtractor(headers); + opentelemetry::global::get_text_map_propagator(|propagator| { + propagator.extract(&extractor) + }) +} diff --git a/src/lib.rs b/src/lib.rs index 6000a65..0b7b11b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,48 +1,162 @@ -use std::cmp::max; +// Initialization logic was retired from https://github.com/davidB/tracing-opentelemetry-instrumentation-sdk/ +// which is licensed under CC0 1.0 Universal +// https://github.com/davidB/tracing-opentelemetry-instrumentation-sdk/blob/d3609ac2cc699d3a24fbf89754053cc8e938e3bf/LICENSE -use axum_tracing_opentelemetry::{otlp, resource::DetectResource}; -use http::header::HeaderMap; -use opentelemetry_http::HeaderInjector; -use tracing_opentelemetry::OpenTelemetrySpanExt; +use opentelemetry_sdk::{ + resource::{OsResourceDetector, ResourceDetector}, + Resource, +}; +use tracing::{level_filters::LevelFilter, Subscriber}; +use tracing_subscriber::fmt::writer::MakeWriterExt; use tracing_subscriber::{ - filter::LevelFilter, - fmt::{format::FmtSpan, writer::MakeWriterExt}, - layer::SubscriberExt, + fmt::format::FmtSpan, layer::SubscriberExt, registry::LookupSpan, Layer, }; -pub use axum_tracing_opentelemetry::opentelemetry_tracing_layer; +pub mod middleware; pub mod propagation; +pub mod http; + +#[cfg(feature = "axum")] +pub use tracing_opentelemetry_instrumentation_sdk; + +#[cfg(feature = "otlp")] +pub mod otlp; + #[cfg(feature = "integration_test")] pub mod test; +mod filter; + +#[derive(Debug, Default)] +pub struct DetectResource { + fallback_service_name: &'static str, + fallback_service_version: &'static str, +} + +impl DetectResource { + /// `service.name` is first extracted from environment variables + /// (in this order) `OTEL_SERVICE_NAME`, `SERVICE_NAME`, `APP_NAME`. + /// But a default value can be provided with this method. + + /// `service.name` is first extracted from environment variables + /// (in this order) `SERVICE_VERSION`, `APP_VERSION`. + /// But a default value can be provided with this method. + pub fn new( + fallback_service_name: &'static str, + fallback_service_version: &'static str, + ) -> Self { + DetectResource { + fallback_service_name, + fallback_service_version, + } + } + + pub fn build(self) -> Resource { + let base = Resource::default(); + let fallback = Resource::from_detectors( + std::time::Duration::from_secs(0), + vec![ + Box::new(ServiceInfoDetector { + fallback_service_name: self.fallback_service_name, + fallback_service_version: self.fallback_service_version, + }), + Box::new(OsResourceDetector), + //Box::new(ProcessResourceDetector), + ], + ); + let rsrc = base.merge(&fallback); // base has lower priority + + // Debug + rsrc.iter().for_each( + |kv| tracing::debug!(target: "otel::setup::resource", key = %kv.0, value = %kv.1), + ); + + rsrc + } +} + +#[derive(Debug)] +pub struct ServiceInfoDetector { + fallback_service_name: &'static str, + fallback_service_version: &'static str, +} + +impl ResourceDetector for ServiceInfoDetector { + fn detect(&self, _timeout: std::time::Duration) -> Resource { + let service_name = std::env::var("OTEL_SERVICE_NAME") + .or_else(|_| std::env::var("SERVICE_NAME")) + .or_else(|_| std::env::var("APP_NAME")) + .ok() + .or_else(|| Some(self.fallback_service_name.to_string())) + .map(|v| { + opentelemetry_semantic_conventions::resource::SERVICE_NAME.string(v) + }); + let service_version = std::env::var("OTEL_SERVICE_VERSION") + .or_else(|_| std::env::var("SERVICE_VERSION")) + .or_else(|_| std::env::var("APP_VERSION")) + .ok() + .or_else(|| Some(self.fallback_service_version.to_string())) + .map(|v| { + opentelemetry_semantic_conventions::resource::SERVICE_VERSION.string(v) + }); + Resource::new(vec![service_name, service_version].into_iter().flatten()) + } +} + +pub fn build_logger_text( + log_level: tracing::Level, +) -> Box + Send + Sync + 'static> +where + S: Subscriber + for<'a> LookupSpan<'a>, +{ + if cfg!(debug_assertions) { + Box::new( + tracing_subscriber::fmt::layer() + .pretty() + .with_line_number(true) + .with_thread_names(true) + .with_timer(tracing_subscriber::fmt::time::uptime()) + .with_span_events(FmtSpan::NEW | FmtSpan::CLOSE) + .with_writer(std::io::stdout.with_max_level(log_level)), + ) + } else { + Box::new( + tracing_subscriber::fmt::layer() + .json() + .with_timer(tracing_subscriber::fmt::time::uptime()) + .with_span_events(FmtSpan::NEW | FmtSpan::CLOSE) + .with_writer(std::io::stdout.with_max_level(log_level)), + ) + } +} + pub fn init_tracing_with_fallbacks( log_level: tracing::Level, fallback_service_name: &'static str, fallback_service_version: &'static str, ) { - let otel_rsrc = DetectResource::default() - .with_fallback_service_name(fallback_service_name) - .with_fallback_service_version(fallback_service_version) - .build(); + // set to debug to log detected resources, configuration read and infered + let setup_subscriber = tracing_subscriber::registry() + .with(Into::::into(log_level)) + .with(build_logger_text(log_level)); + let _guard = tracing::subscriber::set_default(setup_subscriber); + tracing::info!("init logging & tracing"); + + let otel_rsrc = + DetectResource::new(fallback_service_name, fallback_service_version).build(); let otel_tracer = otlp::init_tracer(otel_rsrc, otlp::identity).expect("setup of Tracer"); - let otel_layer = tracing_opentelemetry::layer().with_tracer(otel_tracer); opentelemetry::global::set_text_map_propagator( propagation::TextMapSplitPropagator::default(), ); - let fmt_layer = tracing_subscriber::fmt::layer() - .json() - .with_timer(tracing_subscriber::fmt::time::uptime()) - .with_span_events(FmtSpan::NEW | FmtSpan::CLOSE) - .with_writer(std::io::stdout.with_max_level(log_level)); - - let level_filter: LevelFilter = max(log_level, tracing::Level::INFO).into(); + let otel_layer = tracing_opentelemetry::layer() + .with_tracer(otel_tracer) + .with_filter(filter::OtelFilter::default()); let subscriber = tracing_subscriber::registry() - .with(fmt_layer) - .with(level_filter) + .with(build_logger_text(log_level)) .with(otel_layer); tracing::subscriber::set_global_default(subscriber).unwrap(); } @@ -58,15 +172,7 @@ macro_rules! init_tracing { }; } -pub fn inject_context(headers: &mut HeaderMap) { - let context = tracing::Span::current().context(); - let mut injector = HeaderInjector(headers); - - opentelemetry::global::get_text_map_propagator(|propagator| { - propagator.inject_context(&context, &mut injector) - }); -} - +#[inline] pub fn shutdown_signal() { opentelemetry::global::shutdown_tracer_provider(); } diff --git a/src/middleware/axum.rs b/src/middleware/axum.rs new file mode 100644 index 0000000..f5807c5 --- /dev/null +++ b/src/middleware/axum.rs @@ -0,0 +1,183 @@ +// Originally retired from davidB/tracing-opentelemetry-instrumentation-sdk +// https://github.com/davidB/tracing-opentelemetry-instrumentation-sdk/blob/d3609ac2cc699d3a24fbf89754053cc8e938e3bf/axum-tracing-opentelemetry/src/middleware/trace_extractor.rs#L53 +// which is licensed under CC0 1.0 Universal +// https://github.com/davidB/tracing-opentelemetry-instrumentation-sdk/blob/d3609ac2cc699d3a24fbf89754053cc8e938e3bf/LICENSE + +use axum::extract::MatchedPath; +use futures_util::future::BoxFuture; +use http::{Request, Response}; +use pin_project_lite::pin_project; +use std::{ + error::Error, + future::Future, + pin::Pin, + task::{Context, Poll}, +}; +use tower::{Layer, Service}; +use tracing::Span; +use tracing_opentelemetry_instrumentation_sdk::http as otel_http; + +pub type Filter = fn(&str) -> bool; + +#[derive(Default, Debug, Clone)] +pub struct OtelAxumLayer { + filter: Option, +} + +// add a builder like api +impl OtelAxumLayer { + #[must_use] + pub fn filter(self, filter: Filter) -> Self { + OtelAxumLayer { + filter: Some(filter), + } + } +} + +impl Layer for OtelAxumLayer { + /// The wrapped service + type Service = OtelAxumService; + fn layer(&self, inner: S) -> Self::Service { + OtelAxumService { + inner, + filter: self.filter, + } + } +} + +#[derive(Debug, Clone)] +pub struct OtelAxumService { + inner: S, + filter: Option, +} + +impl Service> for OtelAxumService +where + S: Service, Response = Response> + Clone + Send + 'static, + S::Error: Error + 'static, //fmt::Display + 'static, + S::Future: Send + 'static, + B: Send + 'static, +{ + type Response = S::Response; + type Error = S::Error; + // #[allow(clippy::type_complexity)] + // type Future = futures_core::future::BoxFuture<'static, Result>; + type Future = ResponseFuture; + + fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { + self.inner.poll_ready(cx) + } + + fn call(&mut self, req: Request) -> Self::Future { + use tracing_opentelemetry::OpenTelemetrySpanExt; + let span = if self.filter.map_or(true, |f| f(req.uri().path())) { + let span = otel_http::http_server::make_span_from_request(&req); + let route = http_route(&req); + let method = otel_http::http_method(req.method()); + // let client_ip = parse_x_forwarded_for(req.headers()) + // .or_else(|| { + // req.extensions() + // .get::>() + // .map(|ConnectInfo(client_ip)| Cow::from(client_ip.to_string())) + // }) + // .unwrap_or_default(); + span.record("http.route", route); + span.record("otel.name", format!("{method} {route}").trim()); + // span.record("trace_id", find_trace_id_from_tracing(&span)); + // span.record("client.address", client_ip); + span.set_parent(otel_http::extract_context(req.headers())); + span + } else { + tracing::Span::none() + }; + let future = { + let _ = span.enter(); + self.inner.call(req) + }; + ResponseFuture { + inner: future, + span, + } + } +} + +pin_project! { + /// Response future for [`Trace`]. + /// + /// [`Trace`]: super::Trace + pub struct ResponseFuture { + #[pin] + pub(crate) inner: F, + pub(crate) span: Span, + // pub(crate) start: Instant, + } +} + +impl Future for ResponseFuture +where + Fut: Future, E>>, + E: std::error::Error + 'static, +{ + type Output = Result, E>; + + fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { + let this = self.project(); + let _guard = this.span.enter(); + let result = futures_util::ready!(this.inner.poll(cx)); + otel_http::http_server::update_span_from_response_or_error(this.span, &result); + Poll::Ready(result) + } +} + +#[inline] +fn http_route(req: &Request) -> &str { + req.extensions() + .get::() + .map_or_else(|| "", |mp| mp.as_str()) +} + +#[derive(Default, Debug, Clone)] +pub struct OtelInResponseLayer; + +impl Layer for OtelInResponseLayer { + type Service = OtelInResponseService; + + fn layer(&self, inner: S) -> Self::Service { + OtelInResponseService { inner } + } +} + +#[derive(Default, Debug, Clone)] +pub struct OtelInResponseService { + inner: S, +} + +impl Service> for OtelInResponseService +where + S: Service, Response = Response> + Send + 'static, + S::Future: Send + 'static, +{ + type Response = S::Response; + type Error = S::Error; + // `BoxFuture` is a type alias for `Pin>` + type Future = BoxFuture<'static, Result>; + + fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { + self.inner.poll_ready(cx) + } + + #[allow(unused_mut)] + fn call(&mut self, mut request: Request) -> Self::Future { + let future = self.inner.call(request); + + Box::pin(async move { + let mut response = future.await?; + // inject the trace context into the response (optional but useful for debugging and client) + otel_http::inject_context( + &tracing_opentelemetry_instrumentation_sdk::find_current_context(), + response.headers_mut(), + ); + Ok(response) + }) + } +} diff --git a/src/middleware/mod.rs b/src/middleware/mod.rs new file mode 100644 index 0000000..8545ecd --- /dev/null +++ b/src/middleware/mod.rs @@ -0,0 +1,2 @@ +#[cfg(feature = "axum")] +pub mod axum; diff --git a/src/otlp.rs b/src/otlp.rs new file mode 100644 index 0000000..11171da --- /dev/null +++ b/src/otlp.rs @@ -0,0 +1,196 @@ +// Originally retired from davidB/tracing-opentelemetry-instrumentation-sdk +// which is licensed under CC0 1.0 Universal +// https://github.com/davidB/tracing-opentelemetry-instrumentation-sdk/blob/d3609ac2cc699d3a24fbf89754053cc8e938e3bf/LICENSE + +use std::{collections::HashMap, str::FromStr}; + +use opentelemetry::trace::TraceError; +use opentelemetry_otlp::SpanExporterBuilder; +use opentelemetry_sdk::{ + trace::{Sampler, Tracer}, + Resource, +}; +use tracing::Level; + +#[must_use] +pub fn identity( + v: opentelemetry_otlp::OtlpTracePipeline, +) -> opentelemetry_otlp::OtlpTracePipeline { + v +} + +// see https://opentelemetry.io/docs/reference/specification/protocol/exporter/ +pub fn init_tracer(resource: Resource, transform: F) -> Result +where + F: FnOnce( + opentelemetry_otlp::OtlpTracePipeline, + ) -> opentelemetry_otlp::OtlpTracePipeline, +{ + use opentelemetry_otlp::WithExportConfig; + + let (maybe_protocol, maybe_endpoint) = read_protocol_and_endpoint_from_env(); + let (protocol, endpoint) = + infer_protocol_and_endpoint(maybe_protocol.as_deref(), maybe_endpoint.as_deref()); + tracing::debug!(target: "otel::setup", OTEL_EXPORTER_OTLP_TRACES_ENDPOINT = endpoint); + tracing::debug!(target: "otel::setup", OTEL_EXPORTER_OTLP_TRACES_PROTOCOL = protocol); + let exporter: SpanExporterBuilder = match protocol.as_str() { + "http/protobuf" => opentelemetry_otlp::new_exporter() + .http() + .with_endpoint(endpoint) + .with_headers(read_headers_from_env()) + .into(), + _ => opentelemetry_otlp::new_exporter() + .tonic() + .with_endpoint(endpoint) + .into(), + }; + + let mut pipeline = opentelemetry_otlp::new_pipeline() + .tracing() + .with_exporter(exporter) + .with_trace_config( + opentelemetry_sdk::trace::config() + .with_resource(resource) + .with_sampler(read_sampler_from_env()), + ); + pipeline = transform(pipeline); + pipeline.install_batch(opentelemetry_sdk::runtime::Tokio) +} + +/// turn a string of "k1=v1,k2=v2,..." into an iterator of (key, value) tuples +fn parse_headers(val: &str) -> impl Iterator + '_ { + val.split(',').filter_map(|kv| { + let s = kv + .split_once('=') + .map(|(k, v)| (k.to_owned(), v.to_owned())); + s + }) +} +fn read_headers_from_env() -> HashMap { + let mut headers = HashMap::new(); + headers.extend(parse_headers( + &std::env::var("OTEL_EXPORTER_OTLP_HEADERS").unwrap_or_default(), + )); + headers.extend(parse_headers( + &std::env::var("OTEL_EXPORTER_OTLP_TRACES_HEADERS").unwrap_or_default(), + )); + headers +} +fn read_protocol_and_endpoint_from_env() -> (Option, Option) { + let maybe_endpoint = std::env::var("OTEL_EXPORTER_OTLP_TRACES_ENDPOINT") + .or_else(|_| std::env::var("OTEL_EXPORTER_OTLP_ENDPOINT")) + .ok(); + let maybe_protocol = std::env::var("OTEL_EXPORTER_OTLP_TRACES_PROTOCOL") + .or_else(|_| std::env::var("OTEL_EXPORTER_OTLP_PROTOCOL")) + .ok(); + (maybe_protocol, maybe_endpoint) +} +pub fn read_otel_log_level_from_env() -> Level { + let default_log_level = Level::INFO; + if let Ok(level_str) = std::env::var("OTEL_LOG_LEVEL") { + level_str.parse().unwrap_or(default_log_level) + } else { + default_log_level + } +} + +/// see +/// TODO log error and infered sampler +fn read_sampler_from_env() -> Sampler { + let mut name = std::env::var("OTEL_TRACES_SAMPLER") + .ok() + .unwrap_or_default() + .to_lowercase(); + let v = match name.as_str() { + "always_on" => Sampler::AlwaysOn, + "always_off" => Sampler::AlwaysOff, + "traceidratio" => Sampler::TraceIdRatioBased(read_sampler_arg_from_env(1f64)), + "parentbased_always_on" => Sampler::ParentBased(Box::new(Sampler::AlwaysOn)), + "parentbased_always_off" => Sampler::ParentBased(Box::new(Sampler::AlwaysOff)), + "parentbased_traceidratio" => Sampler::ParentBased(Box::new( + Sampler::TraceIdRatioBased(read_sampler_arg_from_env(1f64)), + )), + "jaeger_remote" => todo!("unsupported: OTEL_TRACES_SAMPLER='jaeger_remote'"), + "xray" => todo!("unsupported: OTEL_TRACES_SAMPLER='xray'"), + _ => { + name = "parentbased_always_on".to_string(); + Sampler::ParentBased(Box::new(Sampler::AlwaysOn)) + } + }; + tracing::debug!(target: "otel::setup", OTEL_TRACES_SAMPLER = ?name); + v +} + +fn read_sampler_arg_from_env(default: T) -> T +where + T: FromStr + Copy + std::fmt::Debug, +{ + //TODO Log for invalid value (how to log) + let v = std::env::var("OTEL_TRACES_SAMPLER_ARG") + .map_or(default, |s| T::from_str(&s).unwrap_or(default)); + tracing::debug!(target: "otel::setup", OTEL_TRACES_SAMPLER_ARG = ?v); + v +} + +fn infer_protocol_and_endpoint( + maybe_protocol: Option<&str>, + maybe_endpoint: Option<&str>, +) -> (String, String) { + let protocol = maybe_protocol.unwrap_or_else(|| { + if maybe_endpoint.map_or(false, |e| e.contains(":4317")) { + "grpc" + } else { + "http/protobuf" + } + }); + + let endpoint = match protocol { + "http/protobuf" => maybe_endpoint.unwrap_or("http://localhost:4318"), //Devskim: ignore DS137138 + _ => maybe_endpoint.unwrap_or("http://localhost:4317"), //Devskim: ignore DS137138 + }; + + (protocol.to_string(), endpoint.to_string()) +} + +#[cfg(test)] +mod tests { + use assert2::assert; + use rstest::rstest; + + use super::*; + + #[rstest] + #[case(None, None, "http/protobuf", "http://localhost:4318")] //Devskim: ignore DS137138 + #[case(Some("http/protobuf"), None, "http/protobuf", "http://localhost:4318")] //Devskim: ignore DS137138 + #[case(Some("grpc"), None, "grpc", "http://localhost:4317")] //Devskim: ignore DS137138 + #[case(None, Some("http://localhost:4317"), "grpc", "http://localhost:4317")] + #[case( + Some("http/protobuf"), + Some("http://localhost:4318"), //Devskim: ignore DS137138 + "http/protobuf", + "http://localhost:4318" //Devskim: ignore DS137138 + )] + #[case( + Some("http/protobuf"), + Some("https://examples.com:4318"), + "http/protobuf", + "https://examples.com:4318" + )] + #[case( + Some("http/protobuf"), + Some("https://examples.com:4317"), + "http/protobuf", + "https://examples.com:4317" + )] + fn test_infer_protocol_and_endpoint( + #[case] traces_protocol: Option<&str>, + #[case] traces_endpoint: Option<&str>, + #[case] expected_protocol: &str, + #[case] expected_endpoint: &str, + ) { + assert!( + infer_protocol_and_endpoint(traces_protocol, traces_endpoint) + == (expected_protocol.to_string(), expected_endpoint.to_string()) + ); + } +} diff --git a/src/propagation.rs b/src/propagation.rs index eea66f9..1c1b966 100644 --- a/src/propagation.rs +++ b/src/propagation.rs @@ -2,9 +2,11 @@ use opentelemetry::{ propagation::{ text_map_propagator::FieldIter, Extractor, Injector, TextMapPropagator, }, - sdk::propagation::{TextMapCompositePropagator, TraceContextPropagator}, Context, }; +use opentelemetry_sdk::propagation::{ + TextMapCompositePropagator, TraceContextPropagator, +}; use opentelemetry_zipkin::{B3Encoding, Propagator as B3Propagator}; use std::collections::BTreeSet; @@ -49,14 +51,10 @@ impl TextMapPropagator for TextMapSplitPropagator { impl Default for TextMapSplitPropagator { fn default() -> Self { let trace_context_propagator = TraceContextPropagator::new(); - let b3_single_header_propagator = - B3Propagator::with_encoding(B3Encoding::SingleHeader); - let b3_multi_header_propagator = - B3Propagator::with_encoding(B3Encoding::MultipleHeader); + let b3_propagator = B3Propagator::with_encoding(B3Encoding::SingleAndMultiHeader); let composite_propagator = TextMapCompositePropagator::new(vec![ Box::new(trace_context_propagator.clone()), - Box::new(b3_single_header_propagator), - Box::new(b3_multi_header_propagator), + Box::new(b3_propagator), ]); Self::new( diff --git a/src/test/mod.rs b/src/test/mod.rs index f1536fe..edb83d0 100644 --- a/src/test/mod.rs +++ b/src/test/mod.rs @@ -1,18 +1,19 @@ pub mod jaegar; -use hyper::{body::Bytes, header::HeaderValue, Body, Error, HeaderMap, Response}; +use http_body_util::BodyExt; +use hyper::{header::HeaderValue, HeaderMap, Response}; pub use opentelemetry_api::trace::{SpanId, TraceId}; use rand::Rng; #[derive(Debug)] pub struct TracedResponse { - resp: Response, + resp: Response, pub trace_id: TraceId, pub span_id: SpanId, } impl TracedResponse { - pub fn new(resp: Response, traceparent: Traceparent) -> Self { + pub fn new(resp: Response, traceparent: Traceparent) -> Self { Self { resp, trace_id: traceparent.trace_id, @@ -20,17 +21,14 @@ impl TracedResponse { } } - pub async fn get_bytes(&mut self) -> Result { - hyper::body::to_bytes(self.body_mut()).await - } - - pub async fn into_bytes(self) -> Result { - hyper::body::to_bytes(self.resp).await + #[cfg(feature = "axum")] + pub async fn into_axum_bytes(self) -> hyper::Result { + Ok(self.resp.into_body().collect().await?.to_bytes()) } } impl std::ops::Deref for TracedResponse { - type Target = Response; + type Target = Response; fn deref(&self) -> &Self::Target { &self.resp @@ -71,7 +69,7 @@ impl Traceparent { map.append("traceparent", HeaderValue::from_str(&value).unwrap()); } TracingHeaderKind::B3Single => { - let value = format!("{}-{}", self.trace_id, self.span_id); + let value = format!("{}-{}-1", self.trace_id, self.span_id); map.append("b3", HeaderValue::from_str(&value).unwrap()); } TracingHeaderKind::B3Multi => { @@ -83,6 +81,7 @@ impl Traceparent { "X-B3-SpanId", HeaderValue::from_str(&self.span_id.to_string()).unwrap(), ); + map.append("X-B3-Sampled", HeaderValue::from_str("1").unwrap()); } }