Skip to content
Open
Show file tree
Hide file tree
Changes from all 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::tracing::{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
8 changes: 4 additions & 4 deletions prosa/src/core/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ 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},
};
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<M>
Expand Down
2 changes: 1 addition & 1 deletion prosa/src/core/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
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
11 changes: 3 additions & 8 deletions prosa/src/inj/proc.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand Down Expand Up @@ -101,13 +101,8 @@ 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::*, proc::*, settings::*}, inj::{adaptor::*, proc::*}};
/// 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
4 changes: 4 additions & 0 deletions prosa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ pub mod io;
pub mod inj;
pub mod stub;

// Expose crate to avoid adding them into Cargo.toml
pub use opentelemetry as otel;
pub use tracing;

Comment thread
oschijns marked this conversation as resolved.
#[cfg(test)]
mod tests {
use std::{
Expand Down
2 changes: 1 addition & 1 deletion prosa/src/stub/adaptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand Down
9 changes: 2 additions & 7 deletions prosa/src/stub/proc.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -39,13 +39,8 @@ 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::*, proc::*, settings::*}, stub::{adaptor::*, proc::*}};
/// 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 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::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):
```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