From c7f7feda36438e73a1c3ad62c1ebdb1318f5d479 Mon Sep 17 00:00:00 2001 From: Jeremy HERGAULT Date: Tue, 26 May 2026 16:55:42 +0200 Subject: [PATCH 1/7] feat(otel): update OpenTelemetry to 0.32 and improve it's usage Signed-off-by: Jeremy HERGAULT --- Cargo.toml | 4 +- prosa_utils/Cargo.toml | 10 +-- prosa_utils/src/config/observability.rs | 100 ++++++++++++++---------- 3 files changed, 67 insertions(+), 47 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e2b72d0..8895edc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,8 +35,8 @@ toml = "0.9" # Config Observability log = "0.4" -opentelemetry = { version = "0.31.0", features = ["metrics", "trace", "logs"] } -opentelemetry_sdk = { version = "0.31.0", features = ["metrics", "trace", "logs", "rt-tokio"] } +opentelemetry = { version = "0.32", features = ["metrics", "trace", "logs"] } +opentelemetry_sdk = { version = "0.32", features = ["metrics", "trace", "logs", "rt-tokio"] } prometheus = { version = "0.14", default-features = false } # Config SSL diff --git a/prosa_utils/Cargo.toml b/prosa_utils/Cargo.toml index 17f26d3..6238b87 100644 --- a/prosa_utils/Cargo.toml +++ b/prosa_utils/Cargo.toml @@ -51,14 +51,14 @@ openssl = { workspace = true, optional = true } log = { workspace = true, optional = true } tracing-core = { version = "0.1", optional = true } tracing-subscriber = { version = ">=0.3.20, < 0.4", features = ["std", "env-filter"], optional = true } -tracing-opentelemetry = { version = "0.32.1", optional = true } +tracing-opentelemetry = { version = "0.33", optional = true } opentelemetry = { workspace = true, optional = true } opentelemetry_sdk = { workspace = true, optional = true } -opentelemetry-stdout = { version = "0.31.0", optional = true, features = ["metrics", "trace", "logs"]} -opentelemetry-otlp = { version = "0.31.0", optional = true, features = ["metrics", "trace", "logs", "reqwest-rustls", "grpc-tonic"]} +opentelemetry-stdout = { version = "0.32", optional = true, features = ["metrics", "trace", "logs"]} +opentelemetry-otlp = { version = "0.32", optional = true, features = ["metrics", "trace", "logs", "reqwest-rustls", "grpc-tonic", "http-json"]} prometheus = { workspace = true, optional = true } -opentelemetry-prometheus = { version = "0.31.0", optional = true } -opentelemetry-appender-tracing = { version = "0.31.0", optional = true } +opentelemetry-prometheus = { version = "0.32", optional = true } +opentelemetry-appender-tracing = { version = "0.32", optional = true } # Web Observability tokio = { workspace = true, optional = true } diff --git a/prosa_utils/src/config/observability.rs b/prosa_utils/src/config/observability.rs index 7f2f13c..e6d3c43 100644 --- a/prosa_utils/src/config/observability.rs +++ b/prosa_utils/src/config/observability.rs @@ -1,9 +1,7 @@ //! Definition of Opentelemetry configuration use opentelemetry::{KeyValue, trace::TracerProvider as _}; -use opentelemetry_otlp::{ - ExportConfig, ExporterBuildError, Protocol, WithExportConfig, WithHttpConfig, -}; +use opentelemetry_otlp::{ExporterBuildError, Protocol, WithExportConfig, WithHttpConfig}; use opentelemetry_sdk::{ logs::SdkLoggerProvider, metrics::SdkMeterProvider, @@ -29,6 +27,23 @@ pub(crate) struct OTLPExporterCfg { } impl OTLPExporterCfg { + /// Get the sanitized endpoint string (without credentials) + pub(crate) fn get_endpoint(&self) -> String { + let mut endpoint = self.endpoint.clone(); + if !endpoint.username().is_empty() { + let _ = endpoint.set_username(""); + } + if endpoint.password().is_some() { + let _ = endpoint.set_password(None); + } + endpoint.to_string() + } + + /// Get the timeout duration if configured + pub(crate) fn get_timeout(&self) -> Option { + self.timeout_sec.map(Duration::from_secs) + } + pub(crate) fn get_protocol(&self) -> Protocol { match self.endpoint.scheme().to_lowercase().as_str() { "grpc" => Protocol::Grpc, @@ -63,25 +78,6 @@ impl OTLPExporterCfg { } } -impl From for ExportConfig { - fn from(value: OTLPExporterCfg) -> Self { - let protocol = value.get_protocol(); - let mut endpoint = value.endpoint; - if !endpoint.username().is_empty() { - let _ = endpoint.set_username(""); - } - if endpoint.password().is_some() { - let _ = endpoint.set_password(None); - } - - ExportConfig { - endpoint: Some(endpoint.to_string()), - timeout: value.timeout_sec.map(Duration::from_secs), - protocol, - } - } -} - impl Default for OTLPExporterCfg { fn default() -> Self { Self { @@ -215,16 +211,24 @@ impl TelemetryMetrics { let mut meter_provider = SdkMeterProvider::builder(); if let Some(s) = &self.otlp { let exporter = if s.get_protocol() == Protocol::Grpc { - opentelemetry_otlp::MetricExporter::builder() + let mut builder = opentelemetry_otlp::MetricExporter::builder() .with_tonic() - .with_export_config(s.clone().into()) - .build() + .with_endpoint(s.get_endpoint()) + .with_protocol(s.get_protocol()); + if let Some(timeout) = s.get_timeout() { + builder = builder.with_timeout(timeout); + } + builder.build() } else { - opentelemetry_otlp::MetricExporter::builder() + let mut builder = opentelemetry_otlp::MetricExporter::builder() .with_http() .with_headers(s.get_header()) - .with_export_config(s.clone().into()) - .build() + .with_endpoint(s.get_endpoint()) + .with_protocol(s.get_protocol()); + if let Some(timeout) = s.get_timeout() { + builder = builder.with_timeout(timeout); + } + builder.build() }?; meter_provider = meter_provider.with_periodic_exporter(exporter); } @@ -290,16 +294,24 @@ impl TelemetryData { let logs_provider = SdkLoggerProvider::builder(); if let Some(s) = &self.otlp { let exporter = if s.get_protocol() == Protocol::Grpc { - opentelemetry_otlp::LogExporter::builder() + let mut builder = opentelemetry_otlp::LogExporter::builder() .with_tonic() - .with_export_config(s.clone().into()) - .build() + .with_endpoint(s.get_endpoint()) + .with_protocol(s.get_protocol()); + if let Some(timeout) = s.get_timeout() { + builder = builder.with_timeout(timeout); + } + builder.build() } else { - opentelemetry_otlp::LogExporter::builder() + let mut builder = opentelemetry_otlp::LogExporter::builder() .with_http() .with_headers(s.get_header()) - .with_export_config(s.clone().into()) - .build() + .with_endpoint(s.get_endpoint()) + .with_protocol(s.get_protocol()); + if let Some(timeout) = s.get_timeout() { + builder = builder.with_timeout(timeout); + } + builder.build() }?; Ok(( logs_provider @@ -328,16 +340,24 @@ impl TelemetryData { let mut trace_provider = SdkTracerProvider::builder(); if let Some(s) = &self.otlp { let exporter = if s.get_protocol() == Protocol::Grpc { - opentelemetry_otlp::SpanExporter::builder() + let mut builder = opentelemetry_otlp::SpanExporter::builder() .with_tonic() - .with_export_config(s.clone().into()) - .build() + .with_endpoint(s.get_endpoint()) + .with_protocol(s.get_protocol()); + if let Some(timeout) = s.get_timeout() { + builder = builder.with_timeout(timeout); + } + builder.build() } else { - opentelemetry_otlp::SpanExporter::builder() + let mut builder = opentelemetry_otlp::SpanExporter::builder() .with_http() .with_headers(s.get_header()) - .with_export_config(s.clone().into()) - .build() + .with_endpoint(s.get_endpoint()) + .with_protocol(s.get_protocol()); + if let Some(timeout) = s.get_timeout() { + builder = builder.with_timeout(timeout); + } + builder.build() }?; trace_provider = trace_provider From 0c0942bba44b1bbbd509fdfcfdb63088e22aa7ab Mon Sep 17 00:00:00 2001 From: Jeremy HERGAULT Date: Thu, 28 May 2026 11:42:55 +0200 Subject: [PATCH 2/7] feat(otel): allow new otel licence, and expose otel framework Signed-off-by: Jeremy HERGAULT --- deny.toml | 1 + prosa/src/lib.rs | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/deny.toml b/deny.toml index 36ddc16..1e7295a 100644 --- a/deny.toml +++ b/deny.toml @@ -11,6 +11,7 @@ allow = [ "MIT", "BSD-2-Clause", "BSD-3-Clause", + "CDLA-Permissive-2.0", "ISC", "Zlib", "Unicode-3.0", diff --git a/prosa/src/lib.rs b/prosa/src/lib.rs index 24f27ad..ac8040d 100644 --- a/prosa/src/lib.rs +++ b/prosa/src/lib.rs @@ -18,6 +18,10 @@ pub mod io; pub mod inj; pub mod stub; +// Expose crate to avoir adding them into Cargo.toml +pub use tracing::{debug, debug_span, error, error_span, info, info_span, trace, trace_span, warn, warn_span}; +pub use opentelemetry::{metrics, Key, KeyValue, SpanId, StringValue, TraceId, Value}; + #[cfg(test)] mod tests { use std::{ From 9495dac1d1f2f5db912211864d7b3b3c1b1ddde7 Mon Sep 17 00:00:00 2001 From: Jeremy HERGAULT Date: Thu, 28 May 2026 11:46:34 +0200 Subject: [PATCH 3/7] fix: fmt Signed-off-by: Jeremy HERGAULT --- prosa/src/lib.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/prosa/src/lib.rs b/prosa/src/lib.rs index ac8040d..24a74a7 100644 --- a/prosa/src/lib.rs +++ b/prosa/src/lib.rs @@ -19,8 +19,10 @@ pub mod inj; pub mod stub; // Expose crate to avoir adding them into Cargo.toml -pub use tracing::{debug, debug_span, error, error_span, info, info_span, trace, trace_span, warn, warn_span}; -pub use opentelemetry::{metrics, Key, KeyValue, SpanId, StringValue, TraceId, Value}; +pub use opentelemetry::{Key, KeyValue, SpanId, StringValue, TraceId, Value, metrics}; +pub use tracing::{ + debug, debug_span, error, error_span, info, info_span, trace, trace_span, warn, warn_span, +}; #[cfg(test)] mod tests { From bcf84cec4e2997e364846786476229a81e6e5dfd Mon Sep 17 00:00:00 2001 From: Jeremy HERGAULT Date: Sat, 30 May 2026 16:57:59 +0200 Subject: [PATCH 4/7] feat: expose more lib to simplify coding Signed-off-by: Jeremy HERGAULT --- prosa/src/core/settings.rs | 6 ++++-- prosa/src/inj/proc.rs | 17 +++++++++++------ prosa/src/io.rs | 2 +- prosa/src/io/listener.rs | 21 +++++++++++++++------ prosa/src/io/stream.rs | 14 ++++++++++---- prosa/src/stub/proc.rs | 17 +++++++++++------ 6 files changed, 52 insertions(+), 25 deletions(-) diff --git a/prosa/src/core/settings.rs b/prosa/src/core/settings.rs index b9d823f..a5dc472 100644 --- a/prosa/src/core/settings.rs +++ b/prosa/src/core/settings.rs @@ -13,6 +13,9 @@ use config::{Config, ConfigBuilder, builder::DefaultState}; use prosa_utils::config::observability::Observability; use serde::Serialize; +/// Re-export of prosa_utils for observability config +pub use prosa_utils::config::{observability, tracing}; + /// Implement the trait [`Settings`] pub use prosa_macros::settings; @@ -45,8 +48,7 @@ pub use prosa_macros::settings; /// is equivalent to /// /// ``` -/// use prosa::core::settings::Settings; -/// use prosa_utils::config::observability::Observability; +/// use prosa::core::settings::{Settings, observability::Observability}; /// use serde::{Deserialize, Serialize}; /// /// #[derive(Debug, Deserialize, Serialize)] diff --git a/prosa/src/inj/proc.rs b/prosa/src/inj/proc.rs index 14bf26c..e174a15 100644 --- a/prosa/src/inj/proc.rs +++ b/prosa/src/inj/proc.rs @@ -101,13 +101,18 @@ impl Default for InjSettings { /// Inj processor to inject transactions /// /// ``` -/// use prosa::core::main::{MainProc, MainRunnable}; -/// use prosa::core::proc::{proc, Proc, ProcBusParam, ProcConfig}; -/// use prosa::inj::adaptor::InjDummyAdaptor; -/// use prosa::inj::proc::{InjProc, InjSettings}; -/// use prosa_utils::config::observability::Observability; +/// use prosa::{ +/// core::{ +/// main::{MainProc, MainRunnable}, +/// proc::{proc, Proc, ProcBusParam, ProcConfig}, +/// settings::{settings, observability::Observability}, +/// }, +/// inj::{ +/// adaptor::InjDummyAdaptor, +/// proc::{InjProc, InjSettings}, +/// }, +/// }; /// use prosa_utils::msg::simple_string_tvf::SimpleStringTvf; -/// use prosa::core::settings::settings; /// use serde::Serialize; /// /// // Main settings diff --git a/prosa/src/io.rs b/prosa/src/io.rs index 21f2241..dc8ca91 100644 --- a/prosa/src/io.rs +++ b/prosa/src/io.rs @@ -9,7 +9,7 @@ use std::{ use url::Url; pub use prosa_macros::io; -pub use prosa_utils::config::ssl::SslConfig; +pub use prosa_utils::config::ssl::{SslConfig, SslConfigContext}; pub mod listener; pub mod stream; diff --git a/prosa/src/io/listener.rs b/prosa/src/io/listener.rs index a9f1c0b..da3dad1 100644 --- a/prosa/src/io/listener.rs +++ b/prosa/src/io/listener.rs @@ -132,8 +132,11 @@ impl StreamListener { /// /// ``` /// use tokio::io; - /// use prosa_utils::config::ssl::{SslConfig, SslConfigContext}; - /// use prosa::io::listener::StreamListener; + /// use prosa::io::{ + /// listener::StreamListener, + /// SslConfig, + /// SslConfigContext, + /// }; /// /// async fn accepting() -> Result<(), io::Error> { /// let ssl_acceptor = SslConfig::default().init_tls_server_context(None).unwrap().build(); @@ -173,8 +176,11 @@ impl StreamListener { /// /// ``` /// use tokio::io; - /// use prosa_utils::config::ssl::{SslConfig, SslConfigContext}; - /// use prosa::io::listener::StreamListener; + /// use prosa::io::{ + /// listener::StreamListener, + /// SslConfig, + /// SslConfigContext, + /// }; /// /// # #[cfg(feature="openssl")] /// async fn accepting() -> Result<(), io::Error> { @@ -230,8 +236,11 @@ impl StreamListener { /// /// ``` /// use tokio::io; - /// use prosa_utils::config::ssl::{SslConfig, SslConfigContext}; - /// use prosa::io::listener::StreamListener; + /// use prosa::io::{ + /// listener::StreamListener, + /// SslConfig, + /// SslConfigContext, + /// }; /// /// # #[cfg(feature="openssl")] /// async fn accepting() -> Result<(), io::Error> { diff --git a/prosa/src/io/stream.rs b/prosa/src/io/stream.rs index cc894d4..954722b 100644 --- a/prosa/src/io/stream.rs +++ b/prosa/src/io/stream.rs @@ -208,8 +208,11 @@ impl Stream { /// ``` /// use tokio::io; /// use url::Url; - /// use prosa_utils::config::ssl::{SslConfig, SslConfigContext}; - /// use prosa::io::stream::Stream; + /// use prosa::io::{ + /// SslConfig, + /// SslConfigContext, + /// stream::Stream, + /// }; /// /// async fn connecting() -> Result<(), io::Error> { /// let ssl_config = SslConfig::default(); @@ -332,8 +335,11 @@ impl Stream { /// ``` /// use tokio::io; /// use url::Url; - /// use prosa_utils::config::ssl::{SslConfig, SslConfigContext}; - /// use prosa::io::stream::Stream; + /// use prosa::io::{ + /// SslConfig, + /// SslConfigContext, + /// stream::Stream, + /// }; /// /// async fn connecting() -> Result<(), io::Error> { /// let proxy_url = Url::parse("http://user:pwd@proxy:3128").unwrap(); diff --git a/prosa/src/stub/proc.rs b/prosa/src/stub/proc.rs index 7a41eb0..15351a2 100644 --- a/prosa/src/stub/proc.rs +++ b/prosa/src/stub/proc.rs @@ -39,13 +39,18 @@ impl StubSettings { /// Stub processor to respond to a request /// /// ``` -/// use prosa::core::main::{MainProc, MainRunnable}; -/// use prosa::core::proc::{proc, Proc, ProcBusParam, ProcConfig}; -/// use prosa::stub::adaptor::StubParotAdaptor; -/// use prosa::stub::proc::{StubProc, StubSettings}; -/// use prosa_utils::config::observability::Observability; +/// use prosa::{ +/// core::{ +/// main::{MainProc, MainRunnable}, +/// proc::{proc, Proc, ProcBusParam, ProcConfig}, +/// settings::{settings, observability::Observability}, +/// }, +/// stub::{ +/// adaptor::StubParotAdaptor, +/// proc::{StubProc, StubSettings}, +/// }, +/// }; /// use prosa_utils::msg::simple_string_tvf::SimpleStringTvf; -/// use prosa::core::settings::settings; /// use serde::Serialize; /// /// // Main settings From aa83844cb33f580c189606fd710d2801ddf618d3 Mon Sep 17 00:00:00 2001 From: Jeremy HERGAULT Date: Sat, 30 May 2026 20:30:17 +0200 Subject: [PATCH 5/7] feat: replace remaining reference to unexported items Signed-off-by: Jeremy HERGAULT --- cargo-prosa/assets/main.rs.j2 | 3 +-- prosa/examples/proc.rs | 4 ++-- prosa_book/src/ch02-04-observability.md | 10 ++++++++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/cargo-prosa/assets/main.rs.j2 b/cargo-prosa/assets/main.rs.j2 index d7c8454..b0d8125 100644 --- a/cargo-prosa/assets/main.rs.j2 +++ b/cargo-prosa/assets/main.rs.j2 @@ -4,11 +4,10 @@ use serde::{Deserialize, Serialize}; use tokio::runtime; -use prosa_utils::config::tracing::TelemetryFilter; use prosa::core::{ main::MainRunnable, proc::ProcConfig, - settings::Settings + settings::{Settings, tracing::TelemetryFilter}, }; {% endraw %} // Include settings diff --git a/prosa/examples/proc.rs b/prosa/examples/proc.rs index c65caf4..8b1b198 100644 --- a/prosa/examples/proc.rs +++ b/prosa/examples/proc.rs @@ -6,16 +6,16 @@ use prosa::core::msg::{InternalMsg, Msg, RequestMsg}; use prosa::core::proc::{Proc, ProcBusParam, ProcConfig, proc}; use prosa::core::settings::Settings; use prosa::core::settings::settings; +use prosa::core::settings::tracing::TelemetryFilter; use prosa::event::pending::PendingMsgs; use prosa::stub::adaptor::StubParotAdaptor; use prosa::stub::proc::{StubProc, StubSettings}; -use prosa_utils::config::tracing::TelemetryFilter; +use prosa::{debug, info, warn}; use prosa_utils::msg::simple_string_tvf::SimpleStringTvf; use serde::{Deserialize, Serialize}; use std::time::Duration; use tokio::time; use tracing::metadata::LevelFilter; -use tracing::{debug, info, warn}; #[derive(Default, Adaptor)] struct MyAdaptor {} diff --git a/prosa_book/src/ch02-04-observability.md b/prosa_book/src/ch02-04-observability.md index a680b9d..0b234bc 100644 --- a/prosa_book/src/ch02-04-observability.md +++ b/prosa_book/src/ch02-04-observability.md @@ -8,9 +8,15 @@ When you create an adaptor, you may want to generate custom metrics, traces or l It is important to understand how to implement these features within ProSA, as ProSA handles much of the integration for you. -Each time you'll need to include opentelemetry dependency to your project: +For convenience, ProSA re-exports the most common OpenTelemetry items (`KeyValue`, `metrics`, ...) and the `tracing` macros (`info!`, `debug!`, ...), so for most adaptors you don't need to add any dependency: +```rust,noplayground +use prosa::{KeyValue, metrics}; +use prosa::{debug, error, info, trace, warn}; +``` + +If you need types that aren't re-exported, add the OpenTelemetry dependency to your project (keep the version aligned with ProSA): ```toml -opentelemetry = { version = "0.29", features = ["metrics", "trace", "logs"] } +opentelemetry = { version = "0.32", features = ["metrics", "trace", "logs"] } ``` ## Metrics From 817b0a2bf5cf03ba4d9847e8c76c544893a84618 Mon Sep 17 00:00:00 2001 From: Jeremy HERGAULT Date: Sat, 30 May 2026 20:43:42 +0200 Subject: [PATCH 6/7] fix: typo Signed-off-by: Jeremy HERGAULT --- prosa/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prosa/src/lib.rs b/prosa/src/lib.rs index 24a74a7..cd3f274 100644 --- a/prosa/src/lib.rs +++ b/prosa/src/lib.rs @@ -18,7 +18,7 @@ pub mod io; pub mod inj; pub mod stub; -// Expose crate to avoir adding them into Cargo.toml +// Expose crate to avoid adding them into Cargo.toml pub use opentelemetry::{Key, KeyValue, SpanId, StringValue, TraceId, Value, metrics}; pub use tracing::{ debug, debug_span, error, error_span, info, info_span, trace, trace_span, warn, warn_span, From 272db481b26fa8bb3f50c32239d7e2e83b156ac5 Mon Sep 17 00:00:00 2001 From: Jeremy HERGAULT Date: Mon, 1 Jun 2026 16:20:43 +0200 Subject: [PATCH 7/7] fix: according to code review Signed-off-by: Jeremy HERGAULT --- prosa/examples/proc.rs | 2 +- prosa/src/core/main.rs | 8 ++++---- prosa/src/core/service.rs | 2 +- prosa/src/inj/proc.rs | 16 +++------------- prosa/src/lib.rs | 6 ++---- prosa/src/stub/adaptor.rs | 2 +- prosa/src/stub/proc.rs | 14 ++------------ prosa_book/src/ch02-04-observability.md | 6 +++--- 8 files changed, 17 insertions(+), 39 deletions(-) diff --git a/prosa/examples/proc.rs b/prosa/examples/proc.rs index 8b1b198..17a2d55 100644 --- a/prosa/examples/proc.rs +++ b/prosa/examples/proc.rs @@ -10,7 +10,7 @@ use prosa::core::settings::tracing::TelemetryFilter; use prosa::event::pending::PendingMsgs; use prosa::stub::adaptor::StubParotAdaptor; use prosa::stub::proc::{StubProc, StubSettings}; -use prosa::{debug, info, warn}; +use prosa::tracing::{debug, info, warn}; use prosa_utils::msg::simple_string_tvf::SimpleStringTvf; use serde::{Deserialize, Serialize}; use std::time::Duration; diff --git a/prosa/src/core/main.rs b/prosa/src/core/main.rs index 9cc6a53..1c6fcf4 100644 --- a/prosa/src/core/main.rs +++ b/prosa/src/core/main.rs @@ -16,9 +16,10 @@ use super::{ service::{ProcService, ServiceTable}, settings::Settings, }; -use opentelemetry::metrics::{Meter, MeterProvider as _}; -use opentelemetry::trace::TracerProvider as _; -use opentelemetry::{InstrumentationScope, KeyValue}; +use crate::otel::metrics::{Meter, MeterProvider as _}; +use crate::otel::trace::TracerProvider as _; +use crate::otel::{InstrumentationScope, KeyValue}; +use crate::tracing::{debug, info, warn}; use std::sync::{ Arc, atomic::{AtomicBool, Ordering}, @@ -26,7 +27,6 @@ use std::sync::{ use std::{borrow::Cow, collections::HashSet}; use std::{collections::HashMap, fmt::Debug}; use tokio::{signal, sync::mpsc}; -use tracing::{debug, info, warn}; /// Trait to define a ProSA main processor that is runnable pub trait MainRunnable diff --git a/prosa/src/core/service.rs b/prosa/src/core/service.rs index d52cef6..d0b0c81 100644 --- a/prosa/src/core/service.rs +++ b/prosa/src/core/service.rs @@ -4,7 +4,7 @@ use super::{ msg::InternalMsg, proc::{ProcBusParam, ProcParam}, }; -use opentelemetry::{KeyValue, metrics::AsyncInstrument}; +use crate::otel::{KeyValue, metrics::AsyncInstrument}; use prosa_utils::msg::tvf::{Tvf, TvfError}; use std::{ collections::{HashMap, HashSet}, diff --git a/prosa/src/inj/proc.rs b/prosa/src/inj/proc.rs index e174a15..b32890b 100644 --- a/prosa/src/inj/proc.rs +++ b/prosa/src/inj/proc.rs @@ -1,9 +1,9 @@ use std::time::Duration; -use opentelemetry::{KeyValue, metrics::Histogram}; +use crate::otel::{KeyValue, metrics::Histogram}; +use crate::tracing::debug; use prosa_macros::{proc, proc_settings}; use serde::{Deserialize, Serialize}; -use tracing::debug; use crate::{ core::{ @@ -101,17 +101,7 @@ impl Default for InjSettings { /// Inj processor to inject transactions /// /// ``` -/// use prosa::{ -/// core::{ -/// main::{MainProc, MainRunnable}, -/// proc::{proc, Proc, ProcBusParam, ProcConfig}, -/// settings::{settings, observability::Observability}, -/// }, -/// inj::{ -/// adaptor::InjDummyAdaptor, -/// proc::{InjProc, InjSettings}, -/// }, -/// }; +/// use prosa::{core::{main::*, proc::*, settings::*}, inj::{adaptor::*, proc::*}}; /// use prosa_utils::msg::simple_string_tvf::SimpleStringTvf; /// use serde::Serialize; /// diff --git a/prosa/src/lib.rs b/prosa/src/lib.rs index cd3f274..fbabfd6 100644 --- a/prosa/src/lib.rs +++ b/prosa/src/lib.rs @@ -19,10 +19,8 @@ pub mod inj; pub mod stub; // Expose crate to avoid adding them into Cargo.toml -pub use opentelemetry::{Key, KeyValue, SpanId, StringValue, TraceId, Value, metrics}; -pub use tracing::{ - debug, debug_span, error, error_span, info, info_span, trace, trace_span, warn, warn_span, -}; +pub use opentelemetry as otel; +pub use tracing; #[cfg(test)] mod tests { diff --git a/prosa/src/stub/adaptor.rs b/prosa/src/stub/adaptor.rs index 5f0909c..0aabb08 100644 --- a/prosa/src/stub/adaptor.rs +++ b/prosa/src/stub/adaptor.rs @@ -10,7 +10,7 @@ use crate::{ maybe_async, }; extern crate self as prosa; -use opentelemetry::metrics::Meter; +use crate::otel::metrics::Meter; /// Adaptator trait for the stub processor /// diff --git a/prosa/src/stub/proc.rs b/prosa/src/stub/proc.rs index 15351a2..c106a42 100644 --- a/prosa/src/stub/proc.rs +++ b/prosa/src/stub/proc.rs @@ -1,8 +1,8 @@ use std::sync::Arc; +use crate::tracing::debug; use prosa_macros::proc_settings; use serde::{Deserialize, Serialize}; -use tracing::debug; use crate::core::adaptor::{Adaptor, MaybeAsync}; use crate::core::error::{BusError, ProcError}; @@ -39,17 +39,7 @@ impl StubSettings { /// Stub processor to respond to a request /// /// ``` -/// use prosa::{ -/// core::{ -/// main::{MainProc, MainRunnable}, -/// proc::{proc, Proc, ProcBusParam, ProcConfig}, -/// settings::{settings, observability::Observability}, -/// }, -/// stub::{ -/// adaptor::StubParotAdaptor, -/// proc::{StubProc, StubSettings}, -/// }, -/// }; +/// use prosa::{core::{main::*, proc::*, settings::*}, stub::{adaptor::*, proc::*}}; /// use prosa_utils::msg::simple_string_tvf::SimpleStringTvf; /// use serde::Serialize; /// diff --git a/prosa_book/src/ch02-04-observability.md b/prosa_book/src/ch02-04-observability.md index 0b234bc..866ff80 100644 --- a/prosa_book/src/ch02-04-observability.md +++ b/prosa_book/src/ch02-04-observability.md @@ -8,10 +8,10 @@ When you create an adaptor, you may want to generate custom metrics, traces or l It is important to understand how to implement these features within ProSA, as ProSA handles much of the integration for you. -For convenience, ProSA re-exports the most common OpenTelemetry items (`KeyValue`, `metrics`, ...) and the `tracing` macros (`info!`, `debug!`, ...), so for most adaptors you don't need to add any dependency: +For convenience, ProSA re-exports the OpenTelemetry items (`KeyValue`, `metrics`, ...) and the `tracing` macros (`info!`, `debug!`, ...), so for most adaptors you don't need to add any dependency: ```rust,noplayground -use prosa::{KeyValue, metrics}; -use prosa::{debug, error, info, trace, warn}; +use prosa::otel::{KeyValue, metrics}; +use prosa::tracing::{debug, error, info, trace, warn}; ``` If you need types that aren't re-exported, add the OpenTelemetry dependency to your project (keep the version aligned with ProSA):