Skip to content

Commit

Permalink
stamp 0.7.1: upgrade tower to 0.5
Browse files Browse the repository at this point in the history
stamp 0.7.1: upgrade tower to 0.5
  • Loading branch information
francoposa committed Sep 29, 2024
1 parent 7367478 commit e09363a
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "tower-otel-http-metrics"
edition = "2021"
version = "0.7.0"
version = "0.7.1"
license = "MIT"
description = "OpenTelemetry Metrics Middleware for Tower-compatible Rust HTTP servers"
homepage = "https://github.com/francoposa/tower-otel-http-metrics"
Expand All @@ -21,7 +21,7 @@ futures-util = { version = "0.3", default-features = false }
http = { version = "1", features = ["std"], default-features = false }
opentelemetry = { version = "0.25", features = ["metrics"], default-features = false }
pin-project-lite = { version = "0.2", default-features = false }
tower = { version = "0.4", default-features = false }
tower = { version = "0.5", default-features = false }
tower-service = { version = "0.3", default-features = false }
tower-layer = { version = "0.3", default-features = false }

Expand Down
2 changes: 1 addition & 1 deletion development/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ services:
example-tower-echo-server:
build:
context: ../
dockerfile: ../examples/tower-http-service/Dockerfile.tower
dockerfile: ./examples/tower-http-service/Dockerfile.tower
container_name: echo-server
environment:
- OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4317
Expand Down
4 changes: 2 additions & 2 deletions examples/tower-http-service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ opentelemetry_sdk = { version = "0.25.0", features = ["rt-tokio"], default-featu
opentelemetry-semantic-conventions = { version = "0.25.0", default-features = false }
opentelemetry-otlp = { version = "0.25.0", features = ["grpc-tonic", "metrics"], default-features = false }
tokio = { version = "1", features = ["rt-multi-thread", "macros"], default-features = false }
tower = { version = "0.4", default-features = false }
tower-http = { version = "0.5", default-features = false }
tower = { version = "0.5", default-features = false }
tower-http = { version = "0.6", default-features = false }
8 changes: 4 additions & 4 deletions examples/tower-http-service/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use std::time::Duration;

use http_body_util::Full;
use hyper::body::Bytes;
use hyper::server::conn::http1;
use hyper::{Request, Response};
use opentelemetry::{global, KeyValue};
use opentelemetry_otlp::{
Expand Down Expand Up @@ -82,9 +81,10 @@ async fn main() {
let service_clone = hyper_service.clone();

tokio::task::spawn(async move {
if let Err(err) = http1::Builder::new()
.serve_connection(io, service_clone)
.await
if let Err(err) =
hyper_util::server::conn::auto::Builder::new(hyper_util::rt::TokioExecutor::new())
.serve_connection(io, service_clone)
.await
{
eprintln!("server error: {}", err);
}
Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use std::{fmt, result};
#[cfg(feature = "axum")]
use axum::extract::MatchedPath;
use futures_util::ready;
use http::{Response, Version};
use http;
use opentelemetry::metrics::{Histogram, Meter};
use opentelemetry::{global, KeyValue};
use pin_project_lite::pin_project;
Expand Down Expand Up @@ -234,7 +234,7 @@ where

fn extract_labels_server_request_duration<T>(
metrics_state: &ResponseFutureMetricsState,
resp: &Response<T>,
resp: &http::Response<T>,
) -> Vec<KeyValue> {
vec![
KeyValue::new(HTTP_ROUTE_LABEL, metrics_state.http_route.clone()),
Expand All @@ -254,7 +254,7 @@ fn extract_labels_server_request_duration<T>(
]
}

fn split_and_format_protocol_version(http_version: Version) -> (String, String) {
fn split_and_format_protocol_version(http_version: http::Version) -> (String, String) {
let version_str = match http_version {
http::Version::HTTP_09 => "0.9",
http::Version::HTTP_10 => "1.0",
Expand Down

0 comments on commit e09363a

Please sign in to comment.