Skip to content

Commit

Permalink
feat: Add prometheus direct interface and update opentelemetry (#14)
Browse files Browse the repository at this point in the history
* feat: Add prometheus direct interface and update opentelemetry

Signed-off-by: Jeremy HERGAULT <[email protected]>
  • Loading branch information
reneca authored Oct 16, 2024
1 parent 2095efe commit 1b32e85
Show file tree
Hide file tree
Showing 14 changed files with 408 additions and 113 deletions.
15 changes: 15 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,19 @@ prosa-macros = { version = "0.1.2", path = "prosa_macros" }
thiserror = "1"
aquamarine = "0.5"
bytes = "1"
url = { version = "2", features = ["serde"] }
tokio = "1"

# Config Observability
log = "0.4"
tracing-core = "0.1"
tracing-subscriber = "0.3"
tracing-opentelemetry = "0.25"
opentelemetry = { version = "0.24", features = ["metrics", "trace", "logs"] }
opentelemetry_sdk = { version = "0.24", features = ["metrics", "trace", "logs", "rt-tokio"] }
opentelemetry-stdout = { version = "0.5", features = ["metrics", "trace", "logs"]}
opentelemetry-otlp = { version = "0.17", features = ["metrics", "trace", "logs"]}
prometheus = { version = "0.13" }
prometheus_exporter = { version = "0.8", features = ["logging"] }
opentelemetry-prometheus = { version = "0.17" }
opentelemetry-appender-log = "0.5"
2 changes: 1 addition & 1 deletion cargo-prosa/src/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub struct ComponentVersion<'a> {
pub version: &'a String,
}

impl<'a> fmt::Display for ComponentVersion<'a> {
impl fmt::Display for ComponentVersion<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
if f.alternate() {
writeln!(f, "{}", self.name)?;
Expand Down
15 changes: 9 additions & 6 deletions prosa/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,12 @@ glob = { version = "0.3" }
toml = "0.8"
serde_yaml = "0.9"

tracing-opentelemetry = "0.22"

opentelemetry = { version = "0.21", features = ["metrics", "trace", "logs"] }
opentelemetry_sdk = { version = "0.21", features = ["metrics", "trace", "logs", "rt-tokio"] }
opentelemetry-stdout = { version = "0.2", features = ["metrics", "trace", "logs"]}
opentelemetry-otlp = { version = "0.14", features = ["metrics", "trace", "logs"]}
log.workspace = true
tracing-opentelemetry.workspace = true

opentelemetry.workspace = true
opentelemetry_sdk.workspace = true
opentelemetry-stdout.workspace = true
opentelemetry-otlp.workspace = true
opentelemetry-appender-log.workspace = true
memory-stats = "1"
6 changes: 3 additions & 3 deletions prosa/my_prosa_settings.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: my-prosa

otel:
observability:
level: DEBUG
metrics:
stdout:
level: 0
prometheus:
endpoint: 0.0.0.0:9100
traces:
stdout:
level: debug
Expand Down
7 changes: 0 additions & 7 deletions prosa/proc.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::time::Duration;

use config::Config;
use opentelemetry::global;
use prosa::core::main::{MainProc, MainRunnable};
use prosa::core::msg::{InternalMsg, Msg, RequestMsg};
use prosa::core::proc::{proc, Proc, ProcBusParam, ProcConfig};
Expand Down Expand Up @@ -128,12 +127,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let my_settings = config.try_deserialize::<MySettings>()?;
println!("My ProSA settings: {:?}", my_settings);

// metrics
global::set_meter_provider(my_settings.get_observability().build_meter_provider());

// logs
global::set_logger_provider(my_settings.get_observability().build_logger_provider());

// traces
let telemetry_filter = TelemetryFilter::new(LevelFilter::DEBUG);
my_settings
Expand Down
Loading

0 comments on commit 1b32e85

Please sign in to comment.