Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions cargo-prosa/assets/main.rs.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ allow = [
"MIT",
"BSD-2-Clause",
"BSD-3-Clause",
"CDLA-Permissive-2.0",
"ISC",
"Zlib",
"Unicode-3.0",
Expand Down
4 changes: 2 additions & 2 deletions prosa/examples/proc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
Expand Down
6 changes: 4 additions & 2 deletions prosa/src/core/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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)]
Expand Down
17 changes: 11 additions & 6 deletions prosa/src/inj/proc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
/// },
/// };
Comment thread
reneca marked this conversation as resolved.
Outdated
/// use prosa_utils::msg::simple_string_tvf::SimpleStringTvf;
/// use prosa::core::settings::settings;
/// use serde::Serialize;
///
/// // Main settings
Expand Down
2 changes: 1 addition & 1 deletion prosa/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
21 changes: 15 additions & 6 deletions prosa/src/io/listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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> {
Expand Down Expand Up @@ -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> {
Expand Down
14 changes: 10 additions & 4 deletions prosa/src/io/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
6 changes: 6 additions & 0 deletions prosa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ pub mod io;
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,
};

Comment thread
oschijns marked this conversation as resolved.
#[cfg(test)]
mod tests {
use std::{
Expand Down
17 changes: 11 additions & 6 deletions prosa/src/stub/proc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
/// },
/// };
Comment thread
reneca marked this conversation as resolved.
Outdated
/// use prosa_utils::msg::simple_string_tvf::SimpleStringTvf;
/// use prosa::core::settings::settings;
/// use serde::Serialize;
///
/// // Main settings
Expand Down
10 changes: 8 additions & 2 deletions prosa_book/src/ch02-04-observability.md
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Comment thread
oschijns marked this conversation as resolved.
```toml
opentelemetry = { version = "0.29", features = ["metrics", "trace", "logs"] }
opentelemetry = { version = "0.32", features = ["metrics", "trace", "logs"] }
```

## Metrics
Expand Down
10 changes: 5 additions & 5 deletions prosa_utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
Loading
Loading