Skip to content

Commit

Permalink
Update to opentelemetry 0.20
Browse files Browse the repository at this point in the history
This upgrade has many changes due to a new metrics API upstream.

Metrics have largely been reworked, and in addition, some new metrics macros have been added to enabled us to move towards a better long term metrics story.
  • Loading branch information
bryn committed Sep 18, 2023
1 parent 871e13e commit 07ddbcc
Show file tree
Hide file tree
Showing 32 changed files with 2,717 additions and 1,805 deletions.
430 changes: 301 additions & 129 deletions Cargo.lock

Large diffs are not rendered by default.

38 changes: 20 additions & 18 deletions apollo-router/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ path = "src/main.rs"
default = ["global-allocator"]

# Set the Rust global allocator on some platforms
# https://doc.rust-lang.org/std/alloc/index.html#the-global_allocator-attribute
# https://doc.rust-lang.org/std/alloc/index.html#the-global, bad_field, bar = "hello"_allocator-attribute
# Enabled by default. Disable default features in library crates or to set it yourself:
# ```
# [dependencies]
Expand Down Expand Up @@ -133,30 +133,35 @@ once_cell = "1.18.0"
# groups `^tracing` and `^opentelemetry*` dependencies together as of
# https://github.com/apollographql/router/pull/1509. A comment which exists
# there (and on `tracing` packages below) should be updated should this change.
opentelemetry = { version = "0.19.0", features = ["rt-tokio", "metrics"] }
opentelemetry_api = "0.19.0"
opentelemetry-aws = "0.7.0"
opentelemetry-datadog = { version = "0.7.0", features = ["reqwest-client"] }
opentelemetry-http = "0.8.0"
opentelemetry-jaeger = { version = "0.18.0", features = [
opentelemetry = { version = "0.20.0", features = [
"rt-tokio",
"metrics",
"testing"
] }
opentelemetry_api = "0.20.0"
opentelemetry-aws = "0.8.0"
opentelemetry-datadog = { version = "0.8.0", features = ["reqwest-client"] }
opentelemetry-http = "0.9.0"
opentelemetry-jaeger = { version = "0.19.0", features = [
"collector_client",
"reqwest_collector_client",
"rt-tokio",
] }
opentelemetry-otlp = { version = "0.12.0", default-features = false, features = [
opentelemetry-otlp = { version = "0.13.0", default-features = false, features = [
"grpc-tonic",
"gzip-tonic",
"tonic",
"tls",
"http-proto",
"metrics",
"reqwest-client",
] }
opentelemetry-semantic-conventions = "0.11.0"
opentelemetry-zipkin = { version = "0.17.0", default-features = false, features = [
opentelemetry-semantic-conventions = "0.12.0"
opentelemetry-zipkin = { version = "0.18.0", default-features = false, features = [
"reqwest-client",
"reqwest-rustls",
] }
opentelemetry-prometheus = "0.12.0"
opentelemetry-prometheus = "0.13.0"
paste = "1.0.14"
pin-project-lite = "0.2.12"
prometheus = "0.13"
Expand Down Expand Up @@ -196,12 +201,7 @@ thiserror = "1.0.48"
tokio = { version = "1.32.0", features = ["full"] }
tokio-stream = { version = "0.1.14", features = ["sync", "net"] }
tokio-util = { version = "0.7.8", features = ["net", "codec", "time"] }
tonic = { version = "0.8.3", features = [
"transport",
"tls",
"tls-roots",
"gzip",
] }
tonic = { version = "0.9.2", features = ["transport", "tls", "tls-roots", "gzip"] }
tower = { version = "0.4.13", features = ["full"] }
tower-http = { version = "0.4.3", features = [
"add-extension",
Expand All @@ -219,7 +219,7 @@ tower-service = "0.3.2"
tracing = "0.1.37"
tracing-core = "0.1.31"
tracing-futures = { version = "0.2.5", features = ["futures-03"] }
tracing-opentelemetry = "0.19.0"
tracing-opentelemetry = "0.21.0"
tracing-subscriber = { version = "0.3.17", features = ["env-filter", "json"] }
url = { version = "2.4.1", features = ["serde"] }
urlencoding = "2.1.3"
Expand Down Expand Up @@ -263,10 +263,12 @@ ecdsa = { version = "0.15.1", features = ["signing", "pem", "pkcs8"] }
fred = { version = "6.3.1", features = ["enable-rustls", "no-client-setname"] }
futures-test = "0.3.28"
insta = { version = "1.31.0", features = ["json", "redactions", "yaml"] }
num-traits = "0.2.16"
maplit = "1.0.2"
memchr = { version = "2.6.3", default-features = false }
mockall = "0.11.4"
once_cell = "1.18.0"
opentelemetry-stdout = { version = "0.1.0", features = ["trace"] }
p256 = "0.12.0"
rand_core = "0.6.4"
redis = { version = "0.21.7", features = ["tokio-comp"] }
Expand Down
9 changes: 7 additions & 2 deletions apollo-router/src/executable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use url::Url;
use crate::configuration::generate_config_schema;
use crate::configuration::generate_upgrade;
use crate::configuration::Discussed;
use crate::metrics::meter_provider;
use crate::plugin::plugins;
use crate::plugins::telemetry::reload::init_telemetry;
use crate::router::ConfigurationSource;
Expand Down Expand Up @@ -468,8 +469,12 @@ impl Executable {
None => Self::inner_start(shutdown, schema, config, license, opt).await,
};

//We should be good to shutdown the tracer provider now as the router should have finished everything.
opentelemetry::global::shutdown_tracer_provider();
// We should be good to shutdown OpenTelemetry now as the router should have finished everything.
tokio::task::spawn_blocking(move || {
opentelemetry::global::shutdown_tracer_provider();
meter_provider().shutdown();
})
.await?;
result
}

Expand Down
3 changes: 3 additions & 0 deletions apollo-router/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ mod json_ext;
#[macro_use]
pub mod plugin;

#[macro_use]
pub(crate) mod metrics;

pub(crate) mod axum_factory;
mod cache;
mod configuration;
Expand Down
Loading

0 comments on commit 07ddbcc

Please sign in to comment.