Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates #922

Closed
wants to merge 2 commits into from
Closed
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
10 changes: 5 additions & 5 deletions examples/actix-http-tracing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ publish = false

[dependencies]
actix-web = "4.1"
actix-web-opentelemetry = { version = "0.12", features = ["metrics"] }
opentelemetry = { version = "0.17", features = ["metrics", "tokio"] }
opentelemetry-jaeger = { version = "0.16", features = ["tokio"] }
opentelemetry-prometheus = "0.10"
actix-web-opentelemetry = { version = "0.13", features = ["metrics", "metrics-prometheus"] }
opentelemetry = { version = "0.18", features = ["metrics", "rt-tokio"] }
opentelemetry-jaeger = { version = "0.17", features = ["rt-tokio"] }
opentelemetry-prometheus = "0.11"
tracing = "0.1"
tracing-opentelemetry = "0.17"
tracing-opentelemetry = "0.18"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
32 changes: 21 additions & 11 deletions examples/actix-http-tracing/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use actix_web::middleware::Logger;
use actix_web::{web, App, HttpServer};
use actix_web_opentelemetry::RequestTracing;
use actix_web_opentelemetry::{PrometheusMetricsHandler, RequestMetricsBuilder, RequestTracing};
use opentelemetry::sdk::export::metrics::aggregation;
use opentelemetry::sdk::metrics::{controllers, processors, selectors};
use opentelemetry::{global, sdk::propagation::TraceContextPropagator};
use std::io;
use tracing_subscriber::prelude::*;
Expand All @@ -18,19 +20,23 @@ fn greet_user(username: &str) -> String {

#[actix_web::main]
async fn main() -> io::Result<()> {
// Start an (optional) otel prometheus metrics pipeline
let metrics_exporter = opentelemetry_prometheus::exporter().init();
let request_metrics = actix_web_opentelemetry::RequestMetrics::new(
opentelemetry::global::meter("actix_http_tracing"),
Some(|req: &actix_web::dev::ServiceRequest| {
req.path() == "/metrics" && req.method() == actix_web::http::Method::GET
}),
Some(metrics_exporter),
);
let controller = controllers::basic(
processors::factory(
selectors::simple::histogram([1.0, 2.0, 5.0, 10.0, 20.0, 50.0]),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aggregation::cumulative_temporality_selector(),
)
.with_memory(true),
)
.build();
let exporter = opentelemetry_prometheus::exporter(controller).init();
let meter = global::meter("actix_web");

// Request metrics middleware
let request_metrics = RequestMetricsBuilder::new().build(meter);

// Start an otel jaeger trace pipeline
global::set_text_map_propagator(TraceContextPropagator::new());
let tracer = opentelemetry_jaeger::new_pipeline()
let tracer = opentelemetry_jaeger::new_agent_pipeline()
.with_service_name("app_name")
.install_simple()
.unwrap();
Expand All @@ -48,6 +54,10 @@ async fn main() -> io::Result<()> {
.wrap(Logger::default())
.wrap(RequestTracing::new())
.wrap(request_metrics.clone())
.route(
"/metrics",
web::get().to(PrometheusMetricsHandler::new(exporter.clone())),
)
.service(web::resource("/users/{username}").to(index))
})
.bind("127.0.0.1:8080")?
Expand Down
2 changes: 1 addition & 1 deletion examples/actix-http/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ opentelemetry = { path = "../../opentelemetry", features = ["rt-tokio"] }
opentelemetry-jaeger = { path = "../../opentelemetry-jaeger", features = ["reqwest_collector_client", "rt-tokio-current-thread"] }
actix-web = "4.1.0"
actix-service = "2.0.0"
env_logger = "0.9.0"
env_logger = "0.10.0"
tokio = { version = "1", features = ["full"] }
2 changes: 1 addition & 1 deletion examples/actix-hyper/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ opentelemetry = { path = "../../opentelemetry", features = ["rt-tokio"] }
opentelemetry-jaeger = { path = "../../opentelemetry-jaeger", features = ["hyper_collector_client", "rt-tokio-current-thread"] }
actix-web = "4.1.0"
actix-service = "2.0.0"
env_logger = "0.9.0"
env_logger = "0.10.0"
tokio = { version = "1", features = ["full"] }
2 changes: 1 addition & 1 deletion examples/actix-udp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ opentelemetry = { path = "../../opentelemetry" }
opentelemetry-jaeger = { path = "../../opentelemetry-jaeger" }
actix-web = "4.1"
actix-service = "2"
env_logger = "0.9"
env_logger = "0.10"
2 changes: 1 addition & 1 deletion examples/async/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ publish = false

[dependencies]
futures-util = { version = "0.3", default-features = false, features = ["std"] }
thrift = "0.13"
thrift = "0.17"
tokio = { version = "1.0", features = ["full"] }
opentelemetry = { path = "../../opentelemetry", features = ["rt-tokio"] }
opentelemetry-jaeger = { path = "../../opentelemetry-jaeger", features = ["rt-tokio"] }
2 changes: 1 addition & 1 deletion examples/basic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ futures-util = { version = "0.3", default-features = false, features = ["std"] }
lazy_static = "1.4"
opentelemetry = { path = "../../opentelemetry", features = ["rt-tokio", "metrics"] }
opentelemetry-jaeger = { path = "../../opentelemetry-jaeger", features = ["rt-tokio"] }
thrift = "0.13"
thrift = "0.17"
tokio = { version = "1.0", features = ["full"] }
2 changes: 1 addition & 1 deletion examples/external-otlp-tonic-tokio/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition = "2021"
publish = false

[dependencies]
env_logger = "0.9.0"
env_logger = "0.10.0"
opentelemetry = {path = "../../opentelemetry", features = ["rt-tokio", "metrics"]}
opentelemetry-otlp = {path = "../../opentelemetry-otlp", features = ["tonic", "tls", "tls-roots"]}
serde_json = "1.0"
Expand Down
6 changes: 3 additions & 3 deletions examples/grpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ doc = false

[dependencies]
http = "0.2"
tonic = "0.6.2"
prost = "0.9"
tonic = "0.8.2"
prost = "0.11"
tokio = { version = "1.0", features = ["full"] }
opentelemetry = { path = "../../opentelemetry" }
opentelemetry-jaeger = { path = "../../opentelemetry-jaeger" }

[build-dependencies]
tonic-build = "0.6.2"
tonic-build = "0.8.2"
2 changes: 1 addition & 1 deletion examples/grpc/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl<'a> Injector for MetadataMap<'a> {
/// Set a key and value in the MetadataMap. Does nothing if the key or value are not valid inputs
fn set(&mut self, key: &str, value: String) {
if let Ok(key) = tonic::metadata::MetadataKey::from_bytes(key.as_bytes()) {
if let Ok(val) = tonic::metadata::MetadataValue::from_str(&value) {
if let Ok(val) = tonic::metadata::MetadataValue::try_from(&value) {
self.0.insert(key, val);
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/http/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "http"
name = "http-example"
version = "0.1.0"
edition = "2021"
publish = false
Expand Down
14 changes: 7 additions & 7 deletions examples/tracing-grpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ path = "src/client.rs"

[dependencies]
http = "0.2"
tonic = "0.6.2"
prost = "0.9"
tonic = "0.8.2"
prost = "0.11"
tokio = { version = "1.0", features = ["full"] }
opentelemetry = { version = "0.14", features = ["rt-tokio"] }
opentelemetry-jaeger = "0.13"
opentelemetry = { version = "0.18", features = ["rt-tokio"] }
opentelemetry-jaeger = "0.17"
tracing = "0.1"
tracing-subscriber = "0.2"
tracing-opentelemetry = "0.13"
tracing-subscriber = "0.3"
tracing-opentelemetry = "0.18"
tracing-futures = "0.2"

[build-dependencies]
tonic-build = "0.6.2"
tonic-build = "0.8.2"
6 changes: 2 additions & 4 deletions examples/tracing-grpc/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ impl<'a> Injector for MetadataMap<'a> {
/// Set a key and value in the MetadataMap. Does nothing if the key or value are not valid inputs
fn set(&mut self, key: &str, value: String) {
if let Ok(key) = tonic::metadata::MetadataKey::from_bytes(key.as_bytes()) {
if let Ok(val) = tonic::metadata::MetadataValue::from_str(&value) {
if let Ok(val) = tonic::metadata::MetadataValue::try_from(&value) {
self.0.insert(key, val);
}
}
Expand Down Expand Up @@ -54,9 +54,7 @@ async fn greet() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
global::set_text_map_propagator(TraceContextPropagator::new());
let tracer = opentelemetry_jaeger::new_pipeline()
.with_service_name("grpc-client")
.install_simple()?;
let tracer = opentelemetry_jaeger::new_agent_pipeline().install_simple()?;
tracing_subscriber::registry()
.with(tracing_subscriber::EnvFilter::new("INFO"))
.with(tracing_opentelemetry::layer().with_tracer(tracer))
Expand Down
2 changes: 1 addition & 1 deletion examples/tracing-grpc/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl Greeter for MyGreeter {
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
global::set_text_map_propagator(TraceContextPropagator::new());
let tracer = opentelemetry_jaeger::new_pipeline()
let tracer = opentelemetry_jaeger::new_agent_pipeline()
.with_service_name("grpc-server")
.install_batch(opentelemetry::runtime::Tokio)?;
tracing_subscriber::registry()
Expand Down
8 changes: 4 additions & 4 deletions opentelemetry-jaeger/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ pin-project-lite = { version = "0.2", optional = true }
reqwest = { version = "0.11", default-features = false, optional = true }
surf = { version = "2.0", optional = true }
thiserror = "1.0"
thrift = "0.16"
thrift = "0.17"
tokio = { version = "1.0", features = ["net", "sync"], optional = true }
wasm-bindgen = { version = "0.2", optional = true }
wasm-bindgen-futures = { version = "0.4.18", optional = true }

tonic = { version = "0.6.2", optional = true }
prost = { version = "0.9.0", optional = true }
prost-types = { version = "0.9.0", optional = true }
tonic = { version = "0.8.2", optional = true }
prost = { version = "0.11.2", optional = true }
prost-types = { version = "0.11.2", optional = true }

[dev-dependencies]
tokio = { version = "1.0", features = ["net", "sync"] }
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-stackdriver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ prost = "0.11.0"
prost-types = "0.11.1"
thiserror = "1.0.30"
tonic = { version = "0.8.0", features = ["gzip", "tls", "transport"] }
yup-oauth2 = { version = "7.0.1", optional = true }
yup-oauth2 = { version = "8.0.0", optional = true }

[features]
default = ["yup-authorizer", "tls-native-roots"]
Expand Down
6 changes: 5 additions & 1 deletion opentelemetry-stackdriver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,13 @@ impl Authorizer for YupAuthorizer {
.await
.map_err(|e| Error::Authorizer(e.into()))?;

let token = token
.token()
.ok_or_else(|| Error::Authorizer("no token".into()))?;

req.metadata_mut().insert(
"authorization",
MetadataValue::try_from(format!("Bearer {}", token.as_str())).unwrap(),
MetadataValue::try_from(format!("Bearer {}", token)).unwrap(),
);
Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-zipkin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ opentelemetry-http = { version = "0.7", path = "../opentelemetry-http", optional
opentelemetry-semantic-conventions = { version = "0.10", path = "../opentelemetry-semantic-conventions" }
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
typed-builder = "0.9"
typed-builder = "0.11"
once_cell = "1.12"
http = "0.2"
reqwest = { version = "0.11", optional = true, default-features = false }
Expand Down