From 5b38e27559f0ac6046ba5ac2d0428f430f4f8469 Mon Sep 17 00:00:00 2001 From: Gary Pennington Date: Thu, 15 Jun 2023 15:22:05 +0100 Subject: [PATCH 1/8] update otel to 0.19.0 revert the revert --- .changesets/maint_garypen_2878_otel_0_19_0.md | 20 ++++++ Cargo.lock | 72 ++++++++----------- apollo-router/Cargo.toml | 18 ++--- .../plugins/telemetry/metrics/prometheus.rs | 11 ++- ...ry__tests__it_test_prometheus_metrics.snap | 8 +-- ...est_prometheus_metrics_custom_buckets.snap | 32 ++++----- .../src/plugins/telemetry/tracing/datadog.rs | 7 ++ apollo-router/tests/metrics_tests.rs | 4 +- 8 files changed, 93 insertions(+), 79 deletions(-) create mode 100644 .changesets/maint_garypen_2878_otel_0_19_0.md diff --git a/.changesets/maint_garypen_2878_otel_0_19_0.md b/.changesets/maint_garypen_2878_otel_0_19_0.md new file mode 100644 index 0000000000..d0301f8af4 --- /dev/null +++ b/.changesets/maint_garypen_2878_otel_0_19_0.md @@ -0,0 +1,20 @@ +### update opentelemetry to 0.19.0 ([Issue #2878](https://github.com/apollographql/router/issues/2878)) + + +We've updated the following opentelemetry related crates: + +``` +opentelemetry 0.18.0 -> 0.19.0 +opentelemetry-datadog 0.6.0 -> 0.7.0 +opentelemetry-http 0.7.0 -> 0.8.0 +opentelemetry-jaeger 0.17.0 -> 0.18.0 +opentelemetry-otlp 0.11.0 -> 0.12.0 +opentelemetry-semantic-conventions 0.10.0 -> 0.11.0 +opentelemetry-zipkin 0.16.0 -> 0.17.0 +opentelemetry-prometheus 0.11.0 -> 0.12.0 +tracing-opentelemetry 0.18.0 -> 0.19.0 +``` + +This allows us to close a number of opentelemetry related issues. + +By [@garypen](https://github.com/garypen) in https://github.com/apollographql/router/pull/3196 diff --git a/Cargo.lock b/Cargo.lock index 05f3fb9122..9ad6374124 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -232,7 +232,7 @@ dependencies = [ "apollo-ariadne", "apollo-parser 0.5.3", "indexmap", - "ordered-float 2.10.0", + "ordered-float", "rowan", "salsa", "thiserror", @@ -3815,9 +3815,9 @@ dependencies = [ [[package]] name = "opentelemetry" -version = "0.18.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69d6c3d7288a106c0a363e4b0e8d308058d56902adefb16f4936f417ffef086e" +checksum = "5f4b8347cc26099d3aeee044065ecc3ae11469796b4d65d065a23a584ed92a6f" dependencies = [ "opentelemetry_api", "opentelemetry_sdk", @@ -3825,9 +3825,9 @@ dependencies = [ [[package]] name = "opentelemetry-datadog" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "171770efa142d2a19455b7e985037f560b2e75461f822dd1688bfd83c14856f6" +checksum = "daf08569fbddd2149b268e2bde2bca0bab84bc19ee2efcc234f855f49a911536" dependencies = [ "async-trait", "futures-core", @@ -3846,9 +3846,9 @@ dependencies = [ [[package]] name = "opentelemetry-http" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1edc79add46364183ece1a4542592ca593e6421c60807232f5b8f7a31703825d" +checksum = "a819b71d6530c4297b49b3cae2939ab3a8cc1b9f382826a1bc29dd0ca3864906" dependencies = [ "async-trait", "bytes", @@ -3859,9 +3859,9 @@ dependencies = [ [[package]] name = "opentelemetry-jaeger" -version = "0.17.0" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e785d273968748578931e4dc3b4f5ec86b26e09d9e0d66b55adda7fce742f7a" +checksum = "08e028dc9f4f304e9320ce38c80e7cf74067415b1ad5a8750a38bae54a4d450d" dependencies = [ "async-trait", "futures", @@ -3880,9 +3880,9 @@ dependencies = [ [[package]] name = "opentelemetry-otlp" -version = "0.11.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1c928609d087790fc936a1067bdc310ae702bdf3b090c3f281b713622c8bbde" +checksum = "8af72d59a4484654ea8eb183fea5ae4eb6a41d7ac3e3bae5f4d2a282a3a7d3ca" dependencies = [ "async-trait", "futures", @@ -3900,9 +3900,9 @@ dependencies = [ [[package]] name = "opentelemetry-prometheus" -version = "0.11.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06c3d833835a53cf91331d2cfb27e9121f5a95261f31f08a1f79ab31688b8da8" +checksum = "9a9f186f6293ebb693caddd0595e66b74a6068fa51048e26e0bf9c95478c639c" dependencies = [ "opentelemetry", "prometheus", @@ -3911,32 +3911,31 @@ dependencies = [ [[package]] name = "opentelemetry-proto" -version = "0.1.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d61a2f56df5574508dd86aaca016c917489e589ece4141df1b5e349af8d66c28" +checksum = "045f8eea8c0fa19f7d48e7bc3128a39c2e5c533d5c61298c548dfefc1064474c" dependencies = [ "futures", "futures-util", "opentelemetry", "prost", "tonic 0.8.3", - "tonic-build", ] [[package]] name = "opentelemetry-semantic-conventions" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b02e0230abb0ab6636d18e2ba8fa02903ea63772281340ccac18e0af3ec9eeb" +checksum = "24e33428e6bf08c6f7fcea4ddb8e358fab0fe48ab877a87c70c6ebe20f673ce5" dependencies = [ "opentelemetry", ] [[package]] name = "opentelemetry-zipkin" -version = "0.16.0" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bd6a5d672fe50f682d801f6737a54a633834cf8c91be419c0c9cae8ac85bf4d" +checksum = "e1fd48caee5e1db71454c95be32d1daeb6fae265321ff8f51b1efc8a50b0be80" dependencies = [ "async-trait", "futures-core", @@ -3954,25 +3953,25 @@ dependencies = [ [[package]] name = "opentelemetry_api" -version = "0.18.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c24f96e21e7acc813c7a8394ee94978929db2bcc46cf6b5014fc612bf7760c22" +checksum = "ed41783a5bf567688eb38372f2b7a8530f5a607a4b49d38dd7573236c23ca7e2" dependencies = [ "fnv", "futures-channel", "futures-util", "indexmap", - "js-sys", "once_cell", "pin-project-lite", "thiserror", + "urlencoding", ] [[package]] name = "opentelemetry_sdk" -version = "0.18.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ca41c4933371b61c2a2f214bf16931499af4ec90543604ec828f7a625c09113" +checksum = "8b3a2a91fdbfdd4d212c0dcc2ab540de2c2bcbbd90be17de7a7daf8822d010c1" dependencies = [ "async-trait", "crossbeam-channel", @@ -3996,15 +3995,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" -[[package]] -name = "ordered-float" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3305af35278dd29f46fcdd139e0b1fbfae2153f0e5928b39b035542dd31e37b7" -dependencies = [ - "num-traits", -] - [[package]] name = "ordered-float" version = "2.10.0" @@ -5978,14 +5968,14 @@ dependencies = [ [[package]] name = "thrift" -version = "0.16.0" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09678c4cdbb4eed72e18b7c2af1329c69825ed16fcbac62d083fc3e2b0590ff0" +checksum = "7e54bc85fc7faa8bc175c4bab5b92ba8d9a3ce893d0e9f42cc455c8ab16a9e09" dependencies = [ "byteorder", "integer-encoding", "log", - "ordered-float 1.1.1", + "ordered-float", "threadpool", ] @@ -6416,9 +6406,9 @@ dependencies = [ [[package]] name = "tracing-opentelemetry" -version = "0.18.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21ebb87a95ea13271332df069020513ab70bdb5637ca42d6e492dc3bbbad48de" +checksum = "00a39dcf9bfc1742fa4d6215253b33a6e474be78275884c216fc2a06267b3600" dependencies = [ "once_cell", "opentelemetry", @@ -6511,9 +6501,9 @@ dependencies = [ [[package]] name = "typed-builder" -version = "0.9.1" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a46ee5bd706ff79131be9c94e7edcb82b703c487766a114434e5790361cf08c5" +checksum = "6179333b981641242a768f30f371c9baccbfcc03749627000c500ab88bf4528b" dependencies = [ "proc-macro2", "quote", diff --git a/apollo-router/Cargo.toml b/apollo-router/Cargo.toml index c8ead3135d..0a418b0f23 100644 --- a/apollo-router/Cargo.toml +++ b/apollo-router/Cargo.toml @@ -130,18 +130,18 @@ 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.18.0", features = [ +opentelemetry = { version = "0.19.0", features = [ "rt-tokio", "metrics", ] } -opentelemetry-datadog = { version = "0.6.0", features = ["reqwest-client"] } -opentelemetry-http = "0.7.0" -opentelemetry-jaeger = { version = "0.17.0", features = [ +opentelemetry-datadog = { version = "0.7.0", features = ["reqwest-client"] } +opentelemetry-http = "0.8.0" +opentelemetry-jaeger = { version = "0.18.0", features = [ "collector_client", "reqwest_collector_client", "rt-tokio", ] } -opentelemetry-otlp = { version = "0.11.0", default-features = false, features = [ +opentelemetry-otlp = { version = "0.12.0", default-features = false, features = [ "grpc-tonic", "tonic", "tls", @@ -149,12 +149,12 @@ opentelemetry-otlp = { version = "0.11.0", default-features = false, features = "metrics", "reqwest-client", ] } -opentelemetry-semantic-conventions = "0.10.0" -opentelemetry-zipkin = { version = "0.16.0", default-features = false, features = [ +opentelemetry-semantic-conventions = "0.11.0" +opentelemetry-zipkin = { version = "0.17.0", default-features = false, features = [ "reqwest-client", "reqwest-rustls", ] } -opentelemetry-prometheus = "0.11.0" +opentelemetry-prometheus = "0.12.0" paste = "1.0.12" pin-project-lite = "0.2.9" prometheus = "0.13" @@ -207,7 +207,7 @@ tower-service = "0.3.2" tracing = "0.1.37" tracing-core = "0.1.30" tracing-futures = { version = "0.2.5", features = ["futures-03"] } -tracing-opentelemetry = "0.18.0" +tracing-opentelemetry = "0.19.0" tracing-subscriber = { version = "0.3.11", features = ["env-filter", "json"] } url = { version = "2.4.0", features = ["serde"] } urlencoding = "2.1.2" diff --git a/apollo-router/src/plugins/telemetry/metrics/prometheus.rs b/apollo-router/src/plugins/telemetry/metrics/prometheus.rs index 5d6e6c84bb..e5c60e32d8 100644 --- a/apollo-router/src/plugins/telemetry/metrics/prometheus.rs +++ b/apollo-router/src/plugins/telemetry/metrics/prometheus.rs @@ -83,13 +83,10 @@ impl MetricsConfigurator for Config { metrics_config: &MetricsCommon, ) -> Result { if self.enabled { - let mut controller = controllers::basic( - processors::factory( - selectors::simple::histogram(metrics_config.buckets.clone()), - aggregation::stateless_temporality_selector(), - ) - .with_memory(true), - ) + let mut controller = controllers::basic(processors::factory( + selectors::simple::histogram(metrics_config.buckets.clone()), + aggregation::stateless_temporality_selector(), + )) .with_resource(Resource::new( metrics_config .resources diff --git a/apollo-router/src/plugins/telemetry/snapshots/apollo_router__plugins__telemetry__tests__it_test_prometheus_metrics.snap b/apollo-router/src/plugins/telemetry/snapshots/apollo_router__plugins__telemetry__tests__it_test_prometheus_metrics.snap index 2f7bccf9c1..4608c849dc 100644 --- a/apollo-router/src/plugins/telemetry/snapshots/apollo_router__plugins__telemetry__tests__it_test_prometheus_metrics.snap +++ b/apollo-router/src/plugins/telemetry/snapshots/apollo_router__plugins__telemetry__tests__it_test_prometheus_metrics.snap @@ -2,7 +2,7 @@ source: apollo-router/src/plugins/telemetry/mod.rs expression: prom_metrics --- -apollo_router_http_request_duration_seconds_count{another_test="my_default_value",error="400 Bad Request",myname="label_value",renamed_value="my_value_set",service_name="apollo-router",status="400"} 1 -apollo_router_http_request_duration_seconds_count{another_test="my_default_value",my_value="2",myname="label_value",renamed_value="my_value_set",service_name="apollo-router",status="200",x_custom="coming_from_header"} 1 -apollo_router_http_request_duration_seconds_count{error="INTERNAL_SERVER_ERROR",my_key="my_custom_attribute_from_context",query_from_request="query { test }",service_name="apollo-router",status="200",subgraph="my_subgraph_name",unknown_data="default_value"} 1 -apollo_router_http_request_duration_seconds_count{message="cannot contact the subgraph",service_name="apollo-router",status="500",subgraph="my_subgraph_name_error",subgraph_error_extended_code="SUBREQUEST_HTTP_ERROR"} 1 +apollo_router_http_request_duration_seconds_count{another_test="my_default_value",error="400 Bad Request",myname="label_value",renamed_value="my_value_set",service_name="apollo-router",status="400",otel_scope_name="apollo/router",otel_scope_version=""} 1 +apollo_router_http_request_duration_seconds_count{another_test="my_default_value",my_value="2",myname="label_value",renamed_value="my_value_set",service_name="apollo-router",status="200",x_custom="coming_from_header",otel_scope_name="apollo/router",otel_scope_version=""} 1 +apollo_router_http_request_duration_seconds_count{error="INTERNAL_SERVER_ERROR",my_key="my_custom_attribute_from_context",query_from_request="query { test }",service_name="apollo-router",status="200",subgraph="my_subgraph_name",unknown_data="default_value",otel_scope_name="apollo/router",otel_scope_version=""} 1 +apollo_router_http_request_duration_seconds_count{message="cannot contact the subgraph",service_name="apollo-router",status="500",subgraph="my_subgraph_name_error",subgraph_error_extended_code="SUBREQUEST_HTTP_ERROR",otel_scope_name="apollo/router",otel_scope_version=""} 1 diff --git a/apollo-router/src/plugins/telemetry/snapshots/apollo_router__plugins__telemetry__tests__it_test_prometheus_metrics_custom_buckets.snap b/apollo-router/src/plugins/telemetry/snapshots/apollo_router__plugins__telemetry__tests__it_test_prometheus_metrics_custom_buckets.snap index a973b2aaae..eecbdbd9fe 100644 --- a/apollo-router/src/plugins/telemetry/snapshots/apollo_router__plugins__telemetry__tests__it_test_prometheus_metrics_custom_buckets.snap +++ b/apollo-router/src/plugins/telemetry/snapshots/apollo_router__plugins__telemetry__tests__it_test_prometheus_metrics_custom_buckets.snap @@ -2,19 +2,19 @@ source: apollo-router/src/plugins/telemetry/mod.rs expression: prom_metrics --- -apollo_router_http_request_duration_seconds_bucket{another_test="my_default_value",error="400 Bad Request",myname="label_value",renamed_value="my_value_set",service_name="apollo-router",status="400",le="+Inf"} 1 -apollo_router_http_request_duration_seconds_bucket{another_test="my_default_value",error="400 Bad Request",myname="label_value",renamed_value="my_value_set",service_name="apollo-router",status="400",le="10"} 1 -apollo_router_http_request_duration_seconds_bucket{another_test="my_default_value",error="400 Bad Request",myname="label_value",renamed_value="my_value_set",service_name="apollo-router",status="400",le="20"} 1 -apollo_router_http_request_duration_seconds_bucket{another_test="my_default_value",error="400 Bad Request",myname="label_value",renamed_value="my_value_set",service_name="apollo-router",status="400",le="5"} 1 -apollo_router_http_request_duration_seconds_bucket{another_test="my_default_value",my_value="2",myname="label_value",renamed_value="my_value_set",service_name="apollo-router",status="200",x_custom="coming_from_header",le="+Inf"} 1 -apollo_router_http_request_duration_seconds_bucket{another_test="my_default_value",my_value="2",myname="label_value",renamed_value="my_value_set",service_name="apollo-router",status="200",x_custom="coming_from_header",le="10"} 1 -apollo_router_http_request_duration_seconds_bucket{another_test="my_default_value",my_value="2",myname="label_value",renamed_value="my_value_set",service_name="apollo-router",status="200",x_custom="coming_from_header",le="20"} 1 -apollo_router_http_request_duration_seconds_bucket{another_test="my_default_value",my_value="2",myname="label_value",renamed_value="my_value_set",service_name="apollo-router",status="200",x_custom="coming_from_header",le="5"} 1 -apollo_router_http_request_duration_seconds_bucket{error="INTERNAL_SERVER_ERROR",my_key="my_custom_attribute_from_context",query_from_request="query { test }",service_name="apollo-router",status="200",subgraph="my_subgraph_name",unknown_data="default_value",le="+Inf"} 1 -apollo_router_http_request_duration_seconds_bucket{error="INTERNAL_SERVER_ERROR",my_key="my_custom_attribute_from_context",query_from_request="query { test }",service_name="apollo-router",status="200",subgraph="my_subgraph_name",unknown_data="default_value",le="10"} 1 -apollo_router_http_request_duration_seconds_bucket{error="INTERNAL_SERVER_ERROR",my_key="my_custom_attribute_from_context",query_from_request="query { test }",service_name="apollo-router",status="200",subgraph="my_subgraph_name",unknown_data="default_value",le="20"} 1 -apollo_router_http_request_duration_seconds_bucket{error="INTERNAL_SERVER_ERROR",my_key="my_custom_attribute_from_context",query_from_request="query { test }",service_name="apollo-router",status="200",subgraph="my_subgraph_name",unknown_data="default_value",le="5"} 1 -apollo_router_http_request_duration_seconds_bucket{message="cannot contact the subgraph",service_name="apollo-router",status="500",subgraph="my_subgraph_name_error",subgraph_error_extended_code="SUBREQUEST_HTTP_ERROR",le="+Inf"} 1 -apollo_router_http_request_duration_seconds_bucket{message="cannot contact the subgraph",service_name="apollo-router",status="500",subgraph="my_subgraph_name_error",subgraph_error_extended_code="SUBREQUEST_HTTP_ERROR",le="10"} 1 -apollo_router_http_request_duration_seconds_bucket{message="cannot contact the subgraph",service_name="apollo-router",status="500",subgraph="my_subgraph_name_error",subgraph_error_extended_code="SUBREQUEST_HTTP_ERROR",le="20"} 1 -apollo_router_http_request_duration_seconds_bucket{message="cannot contact the subgraph",service_name="apollo-router",status="500",subgraph="my_subgraph_name_error",subgraph_error_extended_code="SUBREQUEST_HTTP_ERROR",le="5"} 1 +apollo_router_http_request_duration_seconds_bucket{another_test="my_default_value",error="400 Bad Request",myname="label_value",renamed_value="my_value_set",service_name="apollo-router",status="400",otel_scope_name="apollo/router",otel_scope_version="",le="+Inf"} 1 +apollo_router_http_request_duration_seconds_bucket{another_test="my_default_value",error="400 Bad Request",myname="label_value",renamed_value="my_value_set",service_name="apollo-router",status="400",otel_scope_name="apollo/router",otel_scope_version="",le="10"} 1 +apollo_router_http_request_duration_seconds_bucket{another_test="my_default_value",error="400 Bad Request",myname="label_value",renamed_value="my_value_set",service_name="apollo-router",status="400",otel_scope_name="apollo/router",otel_scope_version="",le="20"} 1 +apollo_router_http_request_duration_seconds_bucket{another_test="my_default_value",error="400 Bad Request",myname="label_value",renamed_value="my_value_set",service_name="apollo-router",status="400",otel_scope_name="apollo/router",otel_scope_version="",le="5"} 1 +apollo_router_http_request_duration_seconds_bucket{another_test="my_default_value",my_value="2",myname="label_value",renamed_value="my_value_set",service_name="apollo-router",status="200",x_custom="coming_from_header",otel_scope_name="apollo/router",otel_scope_version="",le="+Inf"} 1 +apollo_router_http_request_duration_seconds_bucket{another_test="my_default_value",my_value="2",myname="label_value",renamed_value="my_value_set",service_name="apollo-router",status="200",x_custom="coming_from_header",otel_scope_name="apollo/router",otel_scope_version="",le="10"} 1 +apollo_router_http_request_duration_seconds_bucket{another_test="my_default_value",my_value="2",myname="label_value",renamed_value="my_value_set",service_name="apollo-router",status="200",x_custom="coming_from_header",otel_scope_name="apollo/router",otel_scope_version="",le="20"} 1 +apollo_router_http_request_duration_seconds_bucket{another_test="my_default_value",my_value="2",myname="label_value",renamed_value="my_value_set",service_name="apollo-router",status="200",x_custom="coming_from_header",otel_scope_name="apollo/router",otel_scope_version="",le="5"} 1 +apollo_router_http_request_duration_seconds_bucket{error="INTERNAL_SERVER_ERROR",my_key="my_custom_attribute_from_context",query_from_request="query { test }",service_name="apollo-router",status="200",subgraph="my_subgraph_name",unknown_data="default_value",otel_scope_name="apollo/router",otel_scope_version="",le="+Inf"} 1 +apollo_router_http_request_duration_seconds_bucket{error="INTERNAL_SERVER_ERROR",my_key="my_custom_attribute_from_context",query_from_request="query { test }",service_name="apollo-router",status="200",subgraph="my_subgraph_name",unknown_data="default_value",otel_scope_name="apollo/router",otel_scope_version="",le="10"} 1 +apollo_router_http_request_duration_seconds_bucket{error="INTERNAL_SERVER_ERROR",my_key="my_custom_attribute_from_context",query_from_request="query { test }",service_name="apollo-router",status="200",subgraph="my_subgraph_name",unknown_data="default_value",otel_scope_name="apollo/router",otel_scope_version="",le="20"} 1 +apollo_router_http_request_duration_seconds_bucket{error="INTERNAL_SERVER_ERROR",my_key="my_custom_attribute_from_context",query_from_request="query { test }",service_name="apollo-router",status="200",subgraph="my_subgraph_name",unknown_data="default_value",otel_scope_name="apollo/router",otel_scope_version="",le="5"} 1 +apollo_router_http_request_duration_seconds_bucket{message="cannot contact the subgraph",service_name="apollo-router",status="500",subgraph="my_subgraph_name_error",subgraph_error_extended_code="SUBREQUEST_HTTP_ERROR",otel_scope_name="apollo/router",otel_scope_version="",le="+Inf"} 1 +apollo_router_http_request_duration_seconds_bucket{message="cannot contact the subgraph",service_name="apollo-router",status="500",subgraph="my_subgraph_name_error",subgraph_error_extended_code="SUBREQUEST_HTTP_ERROR",otel_scope_name="apollo/router",otel_scope_version="",le="10"} 1 +apollo_router_http_request_duration_seconds_bucket{message="cannot contact the subgraph",service_name="apollo-router",status="500",subgraph="my_subgraph_name_error",subgraph_error_extended_code="SUBREQUEST_HTTP_ERROR",otel_scope_name="apollo/router",otel_scope_version="",le="20"} 1 +apollo_router_http_request_duration_seconds_bucket{message="cannot contact the subgraph",service_name="apollo-router",status="500",subgraph="my_subgraph_name_error",subgraph_error_extended_code="SUBREQUEST_HTTP_ERROR",otel_scope_name="apollo/router",otel_scope_version="",le="5"} 1 diff --git a/apollo-router/src/plugins/telemetry/tracing/datadog.rs b/apollo-router/src/plugins/telemetry/tracing/datadog.rs index f56e9801b6..70fa2ca657 100644 --- a/apollo-router/src/plugins/telemetry/tracing/datadog.rs +++ b/apollo-router/src/plugins/telemetry/tracing/datadog.rs @@ -78,6 +78,13 @@ impl TracingConfigurator for Config { }) }) .with_service_name(trace_config.service_name.clone()) + .with_version( + opentelemetry::sdk::trace::Config::from(trace_config) + .resource + .get(opentelemetry_semantic_conventions::resource::SERVICE_VERSION) + .expect("cargo version is set as a resource default;qed") + .to_string(), + ) .with_trace_config(trace_config.into()) .build_exporter()?; Ok(builder.with_span_processor( diff --git a/apollo-router/tests/metrics_tests.rs b/apollo-router/tests/metrics_tests.rs index d4f643176c..25dfca072c 100644 --- a/apollo-router/tests/metrics_tests.rs +++ b/apollo-router/tests/metrics_tests.rs @@ -41,8 +41,8 @@ async fn test_metrics_reloading() -> Result<(), BoxError> { router.assert_reloaded().await; } - router.assert_metrics_contains(r#"apollo_router_cache_hit_count{kind="query planner",service_name="apollo-router",storage="memory"} 4"#, None).await; - router.assert_metrics_contains(r#"apollo_router_cache_miss_count{kind="query planner",service_name="apollo-router",storage="memory"} 2"#, None).await; + router.assert_metrics_contains(r#"apollo_router_cache_hit_count_total{kind="query planner",service_name="apollo-router",storage="memory",otel_scope_name="apollo/router",otel_scope_version=""} 4"#, None).await; + router.assert_metrics_contains(r#"apollo_router_cache_miss_count_total{kind="query planner",service_name="apollo-router",storage="memory",otel_scope_name="apollo/router",otel_scope_version=""} 2"#, None).await; router .assert_metrics_contains(r#"apollo_router_cache_hit_time"#, None) .await; From 47e64483b56949ce6b5d06918e289fd3a591244e Mon Sep 17 00:00:00 2001 From: Gary Pennington Date: Thu, 22 Jun 2023 10:18:10 +0100 Subject: [PATCH 2/8] cargo check --- Cargo.lock | 65 +++++++++++++++++++++++++++--------------------------- 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6b95551819..d592847572 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3821,9 +3821,9 @@ dependencies = [ [[package]] name = "opentelemetry" -version = "0.18.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69d6c3d7288a106c0a363e4b0e8d308058d56902adefb16f4936f417ffef086e" +checksum = "5f4b8347cc26099d3aeee044065ecc3ae11469796b4d65d065a23a584ed92a6f" dependencies = [ "opentelemetry_api", "opentelemetry_sdk", @@ -3831,9 +3831,9 @@ dependencies = [ [[package]] name = "opentelemetry-datadog" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "171770efa142d2a19455b7e985037f560b2e75461f822dd1688bfd83c14856f6" +checksum = "daf08569fbddd2149b268e2bde2bca0bab84bc19ee2efcc234f855f49a911536" dependencies = [ "async-trait", "futures-core", @@ -3852,9 +3852,9 @@ dependencies = [ [[package]] name = "opentelemetry-http" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1edc79add46364183ece1a4542592ca593e6421c60807232f5b8f7a31703825d" +checksum = "a819b71d6530c4297b49b3cae2939ab3a8cc1b9f382826a1bc29dd0ca3864906" dependencies = [ "async-trait", "bytes", @@ -3865,9 +3865,9 @@ dependencies = [ [[package]] name = "opentelemetry-jaeger" -version = "0.17.0" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e785d273968748578931e4dc3b4f5ec86b26e09d9e0d66b55adda7fce742f7a" +checksum = "08e028dc9f4f304e9320ce38c80e7cf74067415b1ad5a8750a38bae54a4d450d" dependencies = [ "async-trait", "futures", @@ -3886,9 +3886,9 @@ dependencies = [ [[package]] name = "opentelemetry-otlp" -version = "0.11.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1c928609d087790fc936a1067bdc310ae702bdf3b090c3f281b713622c8bbde" +checksum = "8af72d59a4484654ea8eb183fea5ae4eb6a41d7ac3e3bae5f4d2a282a3a7d3ca" dependencies = [ "async-trait", "futures", @@ -3906,9 +3906,9 @@ dependencies = [ [[package]] name = "opentelemetry-prometheus" -version = "0.11.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06c3d833835a53cf91331d2cfb27e9121f5a95261f31f08a1f79ab31688b8da8" +checksum = "9a9f186f6293ebb693caddd0595e66b74a6068fa51048e26e0bf9c95478c639c" dependencies = [ "opentelemetry", "prometheus", @@ -3917,32 +3917,31 @@ dependencies = [ [[package]] name = "opentelemetry-proto" -version = "0.1.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d61a2f56df5574508dd86aaca016c917489e589ece4141df1b5e349af8d66c28" +checksum = "045f8eea8c0fa19f7d48e7bc3128a39c2e5c533d5c61298c548dfefc1064474c" dependencies = [ "futures", "futures-util", "opentelemetry", "prost", "tonic 0.8.3", - "tonic-build", ] [[package]] name = "opentelemetry-semantic-conventions" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b02e0230abb0ab6636d18e2ba8fa02903ea63772281340ccac18e0af3ec9eeb" +checksum = "24e33428e6bf08c6f7fcea4ddb8e358fab0fe48ab877a87c70c6ebe20f673ce5" dependencies = [ "opentelemetry", ] [[package]] name = "opentelemetry-zipkin" -version = "0.16.0" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bd6a5d672fe50f682d801f6737a54a633834cf8c91be419c0c9cae8ac85bf4d" +checksum = "e1fd48caee5e1db71454c95be32d1daeb6fae265321ff8f51b1efc8a50b0be80" dependencies = [ "async-trait", "futures-core", @@ -3960,25 +3959,25 @@ dependencies = [ [[package]] name = "opentelemetry_api" -version = "0.18.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c24f96e21e7acc813c7a8394ee94978929db2bcc46cf6b5014fc612bf7760c22" +checksum = "ed41783a5bf567688eb38372f2b7a8530f5a607a4b49d38dd7573236c23ca7e2" dependencies = [ "fnv", "futures-channel", "futures-util", "indexmap", - "js-sys", "once_cell", "pin-project-lite", "thiserror", + "urlencoding", ] [[package]] name = "opentelemetry_sdk" -version = "0.18.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ca41c4933371b61c2a2f214bf16931499af4ec90543604ec828f7a625c09113" +checksum = "8b3a2a91fdbfdd4d212c0dcc2ab540de2c2bcbbd90be17de7a7daf8822d010c1" dependencies = [ "async-trait", "crossbeam-channel", @@ -4004,9 +4003,9 @@ checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" [[package]] name = "ordered-float" -version = "1.1.1" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3305af35278dd29f46fcdd139e0b1fbfae2153f0e5928b39b035542dd31e37b7" +checksum = "7940cf2ca942593318d07fcf2596cdca60a85c9e7fab408a5e21a4f9dcd40d87" dependencies = [ "num-traits", ] @@ -5984,14 +5983,14 @@ dependencies = [ [[package]] name = "thrift" -version = "0.16.0" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09678c4cdbb4eed72e18b7c2af1329c69825ed16fcbac62d083fc3e2b0590ff0" +checksum = "7e54bc85fc7faa8bc175c4bab5b92ba8d9a3ce893d0e9f42cc455c8ab16a9e09" dependencies = [ "byteorder", "integer-encoding", "log", - "ordered-float 1.1.1", + "ordered-float 2.10.0", "threadpool", ] @@ -6438,9 +6437,9 @@ dependencies = [ [[package]] name = "tracing-opentelemetry" -version = "0.18.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21ebb87a95ea13271332df069020513ab70bdb5637ca42d6e492dc3bbbad48de" +checksum = "00a39dcf9bfc1742fa4d6215253b33a6e474be78275884c216fc2a06267b3600" dependencies = [ "once_cell", "opentelemetry", @@ -6574,9 +6573,9 @@ dependencies = [ [[package]] name = "typed-builder" -version = "0.9.1" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a46ee5bd706ff79131be9c94e7edcb82b703c487766a114434e5790361cf08c5" +checksum = "6179333b981641242a768f30f371c9baccbfcc03749627000c500ab88bf4528b" dependencies = [ "proc-macro2", "quote", From a5164b683fb2aa443a6d535ca4346f31f913870a Mon Sep 17 00:00:00 2001 From: Gary Pennington Date: Wed, 12 Jul 2023 14:13:04 +0100 Subject: [PATCH 3/8] cargo lint --- apollo-router/src/plugins/telemetry/tracing/datadog.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/apollo-router/src/plugins/telemetry/tracing/datadog.rs b/apollo-router/src/plugins/telemetry/tracing/datadog.rs index b2c7f0538a..4d4cddbc29 100644 --- a/apollo-router/src/plugins/telemetry/tracing/datadog.rs +++ b/apollo-router/src/plugins/telemetry/tracing/datadog.rs @@ -10,7 +10,6 @@ use opentelemetry::Key; use opentelemetry::Value; use opentelemetry_semantic_conventions::resource::SERVICE_NAME; use opentelemetry_semantic_conventions::resource::SERVICE_VERSION; - use schemars::JsonSchema; use serde::Deserialize; use serde::Serialize; From 9289226a360cff1fd1deb523ad2e430084c2845d Mon Sep 17 00:00:00 2001 From: Gary Pennington Date: Wed, 12 Jul 2023 14:14:37 +0100 Subject: [PATCH 4/8] add a changeset --- .changesets/maint_garypen_2878_otel_0.19_0.md | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .changesets/maint_garypen_2878_otel_0.19_0.md diff --git a/.changesets/maint_garypen_2878_otel_0.19_0.md b/.changesets/maint_garypen_2878_otel_0.19_0.md new file mode 100644 index 0000000000..32b860cf79 --- /dev/null +++ b/.changesets/maint_garypen_2878_otel_0.19_0.md @@ -0,0 +1,20 @@ +### update opentelemetry to 0.19.0 ([Issue #2878](https://github.com/apollographql/router/issues/2878)) + + +We've updated the following opentelemetry related crates: + +``` +opentelemetry 0.18.0 -> 0.19.0 +opentelemetry-datadog 0.6.0 -> 0.7.0 +opentelemetry-http 0.7.0 -> 0.8.0 +opentelemetry-jaeger 0.17.0 -> 0.18.0 +opentelemetry-otlp 0.11.0 -> 0.12.0 +opentelemetry-semantic-conventions 0.10.0 -> 0.11.0 +opentelemetry-zipkin 0.16.0 -> 0.17.0 +opentelemetry-prometheus 0.11.0 -> 0.12.0 +tracing-opentelemetry 0.18.0 -> 0.19.0 +``` + +This allows us to close a number of opentelemetry related issues. + +By [@garypen](https://github.com/garypen) in https://github.com/apollographql/router/pull/XXXX From 197be62b5f0206882a9db1677d09f05010cded17 Mon Sep 17 00:00:00 2001 From: Gary Pennington Date: Wed, 12 Jul 2023 14:18:21 +0100 Subject: [PATCH 5/8] remove duplicate changeset sigh... --- .changesets/maint_garypen_2878_otel_0.19_0.md | 20 ------------------- 1 file changed, 20 deletions(-) delete mode 100644 .changesets/maint_garypen_2878_otel_0.19_0.md diff --git a/.changesets/maint_garypen_2878_otel_0.19_0.md b/.changesets/maint_garypen_2878_otel_0.19_0.md deleted file mode 100644 index 32b860cf79..0000000000 --- a/.changesets/maint_garypen_2878_otel_0.19_0.md +++ /dev/null @@ -1,20 +0,0 @@ -### update opentelemetry to 0.19.0 ([Issue #2878](https://github.com/apollographql/router/issues/2878)) - - -We've updated the following opentelemetry related crates: - -``` -opentelemetry 0.18.0 -> 0.19.0 -opentelemetry-datadog 0.6.0 -> 0.7.0 -opentelemetry-http 0.7.0 -> 0.8.0 -opentelemetry-jaeger 0.17.0 -> 0.18.0 -opentelemetry-otlp 0.11.0 -> 0.12.0 -opentelemetry-semantic-conventions 0.10.0 -> 0.11.0 -opentelemetry-zipkin 0.16.0 -> 0.17.0 -opentelemetry-prometheus 0.11.0 -> 0.12.0 -tracing-opentelemetry 0.18.0 -> 0.19.0 -``` - -This allows us to close a number of opentelemetry related issues. - -By [@garypen](https://github.com/garypen) in https://github.com/apollographql/router/pull/XXXX From dd1aaf1c743fc9f7e8af1c22a0cae84616b9b5b7 Mon Sep 17 00:00:00 2001 From: Gary Pennington Date: Wed, 12 Jul 2023 14:24:53 +0100 Subject: [PATCH 6/8] update PR number --- .changesets/maint_garypen_2878_otel_0_19_0.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changesets/maint_garypen_2878_otel_0_19_0.md b/.changesets/maint_garypen_2878_otel_0_19_0.md index d0301f8af4..1ec22787ca 100644 --- a/.changesets/maint_garypen_2878_otel_0_19_0.md +++ b/.changesets/maint_garypen_2878_otel_0_19_0.md @@ -17,4 +17,4 @@ tracing-opentelemetry 0.18.0 -> 0.19.0 This allows us to close a number of opentelemetry related issues. -By [@garypen](https://github.com/garypen) in https://github.com/apollographql/router/pull/3196 +By [@garypen](https://github.com/garypen) in https://github.com/apollographql/router/pull/3421 From 2d843c71dc3f960572e381707d294964a70519d2 Mon Sep 17 00:00:00 2001 From: Gary Pennington Date: Wed, 12 Jul 2023 14:48:29 +0100 Subject: [PATCH 7/8] add a note about the renamed metrics --- .changesets/maint_garypen_2878_otel_0_19_0.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.changesets/maint_garypen_2878_otel_0_19_0.md b/.changesets/maint_garypen_2878_otel_0_19_0.md index 1ec22787ca..7271edbe17 100644 --- a/.changesets/maint_garypen_2878_otel_0_19_0.md +++ b/.changesets/maint_garypen_2878_otel_0_19_0.md @@ -17,4 +17,15 @@ tracing-opentelemetry 0.18.0 -> 0.19.0 This allows us to close a number of opentelemetry related issues. +Note: + +The prometheus specification mandates naming format and, unfortunately, the router had two metrics which weren't compliant. The otel upgrade enforces the specification, so the affected metrics are now renamed (see below). + +The two affected metrics in the router were: + +apollo_router_cache_hit_count -> apollo_router_cache_hit_count_total +apollo_router_cache_miss_count -> apollo_router_cache_miss_count_total + +If you are monitoring these metrics via prometheus, please update your dashboards with this name change. + By [@garypen](https://github.com/garypen) in https://github.com/apollographql/router/pull/3421 From 8bdf325bcfad863ac604c3efea3fcc12a46545be Mon Sep 17 00:00:00 2001 From: Gary Pennington Date: Wed, 12 Jul 2023 15:10:59 +0100 Subject: [PATCH 8/8] fix test which doesn't run as part of our test suite unless you set environment variables... --- apollo-router/tests/metrics_tests.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apollo-router/tests/metrics_tests.rs b/apollo-router/tests/metrics_tests.rs index 65a3c704a6..2dca27af51 100644 --- a/apollo-router/tests/metrics_tests.rs +++ b/apollo-router/tests/metrics_tests.rs @@ -60,8 +60,8 @@ async fn test_metrics_reloading() -> Result<(), BoxError> { .await; if std::env::var("APOLLO_KEY").is_ok() && std::env::var("APOLLO_GRAPH_REF").is_ok() { - router.assert_metrics_contains(r#"apollo_router_uplink_fetch_duration_seconds_count{kind="unchanged",query="License",service_name="apollo-router",url="https://uplink.api.apollographql.com/"}"#, Some(Duration::from_secs(120))).await; - router.assert_metrics_contains(r#"apollo_router_uplink_fetch_count_total{query="License",service_name="apollo-router",status="success"}"#, Some(Duration::from_secs(1))).await; + router.assert_metrics_contains(r#"apollo_router_uplink_fetch_duration_seconds_count{kind="unchanged",query="License",service_name="apollo-router",url="https://uplink.api.apollographql.com/",otel_scope_name="apollo/router",otel_scope_version=""}"#, Some(Duration::from_secs(120))).await; + router.assert_metrics_contains(r#"apollo_router_uplink_fetch_count_total{query="License",service_name="apollo-router",status="success",otel_scope_name="apollo/router",otel_scope_version=""}"#, Some(Duration::from_secs(1))).await; } Ok(())