From b9d85c64890cd0957ebbfd2902da400ce876da51 Mon Sep 17 00:00:00 2001 From: Francesco Ceccon Date: Thu, 10 Oct 2024 15:35:00 +0200 Subject: [PATCH 1/3] common: track used/available streams --- common/src/server/service.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/common/src/server/service.rs b/common/src/server/service.rs index edce8342..ed78f16e 100644 --- a/common/src/server/service.rs +++ b/common/src/server/service.rs @@ -38,6 +38,7 @@ where chain_view: tokio::sync::watch::Receiver>, fragment_id_to_name: HashMap, block_store: BlockStoreReader, + options: StreamServiceOptions, ct: CancellationToken, } @@ -60,6 +61,7 @@ where chain_view, fragment_id_to_name, block_store, + options, ct, } } @@ -67,6 +69,14 @@ where pub fn into_service(self) -> dna_stream_server::DnaStreamServer { dna_stream_server::DnaStreamServer::new(self) } + + pub fn current_stream_count(&self) -> usize { + self.options.max_concurrent_streams - self.stream_semaphore.available_permits() + } + + pub fn current_stream_available(&self) -> usize { + self.stream_semaphore.available_permits() + } } #[tonic::async_trait] @@ -78,6 +88,7 @@ where Box> + Send + 'static>, >; + #[tracing::instrument(name = "stream::status", skip_all)] async fn status( &self, _request: tonic::Request, @@ -94,10 +105,17 @@ where Ok(tonic::Response::new(response)) } + #[tracing::instrument( + name = "stream::stream_data", + skip_all, + fields(stream_count, stream_available) + )] async fn stream_data( &self, request: tonic::Request, ) -> tonic::Result, tonic::Status> { + let current_span = tracing::Span::current(); + let request = request.into_inner(); info!(request = ?request, "stream data request"); @@ -118,6 +136,9 @@ where Ok(Ok(permit)) => permit, }; + current_span.record("stream_count", self.current_stream_count()); + current_span.record("stream_available", self.current_stream_available()); + // Validate starting cursor by checking it's in range. // The block could be reorged but that's handled by the `DataStream`. let starting_cursor = if let Some(cursor) = request.starting_cursor { From e5a05566e0c789c6647ca08e9789b0a6d09b1f9d Mon Sep 17 00:00:00 2001 From: Francesco Ceccon Date: Thu, 10 Oct 2024 16:07:40 +0200 Subject: [PATCH 2/3] common: export traces from cache --- Cargo.lock | 159 ++++++++++++++++++++++----------------- Cargo.toml | 14 ++-- common/src/file_cache.rs | 8 +- observability/Cargo.toml | 2 + observability/src/lib.rs | 28 ++++++- 5 files changed, 131 insertions(+), 80 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ee2fbf01..2ed5d35c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -181,9 +181,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a289ffd7448036f2f436b377f981c79ce0b2090877bad938d43387dc09931877" +checksum = "8ecb848c43f6b06ae3de2e4a67496cbbabd78ae87db0f1248934f15d76192c6a" dependencies = [ "alloy-rlp", "bytes", @@ -375,9 +375,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0409e3ba5d1de409997a7db8b8e9d679d52088c1dee042a85033affd3cadeab4" +checksum = "661c516eb1fa3294cc7f2fb8955b3b609d639c282ac81a4eedb14d3046db503a" dependencies = [ "alloy-sol-macro-expander", "alloy-sol-macro-input", @@ -389,9 +389,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro-expander" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a18372ef450d59f74c7a64a738f546ba82c92f816597fed1802ef559304c81f1" +checksum = "ecbabb8fc3d75a0c2cea5215be22e7a267e3efde835b0f2a8922f5e3f5d47683" dependencies = [ "alloy-sol-macro-input", "const-hex", @@ -407,9 +407,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro-input" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7bad89dd0d5f109e8feeaf787a9ed7a05a91a9a0efc6687d147a70ebca8eff7" +checksum = "16517f2af03064485150d89746b8ffdcdbc9b6eeb3d536fb66efd7c2846fbc75" dependencies = [ "const-hex", "dunce", @@ -422,9 +422,9 @@ dependencies = [ [[package]] name = "alloy-sol-types" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4aa666f1036341b46625e72bd36878bf45ad0185f1b88601223e1ec6ed4b72b1" +checksum = "8e448d879903624863f608c552d10efb0e0905ddbee98b0049412799911eb062" dependencies = [ "alloy-primitives", "alloy-sol-macro", @@ -739,6 +739,8 @@ name = "apibara-observability" version = "0.1.0" dependencies = [ "error-stack", + "fastrace", + "fastrace-opentelemetry", "nu-ansi-term 0.50.1", "opentelemetry", "opentelemetry-otlp", @@ -1258,9 +1260,9 @@ dependencies = [ [[package]] name = "aws-smithy-runtime" -version = "1.7.1" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1ce695746394772e7000b39fe073095db6d45a862d0767dd5ad0ac0d7f8eb87" +checksum = "a065c0fe6fdbdf9f11817eb68582b2ab4aff9e9c39e986ae48f7ec576c6322db" dependencies = [ "aws-smithy-async", "aws-smithy-http", @@ -1756,9 +1758,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.19" +version = "4.5.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7be5744db7978a28d9df86a214130d106a89ce49644cbc4e3f0c22c3fba30615" +checksum = "b97f376d85a664d5837dbae44bf546e6477a679ff6610010f17276f686d867e8" dependencies = [ "clap_builder", "clap_derive", @@ -1766,9 +1768,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.19" +version = "4.5.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5fbc17d3ef8278f55b282b2a2e75ae6f6c7d4bb70ed3d0382375104bfafdb4b" +checksum = "19bc80abd44e4bed93ca373a0704ccbd1b710dc5749406201bb018272808dc54" dependencies = [ "anstream", "anstyle", @@ -2448,6 +2450,19 @@ dependencies = [ "syn 2.0.79", ] +[[package]] +name = "fastrace-opentelemetry" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b925484d72af8731396c372abf6a325889e8749e351db8f4c2200aaaecc50d9" +dependencies = [ + "fastrace", + "futures", + "log", + "opentelemetry", + "opentelemetry_sdk", +] + [[package]] name = "fastrand" version = "2.1.1" @@ -2563,8 +2578,9 @@ dependencies = [ [[package]] name = "foyer" -version = "0.12.0-dev" -source = "git+https://github.com/foyer-rs/foyer.git?rev=d49c480#d49c4800e264f88c53ecca038b011af99a7c82da" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28843b2b5c41f80ef7111a1f32f85bee367ad5850bd74856cd43683d13a8ae3c" dependencies = [ "ahash 0.8.11", "anyhow", @@ -2580,8 +2596,9 @@ dependencies = [ [[package]] name = "foyer-common" -version = "0.12.0-dev" -source = "git+https://github.com/foyer-rs/foyer.git?rev=d49c480#d49c4800e264f88c53ecca038b011af99a7c82da" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b32323a9267c2a0d9d3f63cf04b47131251948d5ed818e6bc6209958df9188e6" dependencies = [ "bytes", "cfg-if", @@ -2599,8 +2616,9 @@ dependencies = [ [[package]] name = "foyer-intrusive" -version = "0.12.0-dev" -source = "git+https://github.com/foyer-rs/foyer.git?rev=d49c480#d49c4800e264f88c53ecca038b011af99a7c82da" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbbeee92227c2cb4f1f34a0603e7892d50fc5b5aad64f7475422cbf7e5ff8db5" dependencies = [ "foyer-common", "itertools 0.13.0", @@ -2608,8 +2626,9 @@ dependencies = [ [[package]] name = "foyer-memory" -version = "0.12.0-dev" -source = "git+https://github.com/foyer-rs/foyer.git?rev=d49c480#d49c4800e264f88c53ecca038b011af99a7c82da" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a95d461a831def175ea35deebec580fa49d020386ca25bbfde8d321ff9cc3fa" dependencies = [ "ahash 0.8.11", "bitflags 2.6.0", @@ -2629,8 +2648,9 @@ dependencies = [ [[package]] name = "foyer-storage" -version = "0.12.0-dev" -source = "git+https://github.com/foyer-rs/foyer.git?rev=d49c480#d49c4800e264f88c53ecca038b011af99a7c82da" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71aed691c83a3008de0bdcc2f36bad787a49e4b21b294378ec9a932e8f4f4e6b" dependencies = [ "ahash 0.8.11", "allocator-api2", @@ -2649,6 +2669,7 @@ dependencies = [ "foyer-memory", "fs4", "futures", + "hashbrown 0.14.5", "itertools 0.13.0", "libc", "lz4", @@ -2913,6 +2934,8 @@ version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" dependencies = [ + "allocator-api2", + "equivalent", "foldhash", "serde", ] @@ -3342,9 +3365,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.70" +version = "0.3.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" +checksum = "0cb94a0ffd3f3ee755c20f7d8752f45cac88605a4dcf808abcff72873296ec7b" dependencies = [ "wasm-bindgen", ] @@ -3480,11 +3503,11 @@ checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "lru" -version = "0.12.4" +version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37ee39891760e7d94734f6f63fedc29a2e4a152f836120753a72503f09fcf904" +checksum = "234cf4f4a04dc1f57e24b96cc0cd600cf2af460d4161ac5ecdd0af8e1f3b2a38" dependencies = [ - "hashbrown 0.14.5", + "hashbrown 0.15.0", ] [[package]] @@ -3646,14 +3669,13 @@ dependencies = [ [[package]] name = "mio" -version = "1.0.2" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" +checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" dependencies = [ - "hermit-abi", "libc", "wasi", - "windows-sys 0.52.0", + "windows-sys 0.48.0", ] [[package]] @@ -3880,9 +3902,9 @@ dependencies = [ [[package]] name = "opentelemetry" -version = "0.24.0" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c365a63eec4f55b7efeceb724f1336f26a9cf3427b70e59e2cd2a5b947fba96" +checksum = "803801d3d3b71cd026851a53f974ea03df3d179cb758b260136a6c9e22e196af" dependencies = [ "futures-core", "futures-sink", @@ -3894,9 +3916,9 @@ dependencies = [ [[package]] name = "opentelemetry-otlp" -version = "0.17.0" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b925a602ffb916fb7421276b86756027b37ee708f9dce2dbdcc51739f07e727" +checksum = "596b1719b3cab83addb20bcbffdf21575279d9436d9ccccfe651a3bf0ab5ab06" dependencies = [ "async-trait", "futures-core", @@ -3912,9 +3934,9 @@ dependencies = [ [[package]] name = "opentelemetry-proto" -version = "0.7.0" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30ee9f20bff9c984511a02f082dc8ede839e4a9bf15cc2487c8d6fea5ad850d9" +checksum = "2c43620e8f93359eb7e627a3b16ee92d8585774986f24f2ab010817426c5ce61" dependencies = [ "opentelemetry", "opentelemetry_sdk", @@ -3924,9 +3946,9 @@ dependencies = [ [[package]] name = "opentelemetry_sdk" -version = "0.24.1" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "692eac490ec80f24a17828d49b40b60f5aeaccdfe6a503f939713afd22bc28df" +checksum = "e0da0d6b47a3dbc6e9c9e36a0520e25cf943e046843818faaa3f87365a548c82" dependencies = [ "async-trait", "futures-channel", @@ -4277,9 +4299,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.86" +version = "1.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +checksum = "b3e4daa0dcf6feba26f985457cdf104d4b4256fc5a09547140f3631bb076b19a" dependencies = [ "unicode-ident", ] @@ -5731,9 +5753,9 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3a850d65181df41b83c6be01a7d91f5e9377c43d48faa5af7d95816f437f5a3" +checksum = "20e7b52ad118b2153644eea95c6fc740b6c1555b2344fdab763fc9de4075f665" dependencies = [ "paste", "proc-macro2", @@ -5944,27 +5966,28 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.40.0" +version = "1.38.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" +checksum = "eb2caba9f80616f438e09748d5acda951967e1ea58508ef53d9c6402485a46df" dependencies = [ "backtrace", "bytes", "libc", "mio", + "num_cpus", "parking_lot", "pin-project-lite", "signal-hook-registry", "socket2", "tokio-macros", - "windows-sys 0.52.0", + "windows-sys 0.48.0", ] [[package]] name = "tokio-macros" -version = "2.4.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" +checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" dependencies = [ "proc-macro2", "quote", @@ -6225,9 +6248,9 @@ dependencies = [ [[package]] name = "tracing-opentelemetry" -version = "0.25.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9784ed4da7d921bc8df6963f8c80a0e4ce34ba6ba76668acadd3edbd985ff3b" +checksum = "5eabc56d23707ad55ba2a0750fc24767125d5a0f51993ba41ad2c441cc7b8dea" dependencies = [ "js-sys", "once_cell", @@ -6463,9 +6486,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.93" +version = "0.2.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" +checksum = "ef073ced962d62984fb38a36e5fdc1a2b23c9e0e1fa0689bb97afa4202ef6887" dependencies = [ "cfg-if", "once_cell", @@ -6474,9 +6497,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.93" +version = "0.2.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" +checksum = "c4bfab14ef75323f4eb75fa52ee0a3fb59611977fd3240da19b2cf36ff85030e" dependencies = [ "bumpalo", "log", @@ -6489,9 +6512,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.43" +version = "0.4.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61e9300f63a621e96ed275155c108eb6f843b6a26d053f122ab69724559dc8ed" +checksum = "65471f79c1022ffa5291d33520cbbb53b7687b01c2f8e83b57d102eed7ed479d" dependencies = [ "cfg-if", "js-sys", @@ -6501,9 +6524,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.93" +version = "0.2.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" +checksum = "a7bec9830f60924d9ceb3ef99d55c155be8afa76954edffbb5936ff4509474e7" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -6511,9 +6534,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.93" +version = "0.2.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" +checksum = "4c74f6e152a76a2ad448e223b0fc0b6b5747649c3d769cc6bf45737bf97d0ed6" dependencies = [ "proc-macro2", "quote", @@ -6524,15 +6547,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.93" +version = "0.2.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" +checksum = "a42f6c679374623f295a8623adfe63d9284091245c3504bde47c17a3ce2777d9" [[package]] name = "web-sys" -version = "0.3.70" +version = "0.3.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26fdeaafd9bd129f65e7c031593c24d62186301e0c72c8978fa1678be7d532c0" +checksum = "44188d185b5bdcae1052d08bcbcf9091a5524038d4572cc4f4f2bb9d5554ddd9" dependencies = [ "js-sys", "wasm-bindgen", diff --git a/Cargo.toml b/Cargo.toml index 31559376..222fd1a2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,18 +42,20 @@ ctrlc = { version = "3.4.5", features = ["termination"] } dirs = "5.0.1" error-stack = "0.5.0" etcd-client = { version = "0.14.0", features = ["tls", "tls-roots"] } -foyer = { git = "https://github.com/foyer-rs/foyer.git", rev = "d49c480" } # 0.12-dev +fastrace = "0.7" +fastrace-opentelemetry = "0.7" +foyer = { version = "0.12.1", features = ["tracing"] } futures = "0.3.30" hex = { version = "0.4.3", features = ["serde"] } memmap2 = "0.9.4" mimalloc = "0.1.43" -opentelemetry = { version = "0.24.0", features = ["trace", "metrics"] } -opentelemetry_sdk = { version = "0.24.1", features = [ +opentelemetry = { version = "0.25", features = ["trace", "metrics"] } +opentelemetry_sdk = { version = "0.25", features = [ "trace", "metrics", "rt-tokio", ] } -opentelemetry-otlp = { version = "0.17.0", features = [ +opentelemetry-otlp = { version = "0.25", features = [ "trace", "metrics", "grpc-tonic", @@ -75,7 +77,7 @@ tempfile = "3.13.0" tempdir = "0.3.7" testcontainers = "0.22.0" time = { version = "0.3.36", features = ["formatting", "local-offset"] } -tokio = { version = "1.39.2", features = ["full"] } +tokio = { version = "1.38", features = ["full"] } tokio-stream = { version = "0.1.15", features = ["sync", "net"] } tokio-util = "0.7.11" tonic = { version = "0.12.1", features = ["tls", "tls-roots", "prost"] } @@ -87,7 +89,7 @@ tracing = { version = "0.1.40", features = [ "release_max_level_debug", "valuable", ] } -tracing-opentelemetry = "0.25.0" +tracing-opentelemetry = "0.26" tracing-subscriber = { version = "0.3.18", features = [ "std", "env-filter", diff --git a/common/src/file_cache.rs b/common/src/file_cache.rs index 9538f9d5..5718185a 100644 --- a/common/src/file_cache.rs +++ b/common/src/file_cache.rs @@ -6,7 +6,7 @@ use error_stack::{Result, ResultExt}; use foyer::{ AdmissionPicker, AdmitAllPicker, CacheEntry, Compression, DirectFsDeviceOptions, Engine, HybridCache, HybridCacheBuilder, HybridFetch, LargeEngineOptions, RateLimitPicker, RecoverMode, - RuntimeConfig, TokioRuntimeConfig, + RuntimeOptions, TokioRuntimeOptions, }; #[derive(Debug)] @@ -168,12 +168,12 @@ impl FileCacheArgs { .storage(Engine::Large) .with_compression(compression) .with_admission_picker(admission_picker) - .with_runtime_config(RuntimeConfig::Separated { - read_runtime_config: TokioRuntimeConfig { + .with_runtime_options(RuntimeOptions::Separated { + read_runtime_options: TokioRuntimeOptions { worker_threads: self.cache_runtime_read_threads, max_blocking_threads: self.cache_runtime_read_threads * 2, }, - write_runtime_config: TokioRuntimeConfig { + write_runtime_options: TokioRuntimeOptions { worker_threads: self.cache_runtime_write_threads, max_blocking_threads: self.cache_runtime_write_threads * 2, }, diff --git a/observability/Cargo.toml b/observability/Cargo.toml index 5d8e96cf..946c63e9 100644 --- a/observability/Cargo.toml +++ b/observability/Cargo.toml @@ -8,6 +8,8 @@ license.workspace = true [dependencies] error-stack.workspace = true +fastrace.workspace = true +fastrace-opentelemetry.workspace = true nu-ansi-term = "0.50.1" opentelemetry.workspace = true opentelemetry-otlp.workspace = true diff --git a/observability/src/lib.rs b/observability/src/lib.rs index 424b1397..b2ef3d8c 100644 --- a/observability/src/lib.rs +++ b/observability/src/lib.rs @@ -3,10 +3,14 @@ mod dna_fmt; use std::borrow::Cow; +use std::time::Duration; use error_stack::{Result, ResultExt}; -use opentelemetry::global; -use opentelemetry::trace::TracerProvider; +use fastrace::collector::Config; +use fastrace_opentelemetry::OpenTelemetryReporter; +use opentelemetry::trace::{SpanKind, TracerProvider}; +use opentelemetry::{global, InstrumentationLibrary}; +use opentelemetry_sdk::resource::{ResourceDetector, SdkProvidedResourceDetector}; use tracing::Subscriber; pub use opentelemetry::metrics::{ObservableCounter, ObservableGauge}; @@ -83,10 +87,30 @@ where S: Subscriber + Send + Sync, for<'a> S: LookupSpan<'a>, { + let package_name = package_name.into(); + let version = version.into(); + // filter traces by crate/level let otel_env_filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("INFO")); + let exporter = opentelemetry_otlp::new_exporter() + .tonic() + .build_span_exporter() + .change_context(OpenTelemetryInitError) + .attach_printable("failed to create span exporter")?; + let resource = SdkProvidedResourceDetector.detect(Duration::from_secs(1)); + let instrumentation_lib = InstrumentationLibrary::builder(package_name.clone()) + .with_version(version.clone()) + .build(); + let reporter = OpenTelemetryReporter::new( + exporter, + SpanKind::Server, + Cow::Owned(resource), + instrumentation_lib, + ); + fastrace::set_reporter(reporter, Config::default()); + // Both tracer and meter are configured with environment variables. let meter = opentelemetry_otlp::new_pipeline() .metrics(opentelemetry_sdk::runtime::Tokio) From 8b2d3019c285cbf8195768c3cbab35b2ffd7feb1 Mon Sep 17 00:00:00 2001 From: Francesco Ceccon Date: Thu, 10 Oct 2024 16:10:33 +0200 Subject: [PATCH 3/3] release: dna-{beaconchain,evm,starknet} 2.0.0-beta.2 --- Cargo.lock | 6 +++--- beaconchain/Cargo.toml | 2 +- evm/Cargo.toml | 2 +- starknet/Cargo.toml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2ed5d35c..868e4c3a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -558,7 +558,7 @@ dependencies = [ [[package]] name = "apibara-dna-beaconchain" -version = "2.0.0-beta.1" +version = "2.0.0-beta.2" dependencies = [ "alloy-consensus", "alloy-eips", @@ -630,7 +630,7 @@ dependencies = [ [[package]] name = "apibara-dna-evm" -version = "2.0.0-beta.1" +version = "2.0.0-beta.2" dependencies = [ "alloy-primitives", "alloy-provider", @@ -680,7 +680,7 @@ dependencies = [ [[package]] name = "apibara-dna-starknet" -version = "2.0.0-beta.1" +version = "2.0.0-beta.2" dependencies = [ "apibara-dna-common", "apibara-dna-protocol", diff --git a/beaconchain/Cargo.toml b/beaconchain/Cargo.toml index 3373c248..75edfbb7 100644 --- a/beaconchain/Cargo.toml +++ b/beaconchain/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "apibara-dna-beaconchain" -version = "2.0.0-beta.1" +version = "2.0.0-beta.2" edition.workspace = true authors.workspace = true repository.workspace = true diff --git a/evm/Cargo.toml b/evm/Cargo.toml index 2450b23a..50c0b604 100644 --- a/evm/Cargo.toml +++ b/evm/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "apibara-dna-evm" -version = "2.0.0-beta.1" +version = "2.0.0-beta.2" edition.workspace = true authors.workspace = true repository.workspace = true diff --git a/starknet/Cargo.toml b/starknet/Cargo.toml index 39b00437..ae22025b 100644 --- a/starknet/Cargo.toml +++ b/starknet/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "apibara-dna-starknet" -version = "2.0.0-beta.1" +version = "2.0.0-beta.2" edition.workspace = true authors.workspace = true repository.workspace = true