From 8d8e5e4df558ee2e422363b87ba9a58aa6b16e67 Mon Sep 17 00:00:00 2001 From: Luca Palmieri Date: Sun, 26 Dec 2021 16:28:03 +0100 Subject: [PATCH] Update tracing bunyan formatter and tracing-subscriber. --- Cargo.lock | 171 +++++++++++++++++++++++------------------------ Cargo.toml | 12 ++-- src/telemetry.rs | 9 ++- 3 files changed, 95 insertions(+), 97 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9d41a73..c106d02 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,15 +4,16 @@ version = 3 [[package]] name = "actix-codec" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d5dbeb2d9e51344cb83ca7cc170f1217f9fe25bfc50160e6e200b5c31c1019a" +checksum = "13895df506faee81e423febbae3a33b27fca71831b96bb3d60adf16ebcfea952" dependencies = [ "bitflags", "bytes", "futures-core", "futures-sink", "log", + "memchr", "pin-project-lite", "tokio", "tokio-util", @@ -20,14 +21,13 @@ dependencies = [ [[package]] name = "actix-http" -version = "3.0.0-beta.10" +version = "3.0.0-beta.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd38a862fa7fead2b47ee55e550982aba583ebc7365ccf0155b49934ad6f16f9" +checksum = "6294c508c1413346857838356f53f45dbfd257ea31dca19470d9ce78750a7d37" dependencies = [ "actix-codec", "actix-rt", "actix-service", - "actix-tls", "actix-utils", "ahash", "base64", @@ -39,34 +39,29 @@ dependencies = [ "encoding_rs", "flate2", "futures-core", - "futures-util", + "futures-task", "h2", "http", "httparse", + "httpdate", "itoa", "language-tags", "local-channel", "log", "mime", - "once_cell", "percent-encoding", - "pin-project", "pin-project-lite", "rand", - "regex", - "serde", "sha-1", "smallvec", - "time 0.2.27", - "tokio", "zstd", ] [[package]] name = "actix-macros" -version = "0.2.1" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2f86cd6857c135e6e9fe57b1619a88d1f94a7df34c00e11fe13e64fd3438837" +checksum = "465a6172cf69b960917811022d8f29bc0b7fa1398bc4f78b3c466673db1213b6" dependencies = [ "quote", "syn", @@ -74,9 +69,9 @@ dependencies = [ [[package]] name = "actix-router" -version = "0.5.0-beta.2" +version = "0.5.0-beta.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36b95ce0d76d1aa2f98b681702807475ade0f99bd4552546a6843a966d42ea3d" +checksum = "ddd9f117b910fbcce6e9f45092ffd4ff017785a346d09e2d4fd049f4e20384f4" dependencies = [ "bytestring", "firestorm", @@ -88,9 +83,9 @@ dependencies = [ [[package]] name = "actix-rt" -version = "2.2.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc7d7cd957c9ed92288a7c3c96af81fa5291f65247a76a34dac7b6af74e52ba0" +checksum = "05c2f80ce8d0c990941c7a7a931f69fd0701b76d521f8d36298edf59cd3fbf1f" dependencies = [ "actix-macros", "futures-core", @@ -99,18 +94,19 @@ dependencies = [ [[package]] name = "actix-server" -version = "2.0.0-beta.5" +version = "2.0.0-rc.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26369215fcc3b0176018b3b68756a8bcc275bb000e6212e454944913a1f9bf87" +checksum = "78c9b22794b8af1c2e02434873ef858f2a7db40dbbf861ce77a04cd81ac6b767" dependencies = [ "actix-rt", "actix-service", "actix-utils", "futures-core", + "futures-util", "log", - "mio", + "mio 0.8.0", "num_cpus", - "slab", + "socket2", "tokio", ] @@ -125,23 +121,6 @@ dependencies = [ "pin-project-lite", ] -[[package]] -name = "actix-tls" -version = "3.0.0-beta.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65b7bb60840962ef0332f7ea01a57d73a24d2cb663708511ff800250bbfef569" -dependencies = [ - "actix-codec", - "actix-rt", - "actix-service", - "actix-utils", - "derive_more", - "futures-core", - "http", - "log", - "tokio-util", -] - [[package]] name = "actix-utils" version = "3.0.0" @@ -154,9 +133,9 @@ dependencies = [ [[package]] name = "actix-web" -version = "4.0.0-beta.9" +version = "4.0.0-beta.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d34aa2b23ec9c7c9a799b3cf9258f67c91b18ac3f0f5f484e175c7ac46739bb5" +checksum = "4609cf57246040316642d4dc4c03d7f3d4a083a892122829dbd9e6ec8db7cd67" dependencies = [ "actix-codec", "actix-http", @@ -172,7 +151,6 @@ dependencies = [ "cfg-if", "cookie", "derive_more", - "either", "encoding_rs", "futures-core", "futures-util", @@ -182,22 +160,22 @@ dependencies = [ "mime", "once_cell", "paste", - "pin-project", + "pin-project-lite", "regex", "serde", "serde_json", "serde_urlencoded", "smallvec", "socket2", - "time 0.2.27", + "time 0.3.5", "url", ] [[package]] name = "actix-web-codegen" -version = "0.5.0-beta.4" +version = "0.5.0-beta.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a11fd6f322120a74b23327e778ef0a4950b1f44a2b76468a69316a150f5c6dd" +checksum = "30a90b7f6c2fde9a1fe3df4da758c2c3c9d620dfa3eae4da0b6925dc0a13444a" dependencies = [ "actix-router", "proc-macro2", @@ -743,9 +721,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.4" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7f3675cfef6a30c8031cf9e6493ebdc3bb3272a3fea3923c4210d1830e6a472" +checksum = "8f072413d126e57991455e0a922b31e4c8ba7c2ffbebf6b78b4f8521397d65cd" dependencies = [ "bytes", "fnv", @@ -814,9 +792,9 @@ dependencies = [ [[package]] name = "http" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "527e8c9ac747e28542699a951517aa9a6945af506cd1f2e1b53a576c17b6cc11" +checksum = "1323096b05d41827dadeaee54c9981958c0f94e670bc94ed80037d1a7b8b186b" dependencies = [ "bytes", "fnv", @@ -1024,9 +1002,9 @@ checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" [[package]] name = "matchers" -version = "0.0.1" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" dependencies = [ "regex-automata", ] @@ -1089,6 +1067,19 @@ dependencies = [ "winapi", ] +[[package]] +name = "mio" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba272f85fa0b41fc91872be579b3bbe0f56b792aa361a380eb669469f68dafb2" +dependencies = [ + "libc", + "log", + "miow", + "ntapi", + "winapi", +] + [[package]] name = "miow" version = "0.3.7" @@ -1711,9 +1702,9 @@ checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" [[package]] name = "socket2" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "765f090f0e423d2b55843402a07915add955e7d60657db13707a159727326cad" +checksum = "5dc90fe6c7be1a323296982db1836d1ea9e47b6839496dde9a541bc496df3516" dependencies = [ "libc", "winapi", @@ -1992,6 +1983,16 @@ dependencies = [ "winapi", ] +[[package]] +name = "time" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41effe7cfa8af36f439fac33861b66b049edc6f9a32331e2312660529c1c24ad" +dependencies = [ + "itoa", + "libc", +] + [[package]] name = "time-macros" version = "0.1.1" @@ -2040,15 +2041,27 @@ dependencies = [ "bytes", "libc", "memchr", - "mio", + "mio 0.7.13", "num_cpus", "once_cell", "parking_lot", "pin-project-lite", "signal-hook-registry", + "tokio-macros", "winapi", ] +[[package]] +name = "tokio-macros" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b557f72f448c511a979e2564e55d74e6c4432fc96ff4f6241bc6bded342643b7" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "tokio-native-tls" version = "0.3.0" @@ -2116,12 +2129,12 @@ dependencies = [ [[package]] name = "tracing-actix-web" -version = "0.4.0-beta.12" +version = "0.5.0-beta.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aef43d92080b0429626deba48d01dad848ad515777b373d7a18eac3f129be359" +checksum = "940f76971e1a1ca2c64e8f915aec14acbc61a5b1c1c177dedf64eb8dd41b204d" dependencies = [ "actix-web", - "futures", + "pin-project", "tracing", "tracing-futures", "uuid", @@ -2140,15 +2153,15 @@ dependencies = [ [[package]] name = "tracing-bunyan-formatter" -version = "0.1.7" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06718867c20ea03700d41a9413610cccf5d772caea792f34cc73cdd43f0e14a6" +checksum = "1cb2ad6aa9b1c637d84c54db002275bbf72a7f3c6fed80f8b33f5af0c39027e9" dependencies = [ - "chrono", "gethostname", "log", "serde", "serde_json", + "time 0.3.5", "tracing", "tracing-core", "tracing-log", @@ -2157,9 +2170,9 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.19" +version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ca517f43f0fb96e0c3072ed5c275fe5eece87e8cb52f4a77b69226d3b1c9df8" +checksum = "1f4ed65637b8390770814083d20756f87bfa2c21bf2f110babdc5438351746e4" dependencies = [ "lazy_static", ] @@ -2185,36 +2198,22 @@ dependencies = [ "tracing-core", ] -[[package]] -name = "tracing-serde" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb65ea441fbb84f9f6748fd496cf7f63ec9af5bca94dd86456978d055e8eb28b" -dependencies = [ - "serde", - "tracing-core", -] - [[package]] name = "tracing-subscriber" -version = "0.2.20" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9cbe87a2fa7e35900ce5de20220a582a9483a7063811defce79d7cbd59d4cfe" +checksum = "d5e6136799e1079699e0d9784c883e03af55cf6a1bee48fe1d79ca552c1bc36f" dependencies = [ "ansi_term", - "chrono", "lazy_static", "matchers", "regex", - "serde", - "serde_json", "sharded-slab", "smallvec", "thread_local", "tracing", "tracing-core", "tracing-log", - "tracing-serde", ] [[package]] @@ -2474,8 +2473,6 @@ dependencies = [ name = "zero2prod" version = "0.1.0" dependencies = [ - "actix-http", - "actix-rt", "actix-web", "chrono", "config", @@ -2495,18 +2492,18 @@ dependencies = [ [[package]] name = "zstd" -version = "0.7.0+zstd.1.4.9" +version = "0.9.1+zstd.1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9428752481d8372e15b1bf779ea518a179ad6c771cca2d2c60e4fbff3cc2cd52" +checksum = "538b8347df9257b7fbce37677ef7535c00a3c7bf1f81023cc328ed7fe4b41de8" dependencies = [ "zstd-safe", ] [[package]] name = "zstd-safe" -version = "3.1.0+zstd.1.4.9" +version = "4.1.2+zstd.1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa1926623ad7fe406e090555387daf73db555b948134b4d73eac5eb08fb666d" +checksum = "9fb4cfe2f6e6d35c5d27ecd9d256c4b6f7933c4895654917460ec56c29336cc1" dependencies = [ "libc", "zstd-sys", @@ -2514,9 +2511,9 @@ dependencies = [ [[package]] name = "zstd-sys" -version = "1.5.0+zstd.1.4.9" +version = "1.6.2+zstd.1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e6c094340240369025fc6b731b054ee2a834328fa584310ac96aa4baebdc465" +checksum = "2daf2f248d9ea44454bfcb2516534e8b8ad2fc91bf818a1885495fc42bc8ac9f" dependencies = [ "cc", "libc", diff --git a/Cargo.toml b/Cargo.toml index c4a61e1..cdd295d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,8 +13,8 @@ path = "src/main.rs" name = "zero2prod" [dependencies] -actix-web = "=4.0.0-beta.9" -actix-http = "=3.0.0-beta.10" +actix-web = "=4.0.0-beta.15" +tokio = { version = "1", features = ["macros", "rt-multi-thread"] } serde = "1.0.115" config = { version = "0.10.1", default-features = false, features = ["yaml"] } sqlx = { version = "0.5.5", default-features = false, features = [ "runtime-actix-rustls", "macros", "postgres", "uuid", "chrono", "migrate"] } @@ -22,13 +22,11 @@ uuid = { version = "0.8.1", features = ["v4"] } chrono = "0.4.15" tracing = "0.1.19" tracing-futures = "0.2.4" -tracing-subscriber = { version = "0.2.12", features = ["registry", "env-filter"] } -tracing-bunyan-formatter = "0.1.6" +tracing-subscriber = { version = "0.3", features = ["registry", "env-filter"] } +tracing-bunyan-formatter = "0.3.1" tracing-log = "0.1.1" -tracing-actix-web = "0.4.0-beta.12" +tracing-actix-web = "0.5.0-beta.6" [dev-dependencies] reqwest = { version = "0.11", features = ["json"] } -actix-rt = "2" -tokio = "1" once_cell = "1.7.2" diff --git a/src/telemetry.rs b/src/telemetry.rs index f8646a4..afeac0e 100644 --- a/src/telemetry.rs +++ b/src/telemetry.rs @@ -11,11 +11,14 @@ use tracing_subscriber::{layer::SubscriberExt, EnvFilter, Registry}; /// /// We are using `impl Subscriber` as return type to avoid having to spell out the actual /// type of the returned subscriber, which is indeed quite complex. -pub fn get_subscriber( +pub fn get_subscriber( name: String, env_filter: String, - sink: impl MakeWriter + Send + Sync + 'static, -) -> impl Subscriber + Sync + Send { + sink: Sink, +) -> impl Subscriber + Sync + Send +where + Sink: for<'a> MakeWriter<'a> + Send + Sync + 'static, +{ let env_filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new(env_filter)); let formatting_layer = BunyanFormattingLayer::new(name, sink);