diff --git a/Cargo.toml b/Cargo.toml index 5ecb7cf3e3..c8d041a8bf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,6 +24,7 @@ members = [ "examples/external-otlp-tonic-tokio", "examples/grpc", "examples/http", + "examples/hyper-prometheus", "examples/tracing-grpc", "examples/zipkin", "examples/multiple-span-processors" diff --git a/examples/hyper-prometheus/Cargo.toml b/examples/hyper-prometheus/Cargo.toml new file mode 100644 index 0000000000..c33fb3fee1 --- /dev/null +++ b/examples/hyper-prometheus/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "hyper-prometheus" +version = "0.1.0" +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +opentelemetry = { path = "../../opentelemetry", features = ["rt-tokio"] } +opentelemetry-prometheus = { path = "../../opentelemetry-prometheus" } +prometheus = "0.12" +lazy_static = "1.4" +hyper = { version = "0.14", features = ["full"] } +tokio = { version = "1", features = ["full"] } diff --git a/opentelemetry-prometheus/examples/hyper.rs b/examples/hyper-prometheus/src/main.rs similarity index 70% rename from opentelemetry-prometheus/examples/hyper.rs rename to examples/hyper-prometheus/src/main.rs index 798351a77a..2ab79c58e2 100644 --- a/opentelemetry-prometheus/examples/hyper.rs +++ b/examples/hyper-prometheus/src/main.rs @@ -4,7 +4,7 @@ extern crate lazy_static; use hyper::{ header::CONTENT_TYPE, service::{make_service_fn, service_fn}, - Body, Request, Response, Server, + Body, Method, Request, Response, Server, }; use opentelemetry::{ global, @@ -22,29 +22,41 @@ lazy_static! { } async fn serve_req( - _req: Request
, + req: Request, state: Arc