Closed meringu closed 1 month ago
@meringu thanks for the PR - I will look here & test as well this week.
Could you bump the minor version in the root library's Cargo.toml as well? Even if things are not necessarily breaking with this library's dependencies, so far I have been opting to bump the minor version every time the OTEL deps do, as keeping everything compatible across all the many OTEL libraries can be a bit of a chore for the downstream consumers.
Thanks @francoposa. I bumped it to 0.8.0.
I have tested with updated axum & tower examples in docker compose
Please update example code & dependency versions as well and we can get this merged:
diff --git a/examples/axum-http-service/Cargo.toml b/examples/axum-http-service/Cargo.toml
index 6078924..f50b6d6 100644
--- a/examples/axum-http-service/Cargo.toml
+++ b/examples/axum-http-service/Cargo.toml
@@ -10,8 +10,8 @@ tower_otel_http_metrics = { path = "../../", package = "tower-otel-http-metrics"
axum = { features = ["http1", "tokio"], version = "0.7", default-features = false }
bytes = { version = "1", default-features = false }
http-body-util = { version = "0.1" }
-opentelemetry = { version = "0.25.0", default-features = false }
-opentelemetry_sdk = { version = "0.25.0", features = ["rt-tokio"], default-features = false }
-opentelemetry-semantic-conventions = { version = "0.25.0", default-features = false }
-opentelemetry-otlp = { version = "0.25.0", features = ["metrics", "grpc-tonic"], default-features = false }
+opentelemetry = { version = "0.26", default-features = false }
+opentelemetry_sdk = { version = "0.26", features = ["rt-tokio"], default-features = false }
+opentelemetry-semantic-conventions = { version = "0.26", default-features = false }
+opentelemetry-otlp = { version = "0.26", features = ["metrics", "grpc-tonic"], default-features = false }
tokio = { version = "1", features = ["rt-multi-thread"], default-features = false }
diff --git a/examples/axum-http-service/src/main.rs b/examples/axum-http-service/src/main.rs
index 7280d4a..80df935 100644
--- a/examples/axum-http-service/src/main.rs
+++ b/examples/axum-http-service/src/main.rs
@@ -1,4 +1,3 @@
-use std::borrow::Cow;
use std::time::Duration;
use axum::routing::{get, post, put, Router};
@@ -55,7 +54,7 @@ async fn main() {
global::set_meter_provider(meter_provider);
// init our otel metrics middleware
- let global_meter = global::meter(Cow::from(SERVICE_NAME));
+ let global_meter = global::meter(SERVICE_NAME);
let otel_metrics_service_layer = tower_otel_http_metrics::HTTPMetricsLayerBuilder::new()
.with_meter(global_meter)
.build()
diff --git a/examples/tower-http-service/Cargo.toml b/examples/tower-http-service/Cargo.toml
index 79c4bd9..7f5655c 100644
--- a/examples/tower-http-service/Cargo.toml
+++ b/examples/tower-http-service/Cargo.toml
@@ -11,10 +11,10 @@ bytes = { version = "1", default-features = false }
hyper = { version = "1", default-features = false }
http-body-util = { version = "0.1", default-features = false }
hyper-util = { version = "0.1", features = ["http1", "service", "server", "tokio"], default-features = false }
-opentelemetry = { version = "0.25.0", default-features = false }
-opentelemetry_sdk = { version = "0.25.0", features = ["rt-tokio"], default-features = false }
-opentelemetry-semantic-conventions = { version = "0.25.0", default-features = false }
-opentelemetry-otlp = { version = "0.25.0", features = ["grpc-tonic", "metrics"], default-features = false }
+opentelemetry = { version = "0.26", default-features = false }
+opentelemetry_sdk = { version = "0.26", features = ["rt-tokio"], default-features = false }
+opentelemetry-semantic-conventions = { version = "0.26", default-features = false }
+opentelemetry-otlp = { version = "0.26", features = ["grpc-tonic", "metrics"], default-features = false }
tokio = { version = "1", features = ["rt-multi-thread", "macros"], default-features = false }
tower = { version = "0.5", default-features = false }
tower-http = { version = "0.6", default-features = false }
diff --git a/examples/tower-http-service/src/main.rs b/examples/tower-http-service/src/main.rs
index 1d2ef9a..440a76a 100644
--- a/examples/tower-http-service/src/main.rs
+++ b/examples/tower-http-service/src/main.rs
@@ -1,4 +1,3 @@
-use std::borrow::Cow;
use std::convert::Infallible;
use std::net::SocketAddr;
use std::time::Duration;
@@ -60,7 +59,7 @@ async fn main() {
global::set_meter_provider(meter_provider);
// init our otel metrics middleware
- let global_meter = global::meter(Cow::from(SERVICE_NAME));
+ let global_meter = global::meter(SERVICE_NAME);
let otel_metrics_service_layer = tower_otel_http_metrics::HTTPMetricsLayerBuilder::new()
.with_meter(global_meter)
.build()
Thanks @francoposa. I have applied your patch.
I have given you push rights to this branch if it makes it any more convenient for further patches.
thank you! will tag and release shortly
Upgrades to 0.26. In my testing all I needed to do to get this to work was to update the
global::meter
functions as in the README.md changes.