From b77af1930e46812a92408f59d70027646c393efc Mon Sep 17 00:00:00 2001 From: bryn Date: Wed, 30 Nov 2022 12:42:54 +0000 Subject: [PATCH] Added Apollo Tracing support for `@defer`. You can now view traces in Apollo Studio as normal. Fixes #1600 --- NEXT_CHANGELOG.md | 6 + apollo-router/Cargo.toml | 2 +- .../src/plugins/telemetry/apollo_exporter.rs | 11 +- apollo-router/src/plugins/telemetry/mod.rs | 21 +- .../src/plugins/telemetry/tracing/apollo.rs | 3 +- .../telemetry/tracing/apollo_telemetry.rs | 748 ++++++--- ...pollo_telemetry__test__condition_else.snap | 584 +++++++ ..._apollo_telemetry__test__condition_if.snap | 595 +++++++ ...ing__apollo_telemetry__test__trace_id.snap | 598 +++++++ .../testdata/condition_else_spandata.yaml | 1222 ++++++++++++++ .../testdata/condition_if_spandata.yaml | 1402 +++++++++++++++++ apollo-router/src/query_planner/execution.rs | 262 +-- apollo-router/src/query_planner/mod.rs | 6 + apollo-router/src/query_planner/plan.rs | 11 - .../src/spaceport/proto/reports.proto | 2 +- xtask/src/commands/all.rs | 2 +- 16 files changed, 5138 insertions(+), 337 deletions(-) create mode 100644 apollo-router/src/plugins/telemetry/tracing/snapshots/apollo_router__plugins__telemetry__tracing__apollo_telemetry__test__condition_else.snap create mode 100644 apollo-router/src/plugins/telemetry/tracing/snapshots/apollo_router__plugins__telemetry__tracing__apollo_telemetry__test__condition_if.snap create mode 100644 apollo-router/src/plugins/telemetry/tracing/snapshots/apollo_router__plugins__telemetry__tracing__apollo_telemetry__test__trace_id.snap create mode 100644 apollo-router/src/plugins/telemetry/tracing/testdata/condition_else_spandata.yaml create mode 100644 apollo-router/src/plugins/telemetry/tracing/testdata/condition_if_spandata.yaml diff --git a/NEXT_CHANGELOG.md b/NEXT_CHANGELOG.md index 74945587992..cf7197efed0 100644 --- a/NEXT_CHANGELOG.md +++ b/NEXT_CHANGELOG.md @@ -238,6 +238,12 @@ supergraph: By [@Geal](https://github.com/Geal) in https://github.com/apollographql/router/pull/2155 +### `@defer` Apollo tracing support ([Issue #1600](https://github.com/apollographql/router/issues/1600)) + +Added Apollo tracing support for queries that use `@defer`. You can now view traces in Apollo Studio as normal. + +By [@bryncooke](https://github.com/bryncooke) in https://github.com/apollographql/router/pull/2190 + ## 🐛 Fixes ### fix build_docker_image.sh script when using default repo ([PR #2163](https://github.com/apollographql/router/pull/2163)) diff --git a/apollo-router/Cargo.toml b/apollo-router/Cargo.toml index 680e3838370..4b4fd1d7de0 100644 --- a/apollo-router/Cargo.toml +++ b/apollo-router/Cargo.toml @@ -202,7 +202,7 @@ uname = "0.1.1" uname = "0.1.1" [dev-dependencies] -insta = { version = "1.21.2", features = ["json", "redactions"] } +insta = { version = "1.21.2", features = ["json", "redactions", "yaml"] } introspector-gadget = "0.1.0" maplit = "1.0.2" memchr = { version = "2.5.0", default-features = false } diff --git a/apollo-router/src/plugins/telemetry/apollo_exporter.rs b/apollo-router/src/plugins/telemetry/apollo_exporter.rs index 8392ae27810..eda5b7bc648 100644 --- a/apollo-router/src/plugins/telemetry/apollo_exporter.rs +++ b/apollo-router/src/plugins/telemetry/apollo_exporter.rs @@ -1,4 +1,5 @@ //! Configuration for apollo telemetry exporter. +use std::sync::{Arc, Mutex}; // This entire file is license key functionality use std::time::Duration; @@ -31,20 +32,26 @@ pub(crate) const POOL_TIMEOUT: Duration = Duration::from_secs(5); pub(crate) enum Sender { Noop, Spaceport(mpsc::Sender), + #[cfg(test)] + InMemory(Arc>>), } impl Sender { - pub(crate) fn send(&self, metrics: SingleReport) { + pub(crate) fn send(&self, report: SingleReport) { match &self { Sender::Noop => {} Sender::Spaceport(channel) => { - if let Err(err) = channel.to_owned().try_send(metrics) { + if let Err(err) = channel.to_owned().try_send(report) { tracing::warn!( "could not send metrics to spaceport, metric will be dropped: {}", err ); } } + #[cfg(test)] + Sender::InMemory(storage) => { + storage.lock().expect("mutex poisoned").push(report); + } } } } diff --git a/apollo-router/src/plugins/telemetry/mod.rs b/apollo-router/src/plugins/telemetry/mod.rs index 33295f8d1c2..6a931b1bb45 100644 --- a/apollo-router/src/plugins/telemetry/mod.rs +++ b/apollo-router/src/plugins/telemetry/mod.rs @@ -122,7 +122,6 @@ const CLIENT_VERSION: &str = "apollo_telemetry::client_version"; const ATTRIBUTES: &str = "apollo_telemetry::metrics_attributes"; const SUBGRAPH_ATTRIBUTES: &str = "apollo_telemetry::subgraph_metrics_attributes"; pub(crate) const STUDIO_EXCLUDE: &str = "apollo_telemetry::studio::exclude"; -pub(crate) const FTV1_DO_NOT_SAMPLE: &str = "apollo_telemetry::studio::ftv1_do_not_sample"; pub(crate) const LOGGING_DISPLAY_HEADERS: &str = "apollo_telemetry::logging::display_headers"; pub(crate) const LOGGING_DISPLAY_BODY: &str = "apollo_telemetry::logging::display_body"; const DEFAULT_SERVICE_NAME: &str = "apollo-router"; @@ -281,13 +280,6 @@ impl Plugin for Telemetry { fn execution_service(&self, service: execution::BoxService) -> execution::BoxService { ServiceBuilder::new() .instrument(move |req: &ExecutionRequest| { - // disable ftv1 sampling for deferred queries - let do_not_sample_reason = if req.query_plan.root.contains_condition_or_defer() { - req.context.insert(FTV1_DO_NOT_SAMPLE, true).unwrap(); - "query is deferred" - } else { - "" - }; let query = req .supergraph_request .body() @@ -304,7 +296,6 @@ impl Plugin for Telemetry { graphql.document = query.as_str(), graphql.operation.name = operation_name.as_str(), "otel.kind" = %SpanKind::Internal, - ftv1.do_not_sample_reason = do_not_sample_reason ) }) .service(service) @@ -707,7 +698,7 @@ impl Telemetry { apollo_private.http.request_headers = field::Empty ); - if is_span_sampled(&request.context) { + if is_span_sampled() { span.record( "apollo_private.graphql.variables", &Self::filter_variables_values( @@ -1185,7 +1176,7 @@ impl Telemetry { has_errors: bool, duration: Duration, ) { - if is_span_sampled(context) { + if is_span_sampled() { ::tracing::trace!("span is sampled then skip the apollo metrics"); return; } @@ -1294,12 +1285,8 @@ fn handle_error>(err: T) { } #[inline] -pub(crate) fn is_span_sampled(context: &Context) -> bool { +pub(crate) fn is_span_sampled() -> bool { Span::current().context().span().span_context().is_sampled() - && !context - .get(FTV1_DO_NOT_SAMPLE) - .unwrap_or_default() - .unwrap_or(false) } register_plugin!("apollo", "telemetry", Telemetry); @@ -1315,7 +1302,7 @@ enum ApolloFtv1Handler { impl ApolloFtv1Handler { fn request_ftv1(&self, mut req: SubgraphRequest) -> SubgraphRequest { if let ApolloFtv1Handler::Enabled = self { - if is_span_sampled(&req.context) { + if is_span_sampled() { req.subgraph_request.headers_mut().insert( "apollo-federation-include-trace", HeaderValue::from_static("ftv1"), diff --git a/apollo-router/src/plugins/telemetry/tracing/apollo.rs b/apollo-router/src/plugins/telemetry/tracing/apollo.rs index 969c1a22474..46ddbb785af 100644 --- a/apollo-router/src/plugins/telemetry/tracing/apollo.rs +++ b/apollo-router/src/plugins/telemetry/tracing/apollo.rs @@ -11,7 +11,7 @@ use crate::plugins::telemetry::tracing::TracingConfigurator; use crate::spaceport::Trace; impl TracingConfigurator for Config { - fn apply(&self, builder: Builder, trace_config: &config::Trace) -> Result { + fn apply(&self, builder: Builder, _trace_config: &config::Trace) -> Result { tracing::debug!("configuring Apollo tracing"); Ok(match self { Config { @@ -28,7 +28,6 @@ impl TracingConfigurator for Config { let exporter = apollo_telemetry::Exporter::builder() .expose_trace_id_config(expose_trace_id.clone()) - .trace_config(trace_config.clone()) .endpoint(endpoint.clone()) .apollo_key(key) .apollo_graph_ref(reference) diff --git a/apollo-router/src/plugins/telemetry/tracing/apollo_telemetry.rs b/apollo-router/src/plugins/telemetry/tracing/apollo_telemetry.rs index c8cddba1861..4509c6b9855 100644 --- a/apollo-router/src/plugins/telemetry/tracing/apollo_telemetry.rs +++ b/apollo-router/src/plugins/telemetry/tracing/apollo_telemetry.rs @@ -1,10 +1,10 @@ -use std::borrow::Cow; use std::collections::HashMap; use std::io::Cursor; use std::time::SystemTimeError; use async_trait::async_trait; use derivative::Derivative; +use itertools::Itertools; use lru::LruCache; use opentelemetry::sdk::export::trace::ExportResult; use opentelemetry::sdk::export::trace::SpanData; @@ -13,6 +13,7 @@ use opentelemetry::trace::SpanId; use opentelemetry::Key; use opentelemetry::Value; use opentelemetry_semantic_conventions::trace::HTTP_METHOD; +use serde::de::DeserializeOwned; use thiserror::Error; use url::Url; @@ -21,22 +22,23 @@ use crate::plugins::telemetry::apollo::SingleReport; use crate::plugins::telemetry::apollo_exporter::ApolloExporter; use crate::plugins::telemetry::apollo_exporter::Sender; use crate::plugins::telemetry::config; -use crate::plugins::telemetry::config::Sampler; use crate::plugins::telemetry::config::SamplerOption; +use crate::plugins::telemetry::config::{ExposeTraceId, Sampler}; use crate::plugins::telemetry::tracing::apollo::TracesReport; use crate::plugins::telemetry::BoxError; use crate::plugins::telemetry::SUBGRAPH_SPAN_NAME; use crate::plugins::telemetry::SUPERGRAPH_SPAN_NAME; -use crate::query_planner::FETCH_SPAN_NAME; -use crate::query_planner::FLATTEN_SPAN_NAME; -use crate::query_planner::PARALLEL_SPAN_NAME; use crate::query_planner::SEQUENCE_SPAN_NAME; +use crate::query_planner::{CONDITION_ELSE_SPAN_NAME, CONDITION_IF_SPAN_NAME, PARALLEL_SPAN_NAME}; +use crate::query_planner::{CONDITION_SPAN_NAME, DEFER_SPAN_NAME, FETCH_SPAN_NAME}; +use crate::query_planner::{DEFER_DEFERRED_SPAN_NAME, DEFER_PRIMARY_SPAN_NAME, FLATTEN_SPAN_NAME}; use crate::spaceport::trace::http::Values; -use crate::spaceport::trace::query_plan_node::FetchNode; -use crate::spaceport::trace::query_plan_node::FlattenNode; -use crate::spaceport::trace::query_plan_node::ParallelNode; use crate::spaceport::trace::query_plan_node::ResponsePathElement; use crate::spaceport::trace::query_plan_node::SequenceNode; +use crate::spaceport::trace::query_plan_node::{ConditionNode, ParallelNode}; +use crate::spaceport::trace::query_plan_node::{DeferNode, DeferredNodeDepends}; +use crate::spaceport::trace::query_plan_node::{DeferNodePrimary, FlattenNode}; +use crate::spaceport::trace::query_plan_node::{DeferredNode, FetchNode}; use crate::spaceport::trace::Details; use crate::spaceport::trace::Http; use crate::spaceport::trace::QueryPlanNode; @@ -52,11 +54,13 @@ const APOLLO_PRIVATE_HTTP_REQUEST_HEADERS: Key = pub(crate) const APOLLO_PRIVATE_OPERATION_SIGNATURE: Key = Key::from_static_str("apollo_private.operation_signature"); const APOLLO_PRIVATE_FTV1: Key = Key::from_static_str("apollo_private.ftv1"); -const APOLLO_PRIVATE_PATH: Key = Key::from_static_str("apollo_private.path"); -const FTV1_DO_NOT_SAMPLE_REASON: Key = Key::from_static_str("ftv1.do_not_sample_reason"); +const PATH: Key = Key::from_static_str("apollo_private.path"); const SUBGRAPH_NAME: Key = Key::from_static_str("apollo.subgraph.name"); const CLIENT_NAME: Key = Key::from_static_str("client.name"); const CLIENT_VERSION: Key = Key::from_static_str("client.version"); +const DEPENDS: Key = Key::from_static_str("depends"); +const LABEL: Key = Key::from_static_str("label"); +const CONDITION: Key = Key::from_static_str("condition"); pub(crate) const DEFAULT_TRACE_ID_HEADER_NAME: &str = "apollo-trace-id"; #[derive(Error, Debug)] @@ -67,17 +71,14 @@ pub(crate) enum Error { #[error("subgraph trace payload was not base64")] Base64Decode(#[from] base64::DecodeError), - #[error("ftv1 span attribute should have been a string")] - Ftv1SpanAttribute, + #[error("trace parsing failed")] + TraceParsingFailed, #[error("there were multiple tracing errors")] MultipleErrors(Vec), #[error("duration could not be calculated")] SystemTime(#[from] SystemTimeError), - - #[error("this trace should not be sampled")] - DoNotSample(Cow<'static, str>), } /// A [`SpanExporter`] that writes to [`Reporter`]. @@ -88,10 +89,7 @@ pub(crate) enum Error { #[derivative(Debug)] pub(crate) struct Exporter { expose_trace_id_config: config::ExposeTraceId, - trace_config: config::Trace, spans_by_parent_id: LruCache>, - endpoint: Url, - schema_id: String, #[derivative(Debug = "ignore")] apollo_sender: Sender, field_execution_weight: f64, @@ -105,8 +103,12 @@ enum TreeData { client_version: Option, operation_signature: String, }, - QueryPlan(QueryPlanNode), - Trace(Result>, Error>), + QueryPlanNode(QueryPlanNode), + DeferPrimary(DeferNodePrimary), + DeferDeferred(DeferredNode), + ConditionIf(Option), + ConditionElse(Option), + Trace(Option, Error>>), } #[buildstructor::buildstructor] @@ -114,7 +116,6 @@ impl Exporter { #[builder] pub(crate) fn new( expose_trace_id_config: config::ExposeTraceId, - trace_config: config::Trace, endpoint: Url, apollo_key: String, apollo_graph_ref: String, @@ -128,9 +129,6 @@ impl Exporter { Ok(Self { expose_trace_id_config, spans_by_parent_id: LruCache::new(buffer_size), - trace_config, - endpoint, - schema_id, apollo_sender: apollo_exporter.provider(), field_execution_weight: match field_execution_sampler { Some(SamplerOption::Always(Sampler::AlwaysOn)) => 1.0, @@ -146,23 +144,18 @@ impl Exporter { span: &SpanData, child_nodes: Vec, ) -> Result, Error> { - let variables = span + let variables_json = span .attributes .get(&APOLLO_PRIVATE_GRAPHQL_VARIABLES) - .map(|data| data.as_str()) + .and_then(extract_json) .unwrap_or_default(); - let variables_json = if variables != "{}" { - serde_json::from_str(&variables).unwrap_or_default() - } else { - HashMap::new() - }; let details = Details { variables_json, ..Default::default() }; - let http = self.extract_http_data(span); + let http = extract_http_data(span, &self.expose_trace_id_config); let mut root_trace = crate::spaceport::Trace { start_time: Some(span.start_time.into()), @@ -170,7 +163,7 @@ impl Exporter { duration_ns: span .attributes .get(&APOLLO_PRIVATE_DURATION_NS) - .and_then(Self::extract_i64) + .and_then(extract_i64) .map(|e| e as u64) .unwrap_or_default(), root: None, @@ -181,7 +174,7 @@ impl Exporter { for node in child_nodes { match node { - TreeData::QueryPlan(query_plan) => { + TreeData::QueryPlanNode(query_plan) => { root_trace.query_plan = Some(Box::new(query_plan)) } TreeData::Supergraph { @@ -243,43 +236,26 @@ impl Exporter { if !errors.is_empty() { return Err(Error::MultipleErrors(errors)); } - if let Some(Value::String(reason)) = span.attributes.get(&FTV1_DO_NOT_SAMPLE_REASON) { - if !reason.is_empty() { - return Err(Error::DoNotSample(reason.clone())); - } - } Ok(match span.name.as_ref() { - PARALLEL_SPAN_NAME => vec![TreeData::QueryPlan(QueryPlanNode { + PARALLEL_SPAN_NAME => vec![TreeData::QueryPlanNode(QueryPlanNode { node: Some(crate::spaceport::trace::query_plan_node::Node::Parallel( ParallelNode { - nodes: child_nodes - .into_iter() - .filter_map(|child| match child { - TreeData::QueryPlan(node) => Some(node), - _ => None, - }) - .collect(), + nodes: child_nodes.remove_query_plan_nodes(), }, )), })], - SEQUENCE_SPAN_NAME => vec![TreeData::QueryPlan(QueryPlanNode { + SEQUENCE_SPAN_NAME => vec![TreeData::QueryPlanNode(QueryPlanNode { node: Some(crate::spaceport::trace::query_plan_node::Node::Sequence( SequenceNode { - nodes: child_nodes - .into_iter() - .filter_map(|child| match child { - TreeData::QueryPlan(node) => Some(node), - _ => None, - }) - .collect(), + nodes: child_nodes.remove_query_plan_nodes(), }, )), })], FETCH_SPAN_NAME => { let (trace_parsing_failed, trace) = match child_nodes.pop() { - Some(TreeData::Trace(Ok(trace))) => (false, trace), - Some(TreeData::Trace(Err(_err))) => (true, None), + Some(TreeData::Trace(Some(Ok(trace)))) => (false, Some(trace)), + Some(TreeData::Trace(Some(Err(_err)))) => (true, None), _ => (false, None), }; let service_name = (span @@ -289,7 +265,7 @@ impl Exporter { .unwrap_or_else(|| Value::String("unknown service".into())) .as_str()) .to_string(); - vec![TreeData::QueryPlan(QueryPlanNode { + vec![TreeData::QueryPlanNode(QueryPlanNode { node: Some(crate::spaceport::trace::query_plan_node::Node::Fetch( Box::new(FetchNode { service_name, @@ -298,7 +274,7 @@ impl Exporter { sent_time_offset: span .attributes .get(&APOLLO_PRIVATE_SENT_TIME_OFFSET) - .and_then(Self::extract_i64) + .and_then(extract_i64) .map(|f| f as u64) .unwrap_or_default(), sent_time: Some(span.start_time.into()), @@ -308,52 +284,39 @@ impl Exporter { })] } FLATTEN_SPAN_NAME => { - vec![TreeData::QueryPlan(QueryPlanNode { + vec![TreeData::QueryPlanNode(QueryPlanNode { node: Some(crate::spaceport::trace::query_plan_node::Node::Flatten( Box::new(FlattenNode { response_path: span .attributes - .get(&APOLLO_PRIVATE_PATH) - .and_then(Self::extract_string) - .map(|v| { - v.split('/').filter(|v|!v.is_empty() && *v != "@").map(|v| { - if let Ok(index) = v.parse::() { - ResponsePathElement { id: Some(crate::spaceport::trace::query_plan_node::response_path_element::Id::Index(index))} - } else { - ResponsePathElement { id: Some(crate::spaceport::trace::query_plan_node::response_path_element::Id::FieldName(v.to_string())) } - } - }).collect() - }).unwrap_or_default(), - node: child_nodes - .into_iter() - .filter_map(|child| match child { - TreeData::QueryPlan(node) => Some(Box::new(node)), - _ => None, - }) - .next(), + .get(&PATH) + .map(extract_path) + .unwrap_or_default(), + node: child_nodes.remove_first_query_plan_node().map(Box::new), }), )), })] } SUBGRAPH_SPAN_NAME => { - vec![TreeData::Trace(self.find_ftv1_trace(span))] + vec![TreeData::Trace( + span.attributes + .get(&APOLLO_PRIVATE_FTV1) + .and_then(extract_ftv1_trace), + )] } SUPERGRAPH_SPAN_NAME => { //Currently some data is in the supergraph span as we don't have the a request hook in plugin. child_nodes.push(TreeData::Supergraph { - http: self.extract_http_data(span), - client_name: span - .attributes - .get(&CLIENT_NAME) - .and_then(Self::extract_string), + http: extract_http_data(span, &self.expose_trace_id_config), + client_name: span.attributes.get(&CLIENT_NAME).and_then(extract_string), client_version: span .attributes .get(&CLIENT_VERSION) - .and_then(Self::extract_string), + .and_then(extract_string), operation_signature: span .attributes .get(&APOLLO_PRIVATE_OPERATION_SIGNATURE) - .and_then(Self::extract_string) + .and_then(extract_string) .unwrap_or_default(), }); child_nodes @@ -363,98 +326,181 @@ impl Exporter { self.extract_root_trace(span, child_nodes), )] } + DEFER_SPAN_NAME => { + vec![TreeData::QueryPlanNode(QueryPlanNode { + node: Some(crate::spaceport::trace::query_plan_node::Node::Defer( + Box::new(DeferNode { + primary: child_nodes.remove_first_defer_primary_node().map(Box::new), + deferred: child_nodes.remove_defer_deferred_nodes(), + }), + )), + })] + } + DEFER_PRIMARY_SPAN_NAME => { + vec![TreeData::DeferPrimary(DeferNodePrimary { + node: child_nodes.remove_first_query_plan_node().map(Box::new), + })] + } + DEFER_DEFERRED_SPAN_NAME => { + vec![TreeData::DeferDeferred(DeferredNode { + node: child_nodes.remove_first_query_plan_node(), + path: span + .attributes + .get(&PATH) + .map(extract_path) + .unwrap_or_default(), + // In theory we don't have to do the transformation here, but it is safer to do so. + depends: span + .attributes + .get(&DEPENDS) + .and_then(extract_json::>) + .unwrap_or_default() + .iter() + .map(|d| DeferredNodeDepends { + id: d.id.clone(), + defer_label: d.defer_label.clone().unwrap_or_default(), + }) + .collect(), + label: span + .attributes + .get(&LABEL) + .and_then(extract_string) + .unwrap_or_default(), + })] + } + + CONDITION_SPAN_NAME => { + vec![TreeData::QueryPlanNode(QueryPlanNode { + node: Some(crate::spaceport::trace::query_plan_node::Node::Condition( + Box::new(ConditionNode { + condition: span + .attributes + .get(&CONDITION) + .and_then(extract_string) + .unwrap_or_default(), + if_clause: child_nodes.remove_first_condition_if_node().map(Box::new), + else_clause: child_nodes + .remove_first_condition_else_node() + .map(Box::new), + }), + )), + })] + } + CONDITION_IF_SPAN_NAME => { + vec![TreeData::ConditionIf( + child_nodes.remove_first_query_plan_node(), + )] + } + CONDITION_ELSE_SPAN_NAME => { + vec![TreeData::ConditionElse( + child_nodes.remove_first_query_plan_node(), + )] + } _ => child_nodes, }) } +} - fn extract_string(v: &Value) -> Option { - if let Value::String(v) = v { - Some(v.to_string()) - } else { - None - } - } +fn extract_json(v: &Value) -> Option { + extract_string(v) + .map(|v| serde_json::from_str(&v)) + .transpose() + .unwrap_or(None) +} - fn extract_i64(v: &Value) -> Option { - if let Value::I64(v) = v { - Some(*v) - } else { - None - } +fn extract_string(v: &Value) -> Option { + if let Value::String(v) = v { + Some(v.to_string()) + } else { + None } +} - fn find_ftv1_trace( - &mut self, - span: &SpanData, - ) -> Result>, Error> { - span.attributes - .get(&APOLLO_PRIVATE_FTV1) - .map(|data| { - if let Value::String(data) = data { - Ok(Box::new(crate::spaceport::Trace::decode(Cursor::new( - base64::decode(data.to_string())?, - ))?)) +fn extract_path(v: &Value) -> Vec { + extract_string(v) + .map(|v| { + v.split('/').filter(|v|!v.is_empty() && *v != "@").map(|v| { + if let Ok(index) = v.parse::() { + ResponsePathElement { id: Some(crate::spaceport::trace::query_plan_node::response_path_element::Id::Index(index))} } else { - Err(Error::Ftv1SpanAttribute) + ResponsePathElement { id: Some(crate::spaceport::trace::query_plan_node::response_path_element::Id::FieldName(v.to_string())) } } - }) - .transpose() + }).collect() + }).unwrap_or_default() +} + +fn extract_i64(v: &Value) -> Option { + if let Value::I64(v) = v { + Some(*v) + } else { + None } +} - fn extract_http_data(&self, span: &SpanData) -> Http { - let method = match span - .attributes - .get(&HTTP_METHOD) - .map(|data| data.as_str()) - .unwrap_or_default() - .as_ref() - { - "OPTIONS" => crate::spaceport::trace::http::Method::Options, - "GET" => crate::spaceport::trace::http::Method::Get, - "HEAD" => crate::spaceport::trace::http::Method::Head, - "POST" => crate::spaceport::trace::http::Method::Post, - "PUT" => crate::spaceport::trace::http::Method::Put, - "DELETE" => crate::spaceport::trace::http::Method::Delete, - "TRACE" => crate::spaceport::trace::http::Method::Trace, - "CONNECT" => crate::spaceport::trace::http::Method::Connect, - "PATCH" => crate::spaceport::trace::http::Method::Patch, - _ => crate::spaceport::trace::http::Method::Unknown, - }; - let headers = span - .attributes - .get(&APOLLO_PRIVATE_HTTP_REQUEST_HEADERS) - .map(|data| data.as_str()) - .unwrap_or_default(); - let request_headers = serde_json::from_str::>>(&headers) - .unwrap_or_default() - .into_iter() - .map(|(header_name, value)| (header_name.to_lowercase(), Values { value })) - .collect(); - // For now, only trace_id - let response_headers = if self.expose_trace_id_config.enabled { - let mut res = HashMap::with_capacity(1); - res.insert( - self.expose_trace_id_config - .header_name - .as_ref() - .map(|h| h.to_string()) - .unwrap_or_else(|| DEFAULT_TRACE_ID_HEADER_NAME.to_string()), - Values { - value: vec![span.span_context.trace_id().to_string()], - }, - ); +fn extract_ftv1_trace(v: &Value) -> Option, Error>> { + if let Some(v) = extract_string(v) { + if let Ok(v) = base64::decode(v) { + if let Ok(t) = crate::spaceport::Trace::decode(Cursor::new(v)) { + return Some(Ok(Box::new(t))); + } + } - res - } else { - HashMap::new() - }; + return Some(Err(Error::TraceParsingFailed)); + } + None +} - Http { - method: method.into(), - request_headers, - response_headers, - status_code: 0, - } +fn extract_http_data(span: &SpanData, expose_trace_id_config: &ExposeTraceId) -> Http { + let method = match span + .attributes + .get(&HTTP_METHOD) + .map(|data| data.as_str()) + .unwrap_or_default() + .as_ref() + { + "OPTIONS" => crate::spaceport::trace::http::Method::Options, + "GET" => crate::spaceport::trace::http::Method::Get, + "HEAD" => crate::spaceport::trace::http::Method::Head, + "POST" => crate::spaceport::trace::http::Method::Post, + "PUT" => crate::spaceport::trace::http::Method::Put, + "DELETE" => crate::spaceport::trace::http::Method::Delete, + "TRACE" => crate::spaceport::trace::http::Method::Trace, + "CONNECT" => crate::spaceport::trace::http::Method::Connect, + "PATCH" => crate::spaceport::trace::http::Method::Patch, + _ => crate::spaceport::trace::http::Method::Unknown, + }; + let request_headers = span + .attributes + .get(&APOLLO_PRIVATE_HTTP_REQUEST_HEADERS) + .and_then(extract_json::>>) + .unwrap_or_default() + .into_iter() + .map(|(header_name, value)| (header_name.to_lowercase(), Values { value })) + .collect(); + // For now, only trace_id + let response_headers = if expose_trace_id_config.enabled { + let mut res = HashMap::with_capacity(1); + res.insert( + expose_trace_id_config + .header_name + .as_ref() + .map(|h| h.to_string()) + .unwrap_or_else(|| DEFAULT_TRACE_ID_HEADER_NAME.to_string()), + Values { + value: vec![span.span_context.trace_id().to_string()], + }, + ); + + res + } else { + HashMap::new() + }; + + Http { + method: method.into(), + request_headers, + response_headers, + status_code: 0, } } @@ -470,6 +516,17 @@ impl SpanExporter for Exporter { let mut traces: Vec<(String, crate::spaceport::Trace)> = Vec::new(); for span in batch { if span.name == REQUEST_SPAN_NAME { + // Write spans for testing + // You can obtain new span data by uncommenting the following code and executing a query. + // In general this isn't something we'll want to do often, we are just verifying that the exporter constructs a correct report. + // let mut c = self + // .spans_by_parent_id + // .iter() + // .flat_map(|(_, s)| s.iter()) + // .collect::>(); + // c.push(&span); + // std::fs::write("spandata.yaml", serde_yaml::to_string(&c).unwrap()).unwrap(); + match self.extract_trace(span) { Ok(mut trace) => { let mut operation_signature = Default::default(); @@ -479,17 +536,10 @@ impl SpanExporter for Exporter { } } Err(Error::MultipleErrors(errors)) => { - if let Some(Error::DoNotSample(reason)) = errors.first() { - tracing::debug!( - "sampling is disabled on this trace: {}, skipping", - reason - ); - } else { - tracing::error!( - "failed to construct trace: {}, skipping", - Error::MultipleErrors(errors) - ); - } + tracing::error!( + "failed to construct trace: {}, skipping", + Error::MultipleErrors(errors) + ); } Err(error) => { tracing::error!("failed to construct trace: {}, skipping", error); @@ -514,3 +564,349 @@ impl SpanExporter for Exporter { return ExportResult::Ok(()); } } + +trait ChildNodes { + fn remove_first_query_plan_node(&mut self) -> Option; + fn remove_query_plan_nodes(&mut self) -> Vec; + fn remove_first_defer_primary_node(&mut self) -> Option; + fn remove_defer_deferred_nodes(&mut self) -> Vec; + fn remove_first_condition_if_node(&mut self) -> Option; + fn remove_first_condition_else_node(&mut self) -> Option; +} + +impl ChildNodes for Vec { + fn remove_first_query_plan_node(&mut self) -> Option { + if let Some((idx, _)) = self + .iter() + .find_position(|child| matches!(child, TreeData::QueryPlanNode(_))) + { + if let TreeData::QueryPlanNode(node) = self.remove(idx) { + return Some(node); + } + } + None + } + + fn remove_query_plan_nodes(&mut self) -> Vec { + let mut extracted = Vec::new(); + let mut retained = Vec::new(); + for treedata in self.drain(0..self.len()) { + if let TreeData::QueryPlanNode(node) = treedata { + extracted.push(node); + } else { + retained.push(treedata) + } + } + self.append(&mut retained); + extracted + } + + fn remove_first_defer_primary_node(&mut self) -> Option { + if let Some((idx, _)) = self + .iter() + .find_position(|child| matches!(child, TreeData::DeferPrimary(_))) + { + if let TreeData::DeferPrimary(node) = self.remove(idx) { + return Some(node); + } + } + None + } + + fn remove_defer_deferred_nodes(&mut self) -> Vec { + let mut extracted = Vec::new(); + let mut retained = Vec::new(); + for treedata in self.drain(0..self.len()) { + if let TreeData::DeferDeferred(node) = treedata { + extracted.push(node); + } else { + retained.push(treedata) + } + } + self.append(&mut retained); + extracted + } + + fn remove_first_condition_if_node(&mut self) -> Option { + if let Some((idx, _)) = self + .iter() + .find_position(|child| matches!(child, TreeData::ConditionIf(_))) + { + if let TreeData::ConditionIf(node) = self.remove(idx) { + return node; + } + } + None + } + + fn remove_first_condition_else_node(&mut self) -> Option { + if let Some((idx, _)) = self + .iter() + .find_position(|child| matches!(child, TreeData::ConditionElse(_))) + { + if let TreeData::ConditionElse(node) = self.remove(idx) { + return node; + } + } + None + } +} + +#[buildstructor::buildstructor] +#[cfg(test)] +impl Exporter { + #[builder] + pub(crate) fn test_new(expose_trace_id_config: Option) -> Self { + Exporter { + expose_trace_id_config: expose_trace_id_config.unwrap_or_default(), + spans_by_parent_id: LruCache::unbounded(), + apollo_sender: Sender::InMemory(Default::default()), + field_execution_weight: 1.0, + } + } +} + +#[cfg(test)] +mod test { + use crate::plugins::telemetry::apollo::SingleReport; + use crate::plugins::telemetry::apollo_exporter::Sender; + use crate::plugins::telemetry::config::ExposeTraceId; + use crate::plugins::telemetry::tracing::apollo_telemetry::{ + extract_ftv1_trace, extract_i64, extract_json, extract_path, extract_string, ChildNodes, + Exporter, TreeData, + }; + use crate::spaceport; + use crate::spaceport::trace::query_plan_node::response_path_element::Id; + use crate::spaceport::trace::query_plan_node::{ + DeferNodePrimary, DeferredNode, ResponsePathElement, + }; + use crate::spaceport::trace::QueryPlanNode; + use http::header::HeaderName; + use opentelemetry::sdk::export::trace::SpanExporter; + use opentelemetry::Value; + use prost::Message; + use serde_json::json; + use std::borrow::Cow; + + async fn report(mut exporter: Exporter, spandata: &str) -> SingleReport { + let spandata = serde_yaml::from_str(spandata).expect("test spans must be parsable"); + + exporter + .export(spandata) + .await + .expect("span export must succeed"); + assert!(matches!(exporter.apollo_sender, Sender::InMemory(_))); + if let Sender::InMemory(storage) = exporter.apollo_sender { + return storage + .lock() + .expect("lock poisoned") + .pop() + .expect("must have a report"); + } + panic!("cannot happen"); + } + + #[tokio::test] + async fn test_condition_if() { + // The following curl request was used to generate this span data + // curl --request POST \ + // --header 'content-type: application/json' \ + // --header 'accept: multipart/mixed; deferSpec=20220824, application/json' \ + // --url http://localhost:4000/ \ + // --data '{"query":"query($if: Boolean!) {\n topProducts {\n name\n ... @defer(if: $if) {\n reviews {\n author {\n name\n }\n }\n reviews {\n author {\n name\n }\n }\n }\n }\n}","variables":{"if":true}}' + let spandata = include_str!("testdata/condition_if_spandata.yaml"); + let exporter = Exporter::test_builder().build(); + let report = report(exporter, spandata).await; + insta::with_settings!({sort_maps => true}, { + insta::assert_yaml_snapshot!(report); + }); + } + + #[tokio::test] + async fn test_condition_else() { + // The following curl request was used to generate this span data + // curl --request POST \ + // --header 'content-type: application/json' \ + // --header 'accept: multipart/mixed; deferSpec=20220824, application/json' \ + // --url http://localhost:4000/ \ + // --data '{"query":"query($if: Boolean!) {\n topProducts {\n name\n ... @defer(if: $if) {\n reviews {\n author {\n name\n }\n }\n reviews {\n author {\n name\n }\n }\n }\n }\n}","variables":{"if":false}}' + let spandata = include_str!("testdata/condition_else_spandata.yaml"); + let exporter = Exporter::test_builder().build(); + let report = report(exporter, spandata).await; + insta::with_settings!({sort_maps => true}, { + insta::assert_yaml_snapshot!(report); + }); + } + + #[tokio::test] + async fn test_trace_id() { + let spandata = include_str!("testdata/condition_if_spandata.yaml"); + let exporter = Exporter::test_builder() + .expose_trace_id_config(ExposeTraceId { + enabled: true, + header_name: Some(HeaderName::from_static("trace_id")), + }) + .build(); + let report = report(exporter, spandata).await; + insta::with_settings!({sort_maps => true}, { + insta::assert_yaml_snapshot!(report); + }); + } + + fn elements(tree_data: Vec) -> Vec<&'static str> { + let mut elements = Vec::new(); + for t in tree_data { + match t { + TreeData::Request(_) => elements.push("request"), + TreeData::Supergraph { .. } => elements.push("supergraph"), + TreeData::QueryPlanNode(_) => elements.push("query_plan_node"), + TreeData::DeferPrimary(_) => elements.push("defer_primary"), + TreeData::DeferDeferred(_) => elements.push("defer_deferred"), + TreeData::ConditionIf(_) => elements.push("condition_if"), + TreeData::ConditionElse(_) => elements.push("condition_else"), + TreeData::Trace(_) => elements.push("trace"), + } + } + elements + } + + #[test] + fn remove_first_query_plan_node() { + let mut vec = vec![ + TreeData::Trace(None), + TreeData::QueryPlanNode(QueryPlanNode { node: None }), + TreeData::QueryPlanNode(QueryPlanNode { node: None }), + ]; + + assert!(vec.remove_first_query_plan_node().is_some()); + assert_eq!(elements(vec), ["trace", "query_plan_node"]); + } + + #[test] + fn remove_query_plan_nodes() { + let mut vec = vec![ + TreeData::Trace(None), + TreeData::QueryPlanNode(QueryPlanNode { node: None }), + TreeData::QueryPlanNode(QueryPlanNode { node: None }), + ]; + + assert_eq!(vec.remove_query_plan_nodes().len(), 2); + assert_eq!(elements(vec), ["trace"]); + } + + #[test] + fn remove_first_defer_primary_node() { + let mut vec = vec![ + TreeData::Trace(None), + TreeData::DeferPrimary(DeferNodePrimary { node: None }), + TreeData::DeferDeferred(DeferredNode { + depends: vec![], + label: "".to_string(), + path: Default::default(), + node: None, + }), + ]; + + assert!(vec.remove_first_defer_primary_node().is_some()); + assert_eq!(elements(vec), ["trace", "defer_deferred"]); + } + + #[test] + fn remove_defer_deferred_nodes() { + let mut vec = vec![ + TreeData::Trace(None), + TreeData::DeferPrimary(DeferNodePrimary { node: None }), + TreeData::DeferDeferred(DeferredNode { + depends: vec![], + label: "".to_string(), + path: Default::default(), + node: None, + }), + TreeData::DeferDeferred(DeferredNode { + depends: vec![], + label: "".to_string(), + path: Default::default(), + node: None, + }), + ]; + + assert_eq!(vec.remove_defer_deferred_nodes().len(), 2); + assert_eq!(elements(vec), ["trace", "defer_primary"]); + } + + #[test] + fn test_remove_first_condition_if_node() { + let mut vec = vec![ + TreeData::Trace(None), + TreeData::ConditionIf(Some(QueryPlanNode { node: None })), + TreeData::ConditionElse(Some(QueryPlanNode { node: None })), + ]; + + assert!(vec.remove_first_condition_if_node().is_some()); + assert_eq!(elements(vec), ["trace", "condition_else"]); + } + + #[test] + fn test_remove_first_condition_else_node() { + let mut vec = vec![ + TreeData::Trace(None), + TreeData::ConditionIf(Some(QueryPlanNode { node: None })), + TreeData::ConditionElse(Some(QueryPlanNode { node: None })), + ]; + + assert!(vec.remove_first_condition_else_node().is_some()); + assert_eq!(elements(vec), ["trace", "condition_if"]); + } + + #[test] + fn test_extract_json() { + let val = json!({"hi": "there"}); + assert_eq!( + extract_json::(&Value::String(Cow::Owned(val.to_string()))), + Some(val) + ); + } + + #[test] + fn test_extract_string() { + assert_eq!( + extract_string(&Value::String(Cow::Owned("hi".to_string()))), + Some("hi".to_string()) + ); + } + + #[test] + fn test_extract_path() { + assert_eq!( + extract_path(&Value::String(Cow::Owned("/hi/3/there".to_string()))), + vec![ + ResponsePathElement { + id: Some(Id::FieldName("hi".to_string())), + }, + ResponsePathElement { + id: Some(Id::Index(3)), + }, + ResponsePathElement { + id: Some(Id::FieldName("there".to_string())), + } + ] + ); + } + + #[test] + fn test_extract_i64() { + assert_eq!(extract_i64(&Value::I64(35)), Some(35)); + } + + #[test] + fn test_extract_ftv1_trace() { + let trace = spaceport::Trace::default(); + let encoded = base64::encode(trace.encode_to_vec()); + assert_eq!( + *extract_ftv1_trace(&Value::String(Cow::Owned(encoded))) + .expect("there was a trace here") + .expect("the trace must be decoded"), + trace + ); + } +} diff --git a/apollo-router/src/plugins/telemetry/tracing/snapshots/apollo_router__plugins__telemetry__tracing__apollo_telemetry__test__condition_else.snap b/apollo-router/src/plugins/telemetry/tracing/snapshots/apollo_router__plugins__telemetry__tracing__apollo_telemetry__test__condition_else.snap new file mode 100644 index 00000000000..8fdfb9eeb50 --- /dev/null +++ b/apollo-router/src/plugins/telemetry/tracing/snapshots/apollo_router__plugins__telemetry__tracing__apollo_telemetry__test__condition_else.snap @@ -0,0 +1,584 @@ +--- +source: apollo-router/src/plugins/telemetry/tracing/apollo_telemetry.rs +expression: report +--- +Traces: + traces: + - - "# -\nquery($if:Boolean!){topProducts{name...@defer(if:$if){reviews{author{name}}reviews{author{name}}}}}" + - start_time: + seconds: 1669889787 + nanos: 663946653 + end_time: + seconds: 1669889787 + nanos: 834038179 + duration_ns: 170136294 + root: ~ + is_incomplete: false + signature: "" + unexecuted_operation_body: "" + unexecuted_operation_name: "" + details: + variables_json: {} + operation_name: "" + client_name: "" + client_version: "" + http: + method: 4 + request_headers: + accept: + value: + - "" + content-length: + value: + - "" + content-type: + value: + - "" + host: + value: + - "" + user-agent: + value: + - "" + response_headers: {} + status_code: 0 + cache_policy: ~ + query_plan: + node: + Condition: + condition: if + if_clause: ~ + else_clause: + node: + Sequence: + nodes: + - node: + Fetch: + service_name: products + trace_parsing_failed: false + trace: + start_time: + seconds: 1669889787 + nanos: 701000000 + end_time: + seconds: 1669889787 + nanos: 702000000 + duration_ns: 897303 + root: + original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: "[Product]" + parent_type: Query + cache_policy: ~ + start_time: 294994 + end_time: 460624 + error: [] + child: + - original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: String! + parent_type: Product + cache_policy: ~ + start_time: 640508 + end_time: 658720 + error: [] + child: [] + id: + ResponseName: upc + - original_field_name: "" + type: String + parent_type: Product + cache_policy: ~ + start_time: 669662 + end_time: 693123 + error: [] + child: [] + id: + ResponseName: name + id: + Index: 0 + - original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: String! + parent_type: Product + cache_policy: ~ + start_time: 743892 + end_time: 754144 + error: [] + child: [] + id: + ResponseName: upc + - original_field_name: "" + type: String + parent_type: Product + cache_policy: ~ + start_time: 768092 + end_time: 772946 + error: [] + child: [] + id: + ResponseName: name + id: + Index: 1 + - original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: String! + parent_type: Product + cache_policy: ~ + start_time: 789451 + end_time: 794355 + error: [] + child: [] + id: + ResponseName: upc + - original_field_name: "" + type: String + parent_type: Product + cache_policy: ~ + start_time: 803680 + end_time: 810465 + error: [] + child: [] + id: + ResponseName: name + id: + Index: 2 + id: + ResponseName: topProducts + id: ~ + is_incomplete: false + signature: "" + unexecuted_operation_body: "" + unexecuted_operation_name: "" + details: ~ + client_name: "" + client_version: "" + http: ~ + cache_policy: ~ + query_plan: ~ + full_query_cache_hit: false + persisted_query_hit: false + persisted_query_register: false + registered_operation: false + forbidden_operation: false + field_execution_weight: 1 + sent_time_offset: 1258683 + sent_time: + seconds: 1669889787 + nanos: 665757295 + received_time: + seconds: 1669889787 + nanos: 721612554 + - node: + Flatten: + response_path: [] + node: + node: + Fetch: + service_name: reviews + trace_parsing_failed: false + trace: + start_time: + seconds: 1669889787 + nanos: 758000000 + end_time: + seconds: 1669889787 + nanos: 759000000 + duration_ns: 852791 + root: + original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: "[_Entity]!" + parent_type: Query + cache_policy: ~ + start_time: 269560 + end_time: 348180 + error: [] + child: + - original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: "[Review]" + parent_type: Product + cache_policy: ~ + start_time: 381980 + end_time: 525310 + error: [] + child: + - original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: User + parent_type: Review + cache_policy: ~ + start_time: 545280 + end_time: 716411 + error: [] + child: + - original_field_name: "" + type: ID! + parent_type: User + cache_policy: ~ + start_time: 731071 + end_time: 739501 + error: [] + child: [] + id: + ResponseName: id + id: + ResponseName: author + id: + Index: 0 + - original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: User + parent_type: Review + cache_policy: ~ + start_time: 587530 + end_time: 742541 + error: [] + child: + - original_field_name: "" + type: ID! + parent_type: User + cache_policy: ~ + start_time: 751781 + end_time: 755561 + error: [] + child: [] + id: + ResponseName: id + id: + ResponseName: author + id: + Index: 1 + id: + ResponseName: reviews + id: + Index: 0 + - original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: "[Review]" + parent_type: Product + cache_policy: ~ + start_time: 443110 + end_time: 619020 + error: [] + child: + - original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: User + parent_type: Review + cache_policy: ~ + start_time: 630770 + end_time: 759611 + error: [] + child: + - original_field_name: "" + type: ID! + parent_type: User + cache_policy: ~ + start_time: 764841 + end_time: 771411 + error: [] + child: [] + id: + ResponseName: id + id: + ResponseName: author + id: + Index: 0 + id: + ResponseName: reviews + id: + Index: 1 + - original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: "[Review]" + parent_type: Product + cache_policy: ~ + start_time: 481850 + end_time: 660381 + error: [] + child: + - original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: User + parent_type: Review + cache_policy: ~ + start_time: 674571 + end_time: 773441 + error: [] + child: + - original_field_name: "" + type: ID! + parent_type: User + cache_policy: ~ + start_time: 780401 + end_time: 783931 + error: [] + child: [] + id: + ResponseName: id + id: + ResponseName: author + id: + Index: 0 + id: + ResponseName: reviews + id: + Index: 2 + id: + ResponseName: _entities + id: ~ + is_incomplete: false + signature: "" + unexecuted_operation_body: "" + unexecuted_operation_name: "" + details: ~ + client_name: "" + client_version: "" + http: ~ + cache_policy: ~ + query_plan: ~ + full_query_cache_hit: false + persisted_query_hit: false + persisted_query_register: false + registered_operation: false + forbidden_operation: false + field_execution_weight: 1 + sent_time_offset: 57387931 + sent_time: + seconds: 1669889787 + nanos: 721889405 + received_time: + seconds: 1669889787 + nanos: 780306032 + - node: + Flatten: + response_path: [] + node: + node: + Fetch: + service_name: accounts + trace_parsing_failed: false + trace: + start_time: + seconds: 1669889787 + nanos: 812000000 + end_time: + seconds: 1669889787 + nanos: 812000000 + duration_ns: 634211 + root: + original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: "[_Entity]!" + parent_type: Query + cache_policy: ~ + start_time: 313281 + end_time: 477261 + error: [] + child: + - original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: String + parent_type: User + cache_policy: ~ + start_time: 515761 + end_time: 528191 + error: [] + child: [] + id: + ResponseName: name + id: + Index: 0 + - original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: String + parent_type: User + cache_policy: ~ + start_time: 544811 + end_time: 549991 + error: [] + child: [] + id: + ResponseName: name + id: + Index: 1 + - original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: String + parent_type: User + cache_policy: ~ + start_time: 559331 + end_time: 563811 + error: [] + child: [] + id: + ResponseName: name + id: + Index: 2 + - original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: String + parent_type: User + cache_policy: ~ + start_time: 572511 + end_time: 576871 + error: [] + child: [] + id: + ResponseName: name + id: + Index: 3 + id: + ResponseName: _entities + id: ~ + is_incomplete: false + signature: "" + unexecuted_operation_body: "" + unexecuted_operation_name: "" + details: ~ + client_name: "" + client_version: "" + http: ~ + cache_policy: ~ + query_plan: ~ + full_query_cache_hit: false + persisted_query_hit: false + persisted_query_register: false + registered_operation: false + forbidden_operation: false + field_execution_weight: 1 + sent_time_offset: 116343454 + sent_time: + seconds: 1669889787 + nanos: 780853589 + received_time: + seconds: 1669889787 + nanos: 832590225 + full_query_cache_hit: false + persisted_query_hit: false + persisted_query_register: false + registered_operation: false + forbidden_operation: false + field_execution_weight: 1 + diff --git a/apollo-router/src/plugins/telemetry/tracing/snapshots/apollo_router__plugins__telemetry__tracing__apollo_telemetry__test__condition_if.snap b/apollo-router/src/plugins/telemetry/tracing/snapshots/apollo_router__plugins__telemetry__tracing__apollo_telemetry__test__condition_if.snap new file mode 100644 index 00000000000..8b10d734aa5 --- /dev/null +++ b/apollo-router/src/plugins/telemetry/tracing/snapshots/apollo_router__plugins__telemetry__tracing__apollo_telemetry__test__condition_if.snap @@ -0,0 +1,595 @@ +--- +source: apollo-router/src/plugins/telemetry/tracing/apollo_telemetry.rs +expression: report +--- +Traces: + traces: + - - "# -\nquery($if:Boolean!){topProducts{name...@defer(if:$if){reviews{author{name}}reviews{author{name}}}}}" + - start_time: + seconds: 1669889687 + nanos: 752748920 + end_time: + seconds: 1669889687 + nanos: 943291968 + duration_ns: 63124634 + root: ~ + is_incomplete: false + signature: "" + unexecuted_operation_body: "" + unexecuted_operation_name: "" + details: + variables_json: {} + operation_name: "" + client_name: "" + client_version: "" + http: + method: 4 + request_headers: + accept: + value: + - "" + content-length: + value: + - "" + content-type: + value: + - "" + host: + value: + - "" + user-agent: + value: + - "" + response_headers: {} + status_code: 0 + cache_policy: ~ + query_plan: + node: + Condition: + condition: if + if_clause: + node: + Defer: + primary: + node: + node: + Fetch: + service_name: products + trace_parsing_failed: false + trace: + start_time: + seconds: 1669889687 + nanos: 794000000 + end_time: + seconds: 1669889687 + nanos: 794000000 + duration_ns: 784177 + root: + original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: "[Product]" + parent_type: Query + cache_policy: ~ + start_time: 350743 + end_time: 493944 + error: [] + child: + - original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: String + parent_type: Product + cache_policy: ~ + start_time: 562659 + end_time: 583693 + error: [] + child: [] + id: + ResponseName: name + - original_field_name: "" + type: String! + parent_type: Product + cache_policy: ~ + start_time: 600586 + end_time: 609457 + error: [] + child: [] + id: + ResponseName: upc + id: + Index: 0 + - original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: String + parent_type: Product + cache_policy: ~ + start_time: 633111 + end_time: 640651 + error: [] + child: [] + id: + ResponseName: name + - original_field_name: "" + type: String! + parent_type: Product + cache_policy: ~ + start_time: 651537 + end_time: 657500 + error: [] + child: [] + id: + ResponseName: upc + id: + Index: 1 + - original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: String + parent_type: Product + cache_policy: ~ + start_time: 677060 + end_time: 682744 + error: [] + child: [] + id: + ResponseName: name + - original_field_name: "" + type: String! + parent_type: Product + cache_policy: ~ + start_time: 688877 + end_time: 697275 + error: [] + child: [] + id: + ResponseName: upc + id: + Index: 2 + id: + ResponseName: topProducts + id: ~ + is_incomplete: false + signature: "" + unexecuted_operation_body: "" + unexecuted_operation_name: "" + details: ~ + client_name: "" + client_version: "" + http: ~ + cache_policy: ~ + query_plan: ~ + full_query_cache_hit: false + persisted_query_hit: false + persisted_query_register: false + registered_operation: false + forbidden_operation: false + field_execution_weight: 1 + sent_time_offset: 2064512 + sent_time: + seconds: 1669889687 + nanos: 755593491 + received_time: + seconds: 1669889687 + nanos: 814463456 + deferred: + - depends: + - id: "0" + defer_label: "" + label: "" + path: [] + node: + node: + Sequence: + nodes: + - node: + Flatten: + response_path: [] + node: + node: + Fetch: + service_name: reviews + trace_parsing_failed: false + trace: + start_time: + seconds: 1669889687 + nanos: 860000000 + end_time: + seconds: 1669889687 + nanos: 867000000 + duration_ns: 6005878 + root: + original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: "[_Entity]!" + parent_type: Query + cache_policy: ~ + start_time: 2932541 + end_time: 3488078 + error: [] + child: + - original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: "[Review]" + parent_type: Product + cache_policy: ~ + start_time: 3693575 + end_time: 4527824 + error: [] + child: + - original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: User + parent_type: Review + cache_policy: ~ + start_time: 4597341 + end_time: 5459524 + error: [] + child: + - original_field_name: "" + type: ID! + parent_type: User + cache_policy: ~ + start_time: 5570216 + end_time: 5599387 + error: [] + child: [] + id: + ResponseName: id + id: + ResponseName: author + id: + Index: 0 + - original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: User + parent_type: Review + cache_policy: ~ + start_time: 4838978 + end_time: 5607133 + error: [] + child: + - original_field_name: "" + type: ID! + parent_type: User + cache_policy: ~ + start_time: 5622455 + end_time: 5639696 + error: [] + child: [] + id: + ResponseName: id + id: + ResponseName: author + id: + Index: 1 + id: + ResponseName: reviews + id: + Index: 0 + - original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: "[Review]" + parent_type: Product + cache_policy: ~ + start_time: 3909794 + end_time: 4991206 + error: [] + child: + - original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: User + parent_type: Review + cache_policy: ~ + start_time: 5025853 + end_time: 5644192 + error: [] + child: + - original_field_name: "" + type: ID! + parent_type: User + cache_policy: ~ + start_time: 5665477 + end_time: 5680785 + error: [] + child: [] + id: + ResponseName: id + id: + ResponseName: author + id: + Index: 0 + id: + ResponseName: reviews + id: + Index: 1 + - original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: "[Review]" + parent_type: Product + cache_policy: ~ + start_time: 4207856 + end_time: 5214904 + error: [] + child: + - original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: User + parent_type: Review + cache_policy: ~ + start_time: 5254081 + end_time: 5691578 + error: [] + child: + - original_field_name: "" + type: ID! + parent_type: User + cache_policy: ~ + start_time: 5739015 + end_time: 5754897 + error: [] + child: [] + id: + ResponseName: id + id: + ResponseName: author + id: + Index: 0 + id: + ResponseName: reviews + id: + Index: 2 + id: + ResponseName: _entities + id: ~ + is_incomplete: false + signature: "" + unexecuted_operation_body: "" + unexecuted_operation_name: "" + details: ~ + client_name: "" + client_version: "" + http: ~ + cache_policy: ~ + query_plan: ~ + full_query_cache_hit: false + persisted_query_hit: false + persisted_query_register: false + registered_operation: false + forbidden_operation: false + field_execution_weight: 1 + sent_time_offset: 61661177 + sent_time: + seconds: 1669889687 + nanos: 815176886 + received_time: + seconds: 1669889687 + nanos: 891210939 + - node: + Flatten: + response_path: [] + node: + node: + Fetch: + service_name: accounts + trace_parsing_failed: false + trace: + start_time: + seconds: 1669889687 + nanos: 921000000 + end_time: + seconds: 1669889687 + nanos: 922000000 + duration_ns: 568841 + root: + original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: "[_Entity]!" + parent_type: Query + cache_policy: ~ + start_time: 309661 + end_time: 415501 + error: [] + child: + - original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: String + parent_type: User + cache_policy: ~ + start_time: 452871 + end_time: 463761 + error: [] + child: [] + id: + ResponseName: name + id: + Index: 0 + - original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: String + parent_type: User + cache_policy: ~ + start_time: 483151 + end_time: 489351 + error: [] + child: [] + id: + ResponseName: name + id: + Index: 1 + - original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: String + parent_type: User + cache_policy: ~ + start_time: 498601 + end_time: 503561 + error: [] + child: [] + id: + ResponseName: name + id: + Index: 2 + - original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: String + parent_type: User + cache_policy: ~ + start_time: 512121 + end_time: 515331 + error: [] + child: [] + id: + ResponseName: name + id: + Index: 3 + id: + ResponseName: _entities + id: ~ + is_incomplete: false + signature: "" + unexecuted_operation_body: "" + unexecuted_operation_name: "" + details: ~ + client_name: "" + client_version: "" + http: ~ + cache_policy: ~ + query_plan: ~ + full_query_cache_hit: false + persisted_query_hit: false + persisted_query_register: false + registered_operation: false + forbidden_operation: false + field_execution_weight: 1 + sent_time_offset: 138211218 + sent_time: + seconds: 1669889687 + nanos: 891727207 + received_time: + seconds: 1669889687 + nanos: 941912460 + else_clause: ~ + full_query_cache_hit: false + persisted_query_hit: false + persisted_query_register: false + registered_operation: false + forbidden_operation: false + field_execution_weight: 1 + diff --git a/apollo-router/src/plugins/telemetry/tracing/snapshots/apollo_router__plugins__telemetry__tracing__apollo_telemetry__test__trace_id.snap b/apollo-router/src/plugins/telemetry/tracing/snapshots/apollo_router__plugins__telemetry__tracing__apollo_telemetry__test__trace_id.snap new file mode 100644 index 00000000000..18a4d6e295a --- /dev/null +++ b/apollo-router/src/plugins/telemetry/tracing/snapshots/apollo_router__plugins__telemetry__tracing__apollo_telemetry__test__trace_id.snap @@ -0,0 +1,598 @@ +--- +source: apollo-router/src/plugins/telemetry/tracing/apollo_telemetry.rs +expression: report +--- +Traces: + traces: + - - "# -\nquery($if:Boolean!){topProducts{name...@defer(if:$if){reviews{author{name}}reviews{author{name}}}}}" + - start_time: + seconds: 1669889687 + nanos: 752748920 + end_time: + seconds: 1669889687 + nanos: 943291968 + duration_ns: 63124634 + root: ~ + is_incomplete: false + signature: "" + unexecuted_operation_body: "" + unexecuted_operation_name: "" + details: + variables_json: {} + operation_name: "" + client_name: "" + client_version: "" + http: + method: 4 + request_headers: + accept: + value: + - "" + content-length: + value: + - "" + content-type: + value: + - "" + host: + value: + - "" + user-agent: + value: + - "" + response_headers: + trace_id: + value: + - 339b696e9d17212c0cab33a94c7242c5 + status_code: 0 + cache_policy: ~ + query_plan: + node: + Condition: + condition: if + if_clause: + node: + Defer: + primary: + node: + node: + Fetch: + service_name: products + trace_parsing_failed: false + trace: + start_time: + seconds: 1669889687 + nanos: 794000000 + end_time: + seconds: 1669889687 + nanos: 794000000 + duration_ns: 784177 + root: + original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: "[Product]" + parent_type: Query + cache_policy: ~ + start_time: 350743 + end_time: 493944 + error: [] + child: + - original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: String + parent_type: Product + cache_policy: ~ + start_time: 562659 + end_time: 583693 + error: [] + child: [] + id: + ResponseName: name + - original_field_name: "" + type: String! + parent_type: Product + cache_policy: ~ + start_time: 600586 + end_time: 609457 + error: [] + child: [] + id: + ResponseName: upc + id: + Index: 0 + - original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: String + parent_type: Product + cache_policy: ~ + start_time: 633111 + end_time: 640651 + error: [] + child: [] + id: + ResponseName: name + - original_field_name: "" + type: String! + parent_type: Product + cache_policy: ~ + start_time: 651537 + end_time: 657500 + error: [] + child: [] + id: + ResponseName: upc + id: + Index: 1 + - original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: String + parent_type: Product + cache_policy: ~ + start_time: 677060 + end_time: 682744 + error: [] + child: [] + id: + ResponseName: name + - original_field_name: "" + type: String! + parent_type: Product + cache_policy: ~ + start_time: 688877 + end_time: 697275 + error: [] + child: [] + id: + ResponseName: upc + id: + Index: 2 + id: + ResponseName: topProducts + id: ~ + is_incomplete: false + signature: "" + unexecuted_operation_body: "" + unexecuted_operation_name: "" + details: ~ + client_name: "" + client_version: "" + http: ~ + cache_policy: ~ + query_plan: ~ + full_query_cache_hit: false + persisted_query_hit: false + persisted_query_register: false + registered_operation: false + forbidden_operation: false + field_execution_weight: 1 + sent_time_offset: 2064512 + sent_time: + seconds: 1669889687 + nanos: 755593491 + received_time: + seconds: 1669889687 + nanos: 814463456 + deferred: + - depends: + - id: "0" + defer_label: "" + label: "" + path: [] + node: + node: + Sequence: + nodes: + - node: + Flatten: + response_path: [] + node: + node: + Fetch: + service_name: reviews + trace_parsing_failed: false + trace: + start_time: + seconds: 1669889687 + nanos: 860000000 + end_time: + seconds: 1669889687 + nanos: 867000000 + duration_ns: 6005878 + root: + original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: "[_Entity]!" + parent_type: Query + cache_policy: ~ + start_time: 2932541 + end_time: 3488078 + error: [] + child: + - original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: "[Review]" + parent_type: Product + cache_policy: ~ + start_time: 3693575 + end_time: 4527824 + error: [] + child: + - original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: User + parent_type: Review + cache_policy: ~ + start_time: 4597341 + end_time: 5459524 + error: [] + child: + - original_field_name: "" + type: ID! + parent_type: User + cache_policy: ~ + start_time: 5570216 + end_time: 5599387 + error: [] + child: [] + id: + ResponseName: id + id: + ResponseName: author + id: + Index: 0 + - original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: User + parent_type: Review + cache_policy: ~ + start_time: 4838978 + end_time: 5607133 + error: [] + child: + - original_field_name: "" + type: ID! + parent_type: User + cache_policy: ~ + start_time: 5622455 + end_time: 5639696 + error: [] + child: [] + id: + ResponseName: id + id: + ResponseName: author + id: + Index: 1 + id: + ResponseName: reviews + id: + Index: 0 + - original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: "[Review]" + parent_type: Product + cache_policy: ~ + start_time: 3909794 + end_time: 4991206 + error: [] + child: + - original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: User + parent_type: Review + cache_policy: ~ + start_time: 5025853 + end_time: 5644192 + error: [] + child: + - original_field_name: "" + type: ID! + parent_type: User + cache_policy: ~ + start_time: 5665477 + end_time: 5680785 + error: [] + child: [] + id: + ResponseName: id + id: + ResponseName: author + id: + Index: 0 + id: + ResponseName: reviews + id: + Index: 1 + - original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: "[Review]" + parent_type: Product + cache_policy: ~ + start_time: 4207856 + end_time: 5214904 + error: [] + child: + - original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: User + parent_type: Review + cache_policy: ~ + start_time: 5254081 + end_time: 5691578 + error: [] + child: + - original_field_name: "" + type: ID! + parent_type: User + cache_policy: ~ + start_time: 5739015 + end_time: 5754897 + error: [] + child: [] + id: + ResponseName: id + id: + ResponseName: author + id: + Index: 0 + id: + ResponseName: reviews + id: + Index: 2 + id: + ResponseName: _entities + id: ~ + is_incomplete: false + signature: "" + unexecuted_operation_body: "" + unexecuted_operation_name: "" + details: ~ + client_name: "" + client_version: "" + http: ~ + cache_policy: ~ + query_plan: ~ + full_query_cache_hit: false + persisted_query_hit: false + persisted_query_register: false + registered_operation: false + forbidden_operation: false + field_execution_weight: 1 + sent_time_offset: 61661177 + sent_time: + seconds: 1669889687 + nanos: 815176886 + received_time: + seconds: 1669889687 + nanos: 891210939 + - node: + Flatten: + response_path: [] + node: + node: + Fetch: + service_name: accounts + trace_parsing_failed: false + trace: + start_time: + seconds: 1669889687 + nanos: 921000000 + end_time: + seconds: 1669889687 + nanos: 922000000 + duration_ns: 568841 + root: + original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: "[_Entity]!" + parent_type: Query + cache_policy: ~ + start_time: 309661 + end_time: 415501 + error: [] + child: + - original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: String + parent_type: User + cache_policy: ~ + start_time: 452871 + end_time: 463761 + error: [] + child: [] + id: + ResponseName: name + id: + Index: 0 + - original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: String + parent_type: User + cache_policy: ~ + start_time: 483151 + end_time: 489351 + error: [] + child: [] + id: + ResponseName: name + id: + Index: 1 + - original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: String + parent_type: User + cache_policy: ~ + start_time: 498601 + end_time: 503561 + error: [] + child: [] + id: + ResponseName: name + id: + Index: 2 + - original_field_name: "" + type: "" + parent_type: "" + cache_policy: ~ + start_time: 0 + end_time: 0 + error: [] + child: + - original_field_name: "" + type: String + parent_type: User + cache_policy: ~ + start_time: 512121 + end_time: 515331 + error: [] + child: [] + id: + ResponseName: name + id: + Index: 3 + id: + ResponseName: _entities + id: ~ + is_incomplete: false + signature: "" + unexecuted_operation_body: "" + unexecuted_operation_name: "" + details: ~ + client_name: "" + client_version: "" + http: ~ + cache_policy: ~ + query_plan: ~ + full_query_cache_hit: false + persisted_query_hit: false + persisted_query_register: false + registered_operation: false + forbidden_operation: false + field_execution_weight: 1 + sent_time_offset: 138211218 + sent_time: + seconds: 1669889687 + nanos: 891727207 + received_time: + seconds: 1669889687 + nanos: 941912460 + else_clause: ~ + full_query_cache_hit: false + persisted_query_hit: false + persisted_query_register: false + registered_operation: false + forbidden_operation: false + field_execution_weight: 1 + diff --git a/apollo-router/src/plugins/telemetry/tracing/testdata/condition_else_spandata.yaml b/apollo-router/src/plugins/telemetry/tracing/testdata/condition_else_spandata.yaml new file mode 100644 index 00000000000..79bfeec1195 --- /dev/null +++ b/apollo-router/src/plugins/telemetry/tracing/testdata/condition_else_spandata.yaml @@ -0,0 +1,1222 @@ +--- +- span_context: + trace_id: 241423451034154439021761071644737590229 + span_id: 11040229446866196580 + trace_flags: 1 + is_remote: false + trace_state: ~ + parent_span_id: 1742251638407533446 + span_kind: Internal + name: supergraph + start_time: + secs_since_epoch: 1669889787 + nanos_since_epoch: 664653240 + end_time: + secs_since_epoch: 1669889787 + nanos_since_epoch: 833724241 + attributes: + map: + apollo_private.graphql.variables: + String: "{\"if\":[\"\"]}" + apollo_private.field_level_instrumentation_ratio: + F64: 1.0 + code.lineno: + I64: 687 + graphql.operation.name: + String: "" + client.version: + String: "" + code.namespace: + String: "apollo_router::plugins::telemetry" + idle_ns: + I64: 157491139 + graphql.document: + String: "query($if: Boolean!) {\n topProducts {\n name\n ... @defer(if: $if) {\n reviews {\n author {\n name\n }\n }\n reviews {\n author {\n name\n }\n }\n }\n }\n}" + apollo_private.operation_signature: + String: "# -\nquery($if:Boolean!){topProducts{name...@defer(if:$if){reviews{author{name}}reviews{author{name}}}}}" + code.filepath: + String: apollo-router/src/plugins/telemetry/mod.rs + client.name: + String: "" + thread.id: + I64: 15 + thread.name: + String: tokio-runtime-worker + apollo_private.http.request_headers: + String: "{\"accept\":[\"\"],\"content-length\":[\"\"],\"content-type\":[\"\"],\"host\":[\"\"],\"user-agent\":[\"\"]}" + busy_ns: + I64: 11493818 + evict_list: + - idle_ns + - busy_ns + - apollo_private.operation_signature + - apollo_private.http.request_headers + - apollo_private.graphql.variables + - apollo_private.field_level_instrumentation_ratio + - client.version + - client.name + - graphql.operation.name + - graphql.document + - thread.name + - thread.id + - code.lineno + - code.namespace + - code.filepath + max_len: 128 + dropped_count: 0 + events: + queue: ~ + max_len: 128 + dropped_count: 0 + links: + queue: ~ + max_len: 128 + dropped_count: 0 + status_code: Unset + status_message: "" + resource: + attrs: + process.executable.name: + String: router + service.name: + String: router + service.version: + String: 1.4.0 +- span_context: + trace_id: 241423451034154439021761071644737590229 + span_id: 2903878148672968238 + trace_flags: 1 + is_remote: false + trace_state: ~ + parent_span_id: 11040229446866196580 + span_kind: Internal + name: query_planning + start_time: + secs_since_epoch: 1669889787 + nanos_since_epoch: 665008384 + end_time: + secs_since_epoch: 1669889787 + nanos_since_epoch: 665260302 + attributes: + map: + code.filepath: + String: apollo-router/src/services/supergraph_service.rs + code.namespace: + String: "apollo_router::services::supergraph_service" + code.lineno: + I64: 247 + thread.id: + I64: 15 + graphql.document: + String: "query($if: Boolean!) {\n topProducts {\n name\n ... @defer(if: $if) {\n reviews {\n author {\n name\n }\n }\n reviews {\n author {\n name\n }\n }\n }\n }\n}" + graphql.operation.name: + String: "" + busy_ns: + I64: 174953 + idle_ns: + I64: 74521 + thread.name: + String: tokio-runtime-worker + evict_list: + - idle_ns + - busy_ns + - graphql.operation.name + - graphql.document + - thread.name + - thread.id + - code.lineno + - code.namespace + - code.filepath + max_len: 128 + dropped_count: 0 + events: + queue: ~ + max_len: 128 + dropped_count: 0 + links: + queue: ~ + max_len: 128 + dropped_count: 0 + status_code: Unset + status_message: "" + resource: + attrs: + process.executable.name: + String: router + service.name: + String: router + service.version: + String: 1.4.0 +- span_context: + trace_id: 241423451034154439021761071644737590229 + span_id: 5999425412273508102 + trace_flags: 1 + is_remote: false + trace_state: ~ + parent_span_id: 11040229446866196580 + span_kind: Internal + name: execution + start_time: + secs_since_epoch: 1669889787 + nanos_since_epoch: 665506843 + end_time: + secs_since_epoch: 1669889787 + nanos_since_epoch: 833121369 + attributes: + map: + code.filepath: + String: apollo-router/src/plugins/telemetry/mod.rs + code.namespace: + String: "apollo_router::plugins::telemetry" + thread.id: + I64: 15 + idle_ns: + I64: 156542483 + thread.name: + String: tokio-runtime-worker + code.lineno: + I64: 295 + graphql.operation.name: + String: "" + graphql.document: + String: "query($if: Boolean!) {\n topProducts {\n name\n ... @defer(if: $if) {\n reviews {\n author {\n name\n }\n }\n reviews {\n author {\n name\n }\n }\n }\n }\n}" + busy_ns: + I64: 11092228 + evict_list: + - idle_ns + - busy_ns + - graphql.operation.name + - graphql.document + - thread.name + - thread.id + - code.lineno + - code.namespace + - code.filepath + max_len: 128 + dropped_count: 0 + events: + queue: ~ + max_len: 128 + dropped_count: 0 + links: + queue: ~ + max_len: 128 + dropped_count: 0 + status_code: Unset + status_message: "" + resource: + attrs: + process.executable.name: + String: router + service.name: + String: router + service.version: + String: 1.4.0 +- span_context: + trace_id: 241423451034154439021761071644737590229 + span_id: 11513411186439968114 + trace_flags: 1 + is_remote: false + trace_state: ~ + parent_span_id: 5999425412273508102 + span_kind: Internal + name: condition + start_time: + secs_since_epoch: 1669889787 + nanos_since_epoch: 665620056 + end_time: + secs_since_epoch: 1669889787 + nanos_since_epoch: 832992093 + attributes: + map: + condition: + String: if + idle_ns: + I64: 156736781 + code.lineno: + I64: 322 + thread.id: + I64: 15 + busy_ns: + I64: 10641192 + thread.name: + String: tokio-runtime-worker + code.filepath: + String: apollo-router/src/query_planner/execution.rs + code.namespace: + String: "apollo_router::query_planner::execution" + evict_list: + - idle_ns + - busy_ns + - condition + - thread.name + - thread.id + - code.lineno + - code.namespace + - code.filepath + max_len: 128 + dropped_count: 0 + events: + queue: ~ + max_len: 128 + dropped_count: 0 + links: + queue: ~ + max_len: 128 + dropped_count: 0 + status_code: Unset + status_message: "" + resource: + attrs: + process.executable.name: + String: router + service.name: + String: router + service.version: + String: 1.4.0 +- span_context: + trace_id: 241423451034154439021761071644737590229 + span_id: 7227363968475850651 + trace_flags: 1 + is_remote: false + trace_state: ~ + parent_span_id: 11513411186439968114 + span_kind: Internal + name: condition_else + start_time: + secs_since_epoch: 1669889787 + nanos_since_epoch: 665674882 + end_time: + secs_since_epoch: 1669889787 + nanos_since_epoch: 832920016 + attributes: + map: + thread.name: + String: tokio-runtime-worker + busy_ns: + I64: 10375444 + code.filepath: + String: apollo-router/src/query_planner/execution.rs + code.namespace: + String: "apollo_router::query_planner::execution" + idle_ns: + I64: 156858795 + thread.id: + I64: 15 + code.lineno: + I64: 315 + evict_list: + - idle_ns + - busy_ns + - thread.name + - thread.id + - code.lineno + - code.namespace + - code.filepath + max_len: 128 + dropped_count: 0 + events: + queue: ~ + max_len: 128 + dropped_count: 0 + links: + queue: ~ + max_len: 128 + dropped_count: 0 + status_code: Unset + status_message: "" + resource: + attrs: + process.executable.name: + String: router + service.name: + String: router + service.version: + String: 1.4.0 +- span_context: + trace_id: 241423451034154439021761071644737590229 + span_id: 3562394024950375314 + trace_flags: 1 + is_remote: false + trace_state: ~ + parent_span_id: 7227363968475850651 + span_kind: Internal + name: sequence + start_time: + secs_since_epoch: 1669889787 + nanos_since_epoch: 665703866 + end_time: + secs_since_epoch: 1669889787 + nanos_since_epoch: 832844797 + attributes: + map: + busy_ns: + I64: 9952696 + idle_ns: + I64: 157182858 + code.lineno: + I64: 131 + thread.id: + I64: 15 + thread.name: + String: tokio-runtime-worker + code.filepath: + String: apollo-router/src/query_planner/execution.rs + code.namespace: + String: "apollo_router::query_planner::execution" + evict_list: + - idle_ns + - busy_ns + - thread.name + - thread.id + - code.lineno + - code.namespace + - code.filepath + max_len: 128 + dropped_count: 0 + events: + queue: ~ + max_len: 128 + dropped_count: 0 + links: + queue: ~ + max_len: 128 + dropped_count: 0 + status_code: Unset + status_message: "" + resource: + attrs: + process.executable.name: + String: router + service.name: + String: router + service.version: + String: 1.4.0 +- span_context: + trace_id: 241423451034154439021761071644737590229 + span_id: 3171806008995316844 + trace_flags: 1 + is_remote: false + trace_state: ~ + parent_span_id: 3562394024950375314 + span_kind: Internal + name: fetch + start_time: + secs_since_epoch: 1669889787 + nanos_since_epoch: 665757295 + end_time: + secs_since_epoch: 1669889787 + nanos_since_epoch: 721612554 + attributes: + map: + code.filepath: + String: apollo-router/src/query_planner/execution.rs + thread.name: + String: tokio-runtime-worker + busy_ns: + I64: 2853376 + code.lineno: + I64: 183 + apollo.subgraph.name: + String: products + idle_ns: + I64: 52999788 + apollo_private.sent_time_offset: + I64: 1258683 + code.namespace: + String: "apollo_router::query_planner::execution" + thread.id: + I64: 15 + evict_list: + - idle_ns + - busy_ns + - apollo_private.sent_time_offset + - apollo.subgraph.name + - thread.name + - thread.id + - code.lineno + - code.namespace + - code.filepath + max_len: 128 + dropped_count: 0 + events: + queue: ~ + max_len: 128 + dropped_count: 0 + links: + queue: ~ + max_len: 128 + dropped_count: 0 + status_code: Unset + status_message: "" + resource: + attrs: + process.executable.name: + String: router + service.name: + String: router + service.version: + String: 1.4.0 +- span_context: + trace_id: 241423451034154439021761071644737590229 + span_id: 8981447040431664700 + trace_flags: 1 + is_remote: false + trace_state: ~ + parent_span_id: 3562394024950375314 + span_kind: Internal + name: flatten + start_time: + secs_since_epoch: 1669889787 + nanos_since_epoch: 721823615 + end_time: + secs_since_epoch: 1669889787 + nanos_since_epoch: 780478191 + attributes: + map: + code.lineno: + I64: 171 + path: + String: /topProducts/@ + code.filepath: + String: apollo-router/src/query_planner/execution.rs + thread.name: + String: tokio-runtime-worker + busy_ns: + I64: 3357282 + thread.id: + I64: 16 + idle_ns: + I64: 55288634 + code.namespace: + String: "apollo_router::query_planner::execution" + evict_list: + - idle_ns + - busy_ns + - path + - thread.name + - thread.id + - code.lineno + - code.namespace + - code.filepath + max_len: 128 + dropped_count: 0 + events: + queue: ~ + max_len: 128 + dropped_count: 0 + links: + queue: ~ + max_len: 128 + dropped_count: 0 + status_code: Unset + status_message: "" + resource: + attrs: + process.executable.name: + String: router + service.name: + String: router + service.version: + String: 1.4.0 +- span_context: + trace_id: 241423451034154439021761071644737590229 + span_id: 6073858832559778035 + trace_flags: 1 + is_remote: false + trace_state: ~ + parent_span_id: 3562394024950375314 + span_kind: Internal + name: flatten + start_time: + secs_since_epoch: 1669889787 + nanos_since_epoch: 780771037 + end_time: + secs_since_epoch: 1669889787 + nanos_since_epoch: 832696454 + attributes: + map: + code.filepath: + String: apollo-router/src/query_planner/execution.rs + code.lineno: + I64: 171 + thread.id: + I64: 12 + path: + String: /topProducts/@/reviews/@/author + code.namespace: + String: "apollo_router::query_planner::execution" + busy_ns: + I64: 2911834 + thread.name: + String: tokio-runtime-worker + idle_ns: + I64: 49027761 + evict_list: + - idle_ns + - busy_ns + - path + - thread.name + - thread.id + - code.lineno + - code.namespace + - code.filepath + max_len: 128 + dropped_count: 0 + events: + queue: ~ + max_len: 128 + dropped_count: 0 + links: + queue: ~ + max_len: 128 + dropped_count: 0 + status_code: Unset + status_message: "" + resource: + attrs: + process.executable.name: + String: router + service.name: + String: router + service.version: + String: 1.4.0 +- span_context: + trace_id: 241423451034154439021761071644737590229 + span_id: 12835442046251838696 + trace_flags: 1 + is_remote: false + trace_state: ~ + parent_span_id: 6073858832559778035 + span_kind: Internal + name: fetch + start_time: + secs_since_epoch: 1669889787 + nanos_since_epoch: 780853589 + end_time: + secs_since_epoch: 1669889787 + nanos_since_epoch: 832590225 + attributes: + map: + apollo_private.sent_time_offset: + I64: 116343454 + thread.name: + String: tokio-runtime-worker + apollo.subgraph.name: + String: accounts + code.lineno: + I64: 183 + code.namespace: + String: "apollo_router::query_planner::execution" + thread.id: + I64: 12 + busy_ns: + I64: 2695674 + idle_ns: + I64: 49043196 + code.filepath: + String: apollo-router/src/query_planner/execution.rs + evict_list: + - idle_ns + - busy_ns + - apollo_private.sent_time_offset + - apollo.subgraph.name + - thread.name + - thread.id + - code.lineno + - code.namespace + - code.filepath + max_len: 128 + dropped_count: 0 + events: + queue: ~ + max_len: 128 + dropped_count: 0 + links: + queue: ~ + max_len: 128 + dropped_count: 0 + status_code: Unset + status_message: "" + resource: + attrs: + process.executable.name: + String: router + service.name: + String: router + service.version: + String: 1.4.0 +- span_context: + trace_id: 241423451034154439021761071644737590229 + span_id: 3610481727213722850 + trace_flags: 1 + is_remote: false + trace_state: ~ + parent_span_id: 12835442046251838696 + span_kind: Internal + name: subgraph + start_time: + secs_since_epoch: 1669889787 + nanos_since_epoch: 781326277 + end_time: + secs_since_epoch: 1669889787 + nanos_since_epoch: 832339284 + attributes: + map: + code.lineno: + I64: 327 + thread.id: + I64: 12 + graphql.operation.name: + String: "" + busy_ns: + I64: 1828660 + code.namespace: + String: "apollo_router::plugins::telemetry" + apollo.subgraph.name: + String: accounts + apollo_private.ftv1: + String: GgwI+/2hnAYQgMaYgwMiDAj7/aGcBhCAxpiDA1jj2iZysQFirgEKCV9lbnRpdGllcxoKW19FbnRpdHldIUDBjxNIzZAdYiAQAGIcCgRuYW1lGgZTdHJpbmdAsb0fSL+eIGoEVXNlcmIgEAFiHAoEbmFtZRoGU3RyaW5nQKugIUjnyCFqBFVzZXJiIBACYhwKBG5hbWUaBlN0cmluZ0DjkSJI47QiagRVc2VyYiAQA2IcCgRuYW1lGgZTdHJpbmdA3/giSOeaI2oEVXNlcmoFUXVlcnn5AQAAAAAAAPA/ + idle_ns: + I64: 49194823 + thread.name: + String: tokio-runtime-worker + code.filepath: + String: apollo-router/src/plugins/telemetry/mod.rs + graphql.document: + String: "query($representations:[_Any!]!){_entities(representations:$representations){...on User{name}}}" + evict_list: + - idle_ns + - busy_ns + - apollo_private.ftv1 + - graphql.operation.name + - graphql.document + - apollo.subgraph.name + - thread.name + - thread.id + - code.lineno + - code.namespace + - code.filepath + max_len: 128 + dropped_count: 0 + events: + queue: ~ + max_len: 128 + dropped_count: 0 + links: + queue: ~ + max_len: 128 + dropped_count: 0 + status_code: Unset + status_message: "" + resource: + attrs: + process.executable.name: + String: router + service.name: + String: router + service.version: + String: 1.4.0 +- span_context: + trace_id: 241423451034154439021761071644737590229 + span_id: 10585979809541989539 + trace_flags: 1 + is_remote: false + trace_state: ~ + parent_span_id: 3610481727213722850 + span_kind: Client + name: subgraph_request + start_time: + secs_since_epoch: 1669889787 + nanos_since_epoch: 781627154 + end_time: + secs_since_epoch: 1669889787 + nanos_since_epoch: 831556989 + attributes: + map: + code.lineno: + I64: 173 + apollo.subgraph.name: + String: accounts + code.filepath: + String: apollo-router/src/services/subgraph_service.rs + http.route: + String: /graphql + busy_ns: + I64: 764276 + idle_ns: + I64: 49146842 + thread.name: + String: tokio-runtime-worker + code.namespace: + String: "apollo_router::services::subgraph_service" + net.peer.name: + String: accounts.demo.starstuff.dev + net.peer.port: + String: "80" + thread.id: + I64: 12 + net.transport: + String: ip_tcp + evict_list: + - idle_ns + - busy_ns + - apollo.subgraph.name + - net.transport + - http.route + - net.peer.port + - net.peer.name + - thread.name + - thread.id + - code.lineno + - code.namespace + - code.filepath + max_len: 128 + dropped_count: 0 + events: + queue: ~ + max_len: 128 + dropped_count: 0 + links: + queue: ~ + max_len: 128 + dropped_count: 0 + status_code: Unset + status_message: "" + resource: + attrs: + process.executable.name: + String: router + service.name: + String: router + service.version: + String: 1.4.0 +- span_context: + trace_id: 241423451034154439021761071644737590229 + span_id: 6138999802407292572 + trace_flags: 1 + is_remote: false + trace_state: ~ + parent_span_id: 8981447040431664700 + span_kind: Internal + name: fetch + start_time: + secs_since_epoch: 1669889787 + nanos_since_epoch: 721889405 + end_time: + secs_since_epoch: 1669889787 + nanos_since_epoch: 780306032 + attributes: + map: + code.namespace: + String: "apollo_router::query_planner::execution" + code.lineno: + I64: 183 + apollo.subgraph.name: + String: reviews + idle_ns: + I64: 55311613 + code.filepath: + String: apollo-router/src/query_planner/execution.rs + thread.id: + I64: 16 + apollo_private.sent_time_offset: + I64: 57387931 + busy_ns: + I64: 3098169 + thread.name: + String: tokio-runtime-worker + evict_list: + - idle_ns + - busy_ns + - apollo_private.sent_time_offset + - apollo.subgraph.name + - thread.name + - thread.id + - code.lineno + - code.namespace + - code.filepath + max_len: 128 + dropped_count: 0 + events: + queue: ~ + max_len: 128 + dropped_count: 0 + links: + queue: ~ + max_len: 128 + dropped_count: 0 + status_code: Unset + status_message: "" + resource: + attrs: + process.executable.name: + String: router + service.name: + String: router + service.version: + String: 1.4.0 +- span_context: + trace_id: 241423451034154439021761071644737590229 + span_id: 4904210996315648815 + trace_flags: 1 + is_remote: false + trace_state: ~ + parent_span_id: 6138999802407292572 + span_kind: Internal + name: subgraph + start_time: + secs_since_epoch: 1669889787 + nanos_since_epoch: 722197616 + end_time: + secs_since_epoch: 1669889787 + nanos_since_epoch: 780026875 + attributes: + map: + code.lineno: + I64: 327 + thread.name: + String: tokio-runtime-worker + code.filepath: + String: apollo-router/src/plugins/telemetry/mod.rs + thread.id: + I64: 16 + apollo.subgraph.name: + String: reviews + code.namespace: + String: "apollo_router::plugins::telemetry" + idle_ns: + I64: 55490197 + graphql.document: + String: "query($representations:[_Any!]!){_entities(representations:$representations){...on Product{reviews{author{__typename id}}}}}" + apollo_private.ftv1: + String: GgwI+/2hnAYQwNf16QIiDAj7/aGcBhCA07jpAli3hjRynQNimgMKCV9lbnRpdGllcxoKW19FbnRpdHldIUD4uRBIlKAVYqMBEABingEKB3Jldmlld3MaCFtSZXZpZXddQJyoF0j+hyBiOxAAYjcKBmF1dGhvchoEVXNlckCApCFI+9wrYhcKAmlkGgNJRCFAv88sSK2RLWoEVXNlcmoGUmV2aWV3YjsQAWI3CgZhdXRob3IaBFVzZXJAiu4jSI2pLWIXCgJpZBoDSUQhQKXxLUjpji5qBFVzZXJqBlJldmlld2oHUHJvZHVjdGJlEAFiYQoHcmV2aWV3cxoIW1Jldmlld11A5oUbSIzkJWI7EABiNwoGYXV0aG9yGgRVc2VyQPK/Jki7ri5iFwoCaWQaA0lEIUCp1y5I04ovagRVc2VyagZSZXZpZXdqB1Byb2R1Y3RiZRACYmEKB3Jldmlld3MaCFtSZXZpZXddQLq0HUidpyhiOxAAYjcKBmF1dGhvchoEVXNlckCLlilIwZovYhcKAmlkGgNJRCFA8dAvSLvsL2oEVXNlcmoGUmV2aWV3agdQcm9kdWN0agVRdWVyefkBAAAAAAAA8D8= + graphql.operation.name: + String: "" + busy_ns: + I64: 2342485 + evict_list: + - idle_ns + - busy_ns + - apollo_private.ftv1 + - graphql.operation.name + - graphql.document + - apollo.subgraph.name + - thread.name + - thread.id + - code.lineno + - code.namespace + - code.filepath + max_len: 128 + dropped_count: 0 + events: + queue: ~ + max_len: 128 + dropped_count: 0 + links: + queue: ~ + max_len: 128 + dropped_count: 0 + status_code: Unset + status_message: "" + resource: + attrs: + process.executable.name: + String: router + service.name: + String: router + service.version: + String: 1.4.0 +- span_context: + trace_id: 241423451034154439021761071644737590229 + span_id: 3394522879612717165 + trace_flags: 1 + is_remote: false + trace_state: ~ + parent_span_id: 4904210996315648815 + span_kind: Client + name: subgraph_request + start_time: + secs_since_epoch: 1669889787 + nanos_since_epoch: 722529573 + end_time: + secs_since_epoch: 1669889787 + nanos_since_epoch: 778827278 + attributes: + map: + net.peer.port: + String: "80" + net.peer.name: + String: reviews.demo.starstuff.dev + busy_ns: + I64: 854022 + code.lineno: + I64: 173 + thread.id: + I64: 16 + thread.name: + String: tokio-runtime-worker + net.transport: + String: ip_tcp + apollo.subgraph.name: + String: reviews + idle_ns: + I64: 55426223 + http.route: + String: /graphql + code.filepath: + String: apollo-router/src/services/subgraph_service.rs + code.namespace: + String: "apollo_router::services::subgraph_service" + evict_list: + - idle_ns + - busy_ns + - apollo.subgraph.name + - net.transport + - http.route + - net.peer.port + - net.peer.name + - thread.name + - thread.id + - code.lineno + - code.namespace + - code.filepath + max_len: 128 + dropped_count: 0 + events: + queue: ~ + max_len: 128 + dropped_count: 0 + links: + queue: ~ + max_len: 128 + dropped_count: 0 + status_code: Unset + status_message: "" + resource: + attrs: + process.executable.name: + String: router + service.name: + String: router + service.version: + String: 1.4.0 +- span_context: + trace_id: 241423451034154439021761071644737590229 + span_id: 8956305076273566582 + trace_flags: 1 + is_remote: false + trace_state: ~ + parent_span_id: 3171806008995316844 + span_kind: Internal + name: subgraph + start_time: + secs_since_epoch: 1669889787 + nanos_since_epoch: 665923098 + end_time: + secs_since_epoch: 1669889787 + nanos_since_epoch: 721463582 + attributes: + map: + apollo_private.ftv1: + String: GgwI+/2hnAYQgNfezgIiDAj7/aGcBhDA0qHOAliX4jZy/AFi+QEKC3RvcFByb2R1Y3RzGglbUHJvZHVjdF1A0oASSNCOHGJEEABiHwoDdXBjGgdTdHJpbmchQPyLJ0igmihqB1Byb2R1Y3RiHwoEbmFtZRoGU3RyaW5nQN7vKEiDpypqB1Byb2R1Y3RiRBABYh8KA3VwYxoHU3RyaW5nIUDUsy1I4IMuagdQcm9kdWN0Yh8KBG5hbWUaBlN0cmluZ0Dc8C5I0pYvagdQcm9kdWN0YkQQAmIfCgN1cGMaB1N0cmluZyFAy5cwSPO9MGoHUHJvZHVjdGIfCgRuYW1lGgZTdHJpbmdA4IYxSOG7MWoHUHJvZHVjdGoFUXVlcnn5AQAAAAAAAPA/ + code.filepath: + String: apollo-router/src/plugins/telemetry/mod.rs + code.namespace: + String: "apollo_router::plugins::telemetry" + code.lineno: + I64: 327 + thread.id: + I64: 15 + busy_ns: + I64: 2399895 + idle_ns: + I64: 53143941 + apollo.subgraph.name: + String: products + thread.name: + String: tokio-runtime-worker + graphql.document: + String: "{topProducts{__typename upc name}}" + graphql.operation.name: + String: "" + evict_list: + - idle_ns + - busy_ns + - apollo_private.ftv1 + - graphql.operation.name + - graphql.document + - apollo.subgraph.name + - thread.name + - thread.id + - code.lineno + - code.namespace + - code.filepath + max_len: 128 + dropped_count: 0 + events: + queue: ~ + max_len: 128 + dropped_count: 0 + links: + queue: ~ + max_len: 128 + dropped_count: 0 + status_code: Unset + status_message: "" + resource: + attrs: + process.executable.name: + String: router + service.name: + String: router + service.version: + String: 1.4.0 +- span_context: + trace_id: 241423451034154439021761071644737590229 + span_id: 1429394254881699575 + trace_flags: 1 + is_remote: false + trace_state: ~ + parent_span_id: 8956305076273566582 + span_kind: Client + name: subgraph_request + start_time: + secs_since_epoch: 1669889787 + nanos_since_epoch: 666174039 + end_time: + secs_since_epoch: 1669889787 + nanos_since_epoch: 720334733 + attributes: + map: + code.lineno: + I64: 173 + busy_ns: + I64: 984555 + http.route: + String: /graphql + thread.id: + I64: 15 + thread.name: + String: tokio-runtime-worker + net.peer.port: + String: "80" + net.transport: + String: ip_tcp + apollo.subgraph.name: + String: products + code.namespace: + String: "apollo_router::services::subgraph_service" + idle_ns: + I64: 53145339 + code.filepath: + String: apollo-router/src/services/subgraph_service.rs + net.peer.name: + String: products.demo.starstuff.dev + evict_list: + - idle_ns + - busy_ns + - apollo.subgraph.name + - net.transport + - http.route + - net.peer.port + - net.peer.name + - thread.name + - thread.id + - code.lineno + - code.namespace + - code.filepath + max_len: 128 + dropped_count: 0 + events: + queue: ~ + max_len: 128 + dropped_count: 0 + links: + queue: ~ + max_len: 128 + dropped_count: 0 + status_code: Unset + status_message: "" + resource: + attrs: + process.executable.name: + String: router + service.name: + String: router + service.version: + String: 1.4.0 +- span_context: + trace_id: 241423451034154439021761071644737590229 + span_id: 1742251638407533446 + trace_flags: 1 + is_remote: false + trace_state: ~ + parent_span_id: 0 + span_kind: Server + name: request + start_time: + secs_since_epoch: 1669889787 + nanos_since_epoch: 663946653 + end_time: + secs_since_epoch: 1669889787 + nanos_since_epoch: 834038179 + attributes: + map: + http.route: + String: / + code.filepath: + String: apollo-router/src/axum_factory/utils.rs + code.lineno: + I64: 259 + thread.id: + I64: 15 + apollo_private.duration_ns: + I64: 170136294 + thread.name: + String: tokio-runtime-worker + busy_ns: + I64: 14085565 + idle_ns: + I64: 156001212 + http.method: + String: POST + http.flavor: + String: HTTP/1.1 + trace_id: + String: b5a07721fd79c066109d77fcd2c8d3d5 + code.namespace: + String: "apollo_router::axum_factory::utils" + evict_list: + - idle_ns + - busy_ns + - apollo_private.duration_ns + - trace_id + - http.flavor + - http.route + - http.method + - thread.name + - thread.id + - code.lineno + - code.namespace + - code.filepath + max_len: 128 + dropped_count: 0 + events: + queue: ~ + max_len: 128 + dropped_count: 0 + links: + queue: ~ + max_len: 128 + dropped_count: 0 + status_code: Ok + status_message: "" + resource: + attrs: + process.executable.name: + String: router + service.name: + String: router + service.version: + String: 1.4.0 diff --git a/apollo-router/src/plugins/telemetry/tracing/testdata/condition_if_spandata.yaml b/apollo-router/src/plugins/telemetry/tracing/testdata/condition_if_spandata.yaml new file mode 100644 index 00000000000..5eb96fe3a30 --- /dev/null +++ b/apollo-router/src/plugins/telemetry/tracing/testdata/condition_if_spandata.yaml @@ -0,0 +1,1402 @@ +--- +- span_context: + trace_id: 68597572214826976281453903110565151429 + span_id: 9066603935045941630 + trace_flags: 1 + is_remote: false + trace_state: ~ + parent_span_id: 17238021065393999245 + span_kind: Internal + name: supergraph + start_time: + secs_since_epoch: 1669889687 + nanos_since_epoch: 753731938 + end_time: + secs_since_epoch: 1669889687 + nanos_since_epoch: 943145650 + attributes: + map: + apollo_private.operation_signature: + String: "# -\nquery($if:Boolean!){topProducts{name...@defer(if:$if){reviews{author{name}}reviews{author{name}}}}}" + client.version: + String: "" + apollo_private.http.request_headers: + String: "{\"accept\":[\"\"],\"content-length\":[\"\"],\"content-type\":[\"\"],\"host\":[\"\"],\"user-agent\":[\"\"]}" + code.namespace: + String: "apollo_router::plugins::telemetry" + apollo_private.graphql.variables: + String: "{\"if\":[\"\"]}" + thread.id: + I64: 12 + client.name: + String: "" + busy_ns: + I64: 4321299 + code.lineno: + I64: 687 + apollo_private.field_level_instrumentation_ratio: + F64: 1.0 + code.filepath: + String: apollo-router/src/plugins/telemetry/mod.rs + thread.name: + String: tokio-runtime-worker + graphql.document: + String: "query($if: Boolean!) {\n topProducts {\n name\n ... @defer(if: $if) {\n reviews {\n author {\n name\n }\n }\n reviews {\n author {\n name\n }\n }\n }\n }\n}" + graphql.operation.name: + String: "" + idle_ns: + I64: 185088572 + evict_list: + - idle_ns + - busy_ns + - apollo_private.operation_signature + - apollo_private.http.request_headers + - apollo_private.graphql.variables + - apollo_private.field_level_instrumentation_ratio + - client.version + - client.name + - graphql.operation.name + - graphql.document + - thread.name + - thread.id + - code.lineno + - code.namespace + - code.filepath + max_len: 128 + dropped_count: 0 + events: + queue: ~ + max_len: 128 + dropped_count: 0 + links: + queue: ~ + max_len: 128 + dropped_count: 0 + status_code: Unset + status_message: "" + resource: + attrs: + process.executable.name: + String: router + service.name: + String: router + service.version: + String: 1.4.0 +- span_context: + trace_id: 68597572214826976281453903110565151429 + span_id: 16475097579449127011 + trace_flags: 1 + is_remote: false + trace_state: ~ + parent_span_id: 9066603935045941630 + span_kind: Internal + name: query_planning + start_time: + secs_since_epoch: 1669889687 + nanos_since_epoch: 754166631 + end_time: + secs_since_epoch: 1669889687 + nanos_since_epoch: 754473794 + attributes: + map: + thread.name: + String: tokio-runtime-worker + graphql.document: + String: "query($if: Boolean!) {\n topProducts {\n name\n ... @defer(if: $if) {\n reviews {\n author {\n name\n }\n }\n reviews {\n author {\n name\n }\n }\n }\n }\n}" + code.lineno: + I64: 247 + thread.id: + I64: 12 + code.namespace: + String: "apollo_router::services::supergraph_service" + busy_ns: + I64: 226356 + graphql.operation.name: + String: "" + idle_ns: + I64: 53568 + code.filepath: + String: apollo-router/src/services/supergraph_service.rs + evict_list: + - idle_ns + - busy_ns + - graphql.operation.name + - graphql.document + - thread.name + - thread.id + - code.lineno + - code.namespace + - code.filepath + max_len: 128 + dropped_count: 0 + events: + queue: ~ + max_len: 128 + dropped_count: 0 + links: + queue: ~ + max_len: 128 + dropped_count: 0 + status_code: Unset + status_message: "" + resource: + attrs: + process.executable.name: + String: router + service.name: + String: router + service.version: + String: 1.4.0 +- span_context: + trace_id: 68597572214826976281453903110565151429 + span_id: 13370407496184405775 + trace_flags: 1 + is_remote: false + trace_state: ~ + parent_span_id: 9066603935045941630 + span_kind: Internal + name: execution + start_time: + secs_since_epoch: 1669889687 + nanos_since_epoch: 754802398 + end_time: + secs_since_epoch: 1669889687 + nanos_since_epoch: 942622259 + attributes: + map: + code.filepath: + String: apollo-router/src/plugins/telemetry/mod.rs + code.lineno: + I64: 295 + graphql.operation.name: + String: "" + busy_ns: + I64: 3615340 + code.namespace: + String: "apollo_router::plugins::telemetry" + thread.name: + String: tokio-runtime-worker + graphql.document: + String: "query($if: Boolean!) {\n topProducts {\n name\n ... @defer(if: $if) {\n reviews {\n author {\n name\n }\n }\n reviews {\n author {\n name\n }\n }\n }\n }\n}" + thread.id: + I64: 12 + idle_ns: + I64: 56507020 + evict_list: + - idle_ns + - busy_ns + - graphql.operation.name + - graphql.document + - thread.name + - thread.id + - code.lineno + - code.namespace + - code.filepath + max_len: 128 + dropped_count: 0 + events: + queue: ~ + max_len: 128 + dropped_count: 0 + links: + queue: ~ + max_len: 128 + dropped_count: 0 + status_code: Unset + status_message: "" + resource: + attrs: + process.executable.name: + String: router + service.name: + String: router + service.version: + String: 1.4.0 +- span_context: + trace_id: 68597572214826976281453903110565151429 + span_id: 17796302122798341368 + trace_flags: 1 + is_remote: false + trace_state: ~ + parent_span_id: 13370407496184405775 + span_kind: Internal + name: condition + start_time: + secs_since_epoch: 1669889687 + nanos_since_epoch: 754959750 + end_time: + secs_since_epoch: 1669889687 + nanos_since_epoch: 942588874 + attributes: + map: + code.lineno: + I64: 322 + busy_ns: + I64: 3385353 + thread.id: + I64: 12 + condition: + String: if + idle_ns: + I64: 56502550 + code.filepath: + String: apollo-router/src/query_planner/execution.rs + code.namespace: + String: "apollo_router::query_planner::execution" + thread.name: + String: tokio-runtime-worker + evict_list: + - idle_ns + - busy_ns + - condition + - thread.name + - thread.id + - code.lineno + - code.namespace + - code.filepath + max_len: 128 + dropped_count: 0 + events: + queue: ~ + max_len: 128 + dropped_count: 0 + links: + queue: ~ + max_len: 128 + dropped_count: 0 + status_code: Unset + status_message: "" + resource: + attrs: + process.executable.name: + String: router + service.name: + String: router + service.version: + String: 1.4.0 +- span_context: + trace_id: 68597572214826976281453903110565151429 + span_id: 7922060920455773162 + trace_flags: 1 + is_remote: false + trace_state: ~ + parent_span_id: 17796302122798341368 + span_kind: Internal + name: condition_if + start_time: + secs_since_epoch: 1669889687 + nanos_since_epoch: 755016462 + end_time: + secs_since_epoch: 1669889687 + nanos_since_epoch: 942555071 + attributes: + map: + idle_ns: + I64: 56529649 + code.namespace: + String: "apollo_router::query_planner::execution" + thread.id: + I64: 12 + thread.name: + String: tokio-runtime-worker + busy_ns: + I64: 3285899 + code.lineno: + I64: 301 + code.filepath: + String: apollo-router/src/query_planner/execution.rs + evict_list: + - idle_ns + - busy_ns + - thread.name + - thread.id + - code.lineno + - code.namespace + - code.filepath + max_len: 128 + dropped_count: 0 + events: + queue: ~ + max_len: 128 + dropped_count: 0 + links: + queue: ~ + max_len: 128 + dropped_count: 0 + status_code: Unset + status_message: "" + resource: + attrs: + process.executable.name: + String: router + service.name: + String: router + service.version: + String: 1.4.0 +- span_context: + trace_id: 68597572214826976281453903110565151429 + span_id: 7367125078563119750 + trace_flags: 1 + is_remote: false + trace_state: ~ + parent_span_id: 7922060920455773162 + span_kind: Internal + name: defer + start_time: + secs_since_epoch: 1669889687 + nanos_since_epoch: 755052779 + end_time: + secs_since_epoch: 1669889687 + nanos_since_epoch: 942503528 + attributes: + map: + thread.id: + I64: 12 + code.namespace: + String: "apollo_router::query_planner::execution" + thread.name: + String: tokio-runtime-worker + code.lineno: + I64: 266 + code.filepath: + String: apollo-router/src/query_planner/execution.rs + busy_ns: + I64: 7998729 + idle_ns: + I64: 179450134 + evict_list: + - idle_ns + - busy_ns + - thread.name + - thread.id + - code.lineno + - code.namespace + - code.filepath + max_len: 128 + dropped_count: 0 + events: + queue: ~ + max_len: 128 + dropped_count: 0 + links: + queue: ~ + max_len: 128 + dropped_count: 0 + status_code: Unset + status_message: "" + resource: + attrs: + process.executable.name: + String: router + service.name: + String: router + service.version: + String: 1.4.0 +- span_context: + trace_id: 68597572214826976281453903110565151429 + span_id: 2133409655394903629 + trace_flags: 1 + is_remote: false + trace_state: ~ + parent_span_id: 7367125078563119750 + span_kind: Internal + name: defer_primary + start_time: + secs_since_epoch: 1669889687 + nanos_since_epoch: 755511428 + end_time: + secs_since_epoch: 1669889687 + nanos_since_epoch: 814646161 + attributes: + map: + thread.id: + I64: 12 + thread.name: + String: tokio-runtime-worker + busy_ns: + I64: 2545021 + code.lineno: + I64: 254 + idle_ns: + I64: 56592994 + code.namespace: + String: "apollo_router::query_planner::execution" + code.filepath: + String: apollo-router/src/query_planner/execution.rs + evict_list: + - idle_ns + - busy_ns + - thread.name + - thread.id + - code.lineno + - code.namespace + - code.filepath + max_len: 128 + dropped_count: 0 + events: + queue: ~ + max_len: 128 + dropped_count: 0 + links: + queue: ~ + max_len: 128 + dropped_count: 0 + status_code: Unset + status_message: "" + resource: + attrs: + process.executable.name: + String: router + service.name: + String: router + service.version: + String: 1.4.0 +- span_context: + trace_id: 68597572214826976281453903110565151429 + span_id: 2645274118651895120 + trace_flags: 1 + is_remote: false + trace_state: ~ + parent_span_id: 7367125078563119750 + span_kind: Internal + name: defer_deferred + start_time: + secs_since_epoch: 1669889687 + nanos_since_epoch: 814865184 + end_time: + secs_since_epoch: 1669889687 + nanos_since_epoch: 942212499 + attributes: + map: + thread.id: + I64: 8 + thread.name: + String: tokio-runtime-worker + busy_ns: + I64: 6053017 + code.filepath: + String: apollo-router/src/query_planner/execution.rs + code.namespace: + String: "apollo_router::query_planner::execution" + code.lineno: + I64: 423 + depends: + String: "[{\"id\":\"0\",\"deferLabel\":null}]" + idle_ns: + I64: 121313504 + evict_list: + - idle_ns + - busy_ns + - depends + - thread.name + - thread.id + - code.lineno + - code.namespace + - code.filepath + max_len: 128 + dropped_count: 0 + events: + queue: ~ + max_len: 128 + dropped_count: 0 + links: + queue: ~ + max_len: 128 + dropped_count: 0 + status_code: Unset + status_message: "" + resource: + attrs: + process.executable.name: + String: router + service.name: + String: router + service.version: + String: 1.4.0 +- span_context: + trace_id: 68597572214826976281453903110565151429 + span_id: 18331475190939397625 + trace_flags: 1 + is_remote: false + trace_state: ~ + parent_span_id: 2645274118651895120 + span_kind: Internal + name: sequence + start_time: + secs_since_epoch: 1669889687 + nanos_since_epoch: 815028333 + end_time: + secs_since_epoch: 1669889687 + nanos_since_epoch: 942149712 + attributes: + map: + code.lineno: + I64: 131 + code.filepath: + String: apollo-router/src/query_planner/execution.rs + thread.name: + String: tokio-runtime-worker + idle_ns: + I64: 121412470 + code.namespace: + String: "apollo_router::query_planner::execution" + busy_ns: + I64: 5733632 + thread.id: + I64: 8 + evict_list: + - idle_ns + - busy_ns + - thread.name + - thread.id + - code.lineno + - code.namespace + - code.filepath + max_len: 128 + dropped_count: 0 + events: + queue: ~ + max_len: 128 + dropped_count: 0 + links: + queue: ~ + max_len: 128 + dropped_count: 0 + status_code: Unset + status_message: "" + resource: + attrs: + process.executable.name: + String: router + service.name: + String: router + service.version: + String: 1.4.0 +- span_context: + trace_id: 68597572214826976281453903110565151429 + span_id: 13515135247330952689 + trace_flags: 1 + is_remote: false + trace_state: ~ + parent_span_id: 18331475190939397625 + span_kind: Internal + name: flatten + start_time: + secs_since_epoch: 1669889687 + nanos_since_epoch: 815110257 + end_time: + secs_since_epoch: 1669889687 + nanos_since_epoch: 891354324 + attributes: + map: + code.namespace: + String: "apollo_router::query_planner::execution" + thread.id: + I64: 8 + thread.name: + String: tokio-runtime-worker + path: + String: /topProducts/@ + busy_ns: + I64: 2785764 + code.filepath: + String: apollo-router/src/query_planner/execution.rs + idle_ns: + I64: 73456695 + code.lineno: + I64: 171 + evict_list: + - idle_ns + - busy_ns + - path + - thread.name + - thread.id + - code.lineno + - code.namespace + - code.filepath + max_len: 128 + dropped_count: 0 + events: + queue: ~ + max_len: 128 + dropped_count: 0 + links: + queue: ~ + max_len: 128 + dropped_count: 0 + status_code: Unset + status_message: "" + resource: + attrs: + process.executable.name: + String: router + service.name: + String: router + service.version: + String: 1.4.0 +- span_context: + trace_id: 68597572214826976281453903110565151429 + span_id: 13225643629515892610 + trace_flags: 1 + is_remote: false + trace_state: ~ + parent_span_id: 18331475190939397625 + span_kind: Internal + name: flatten + start_time: + secs_since_epoch: 1669889687 + nanos_since_epoch: 891646051 + end_time: + secs_since_epoch: 1669889687 + nanos_since_epoch: 942014359 + attributes: + map: + code.lineno: + I64: 171 + path: + String: /topProducts/@/reviews/@/author + busy_ns: + I64: 2470710 + thread.id: + I64: 12 + idle_ns: + I64: 47912474 + code.namespace: + String: "apollo_router::query_planner::execution" + thread.name: + String: tokio-runtime-worker + code.filepath: + String: apollo-router/src/query_planner/execution.rs + evict_list: + - idle_ns + - busy_ns + - path + - thread.name + - thread.id + - code.lineno + - code.namespace + - code.filepath + max_len: 128 + dropped_count: 0 + events: + queue: ~ + max_len: 128 + dropped_count: 0 + links: + queue: ~ + max_len: 128 + dropped_count: 0 + status_code: Unset + status_message: "" + resource: + attrs: + process.executable.name: + String: router + service.name: + String: router + service.version: + String: 1.4.0 +- span_context: + trace_id: 68597572214826976281453903110565151429 + span_id: 10741625915594774883 + trace_flags: 1 + is_remote: false + trace_state: ~ + parent_span_id: 13225643629515892610 + span_kind: Internal + name: fetch + start_time: + secs_since_epoch: 1669889687 + nanos_since_epoch: 891727207 + end_time: + secs_since_epoch: 1669889687 + nanos_since_epoch: 941912460 + attributes: + map: + busy_ns: + I64: 2285490 + code.namespace: + String: "apollo_router::query_planner::execution" + code.lineno: + I64: 183 + idle_ns: + I64: 47900322 + thread.id: + I64: 12 + code.filepath: + String: apollo-router/src/query_planner/execution.rs + thread.name: + String: tokio-runtime-worker + apollo.subgraph.name: + String: accounts + apollo_private.sent_time_offset: + I64: 138211218 + evict_list: + - idle_ns + - busy_ns + - apollo_private.sent_time_offset + - apollo.subgraph.name + - thread.name + - thread.id + - code.lineno + - code.namespace + - code.filepath + max_len: 128 + dropped_count: 0 + events: + queue: ~ + max_len: 128 + dropped_count: 0 + links: + queue: ~ + max_len: 128 + dropped_count: 0 + status_code: Unset + status_message: "" + resource: + attrs: + process.executable.name: + String: router + service.name: + String: router + service.version: + String: 1.4.0 +- span_context: + trace_id: 68597572214826976281453903110565151429 + span_id: 1225334337962278768 + trace_flags: 1 + is_remote: false + trace_state: ~ + parent_span_id: 10741625915594774883 + span_kind: Internal + name: subgraph + start_time: + secs_since_epoch: 1669889687 + nanos_since_epoch: 892156522 + end_time: + secs_since_epoch: 1669889687 + nanos_since_epoch: 941660403 + attributes: + map: + graphql.operation.name: + String: "" + thread.name: + String: tokio-runtime-worker + code.filepath: + String: apollo-router/src/plugins/telemetry/mod.rs + graphql.document: + String: "query($representations:[_Any!]!){_entities(representations:$representations){...on User{name}}}" + busy_ns: + I64: 1461920 + thread.id: + I64: 12 + code.lineno: + I64: 327 + apollo.subgraph.name: + String: accounts + apollo_private.ftv1: + String: GgwIl/2hnAYQgLXStwMiDAiX/aGcBhDAsJW3A1iJ3CJysQFirgEKCV9lbnRpdGllcxoKW19FbnRpdHldIUCd8xJIja4ZYiAQAGIcCgRuYW1lGgZTdHJpbmdAh9IbSJGnHGoEVXNlcmIgEAFiHAoEbmFtZRoGU3RyaW5nQM++HUiH7x1qBFVzZXJiIBACYhwKBG5hbWUaBlN0cmluZ0Cptx5Iid4eagRVc2VyYiAQA2IcCgRuYW1lGgZTdHJpbmdA+aAfSIO6H2oEVXNlcmoFUXVlcnn5AQAAAAAAAPA/ + code.namespace: + String: "apollo_router::plugins::telemetry" + idle_ns: + I64: 48052227 + evict_list: + - idle_ns + - busy_ns + - apollo_private.ftv1 + - graphql.operation.name + - graphql.document + - apollo.subgraph.name + - thread.name + - thread.id + - code.lineno + - code.namespace + - code.filepath + max_len: 128 + dropped_count: 0 + events: + queue: ~ + max_len: 128 + dropped_count: 0 + links: + queue: ~ + max_len: 128 + dropped_count: 0 + status_code: Unset + status_message: "" + resource: + attrs: + process.executable.name: + String: router + service.name: + String: router + service.version: + String: 1.4.0 +- span_context: + trace_id: 68597572214826976281453903110565151429 + span_id: 2608858271409465801 + trace_flags: 1 + is_remote: false + trace_state: ~ + parent_span_id: 1225334337962278768 + span_kind: Client + name: subgraph_request + start_time: + secs_since_epoch: 1669889687 + nanos_since_epoch: 892549450 + end_time: + secs_since_epoch: 1669889687 + nanos_since_epoch: 940856877 + attributes: + map: + net.transport: + String: ip_tcp + thread.id: + I64: 12 + busy_ns: + I64: 303810 + code.lineno: + I64: 173 + idle_ns: + I64: 47988391 + code.namespace: + String: "apollo_router::services::subgraph_service" + code.filepath: + String: apollo-router/src/services/subgraph_service.rs + thread.name: + String: tokio-runtime-worker + net.peer.name: + String: accounts.demo.starstuff.dev + apollo.subgraph.name: + String: accounts + net.peer.port: + String: "80" + http.route: + String: /graphql + evict_list: + - idle_ns + - busy_ns + - apollo.subgraph.name + - net.transport + - http.route + - net.peer.port + - net.peer.name + - thread.name + - thread.id + - code.lineno + - code.namespace + - code.filepath + max_len: 128 + dropped_count: 0 + events: + queue: ~ + max_len: 128 + dropped_count: 0 + links: + queue: ~ + max_len: 128 + dropped_count: 0 + status_code: Unset + status_message: "" + resource: + attrs: + process.executable.name: + String: router + service.name: + String: router + service.version: + String: 1.4.0 +- span_context: + trace_id: 68597572214826976281453903110565151429 + span_id: 7788094551464642292 + trace_flags: 1 + is_remote: false + trace_state: ~ + parent_span_id: 13515135247330952689 + span_kind: Internal + name: fetch + start_time: + secs_since_epoch: 1669889687 + nanos_since_epoch: 815176886 + end_time: + secs_since_epoch: 1669889687 + nanos_since_epoch: 891210939 + attributes: + map: + apollo_private.sent_time_offset: + I64: 61661177 + thread.id: + I64: 8 + code.lineno: + I64: 183 + code.namespace: + String: "apollo_router::query_planner::execution" + thread.name: + String: tokio-runtime-worker + idle_ns: + I64: 73473038 + code.filepath: + String: apollo-router/src/query_planner/execution.rs + busy_ns: + I64: 2542996 + apollo.subgraph.name: + String: reviews + evict_list: + - idle_ns + - busy_ns + - apollo_private.sent_time_offset + - apollo.subgraph.name + - thread.name + - thread.id + - code.lineno + - code.namespace + - code.filepath + max_len: 128 + dropped_count: 0 + events: + queue: ~ + max_len: 128 + dropped_count: 0 + links: + queue: ~ + max_len: 128 + dropped_count: 0 + status_code: Unset + status_message: "" + resource: + attrs: + process.executable.name: + String: router + service.name: + String: router + service.version: + String: 1.4.0 +- span_context: + trace_id: 68597572214826976281453903110565151429 + span_id: 17233494816129207457 + trace_flags: 1 + is_remote: false + trace_state: ~ + parent_span_id: 7788094551464642292 + span_kind: Internal + name: subgraph + start_time: + secs_since_epoch: 1669889687 + nanos_since_epoch: 815544252 + end_time: + secs_since_epoch: 1669889687 + nanos_since_epoch: 890840500 + attributes: + map: + thread.id: + I64: 8 + graphql.document: + String: "query($representations:[_Any!]!){_entities(representations:$representations){...on Product{reviews{author{__typename id}}}}}" + apollo.subgraph.name: + String: reviews + apollo_private.ftv1: + String: GgwIl/2hnAYQwL21nQMiDAiX/aGcBhCAnoqaA1j2yO4CcrUDYrIDCglfZW50aXRpZXMaCltfRW50aXR5XSFAvf6yAUjO8tQBYq0BEABiqAEKB3Jldmlld3MaCFtSZXZpZXddQIe44QFI0K2UAmI/EABiOwoGYXV0aG9yGgRVc2VyQN3MmAJIxJzNAmIZCgJpZBoDSUQhQKj90wJIm+HVAmoEVXNlcmoGUmV2aWV3Yj8QAWI7CgZhdXRob3IaBFVzZXJAwqynAkjdndYCYhkKAmlkGgNJRCFAt5XXAkiQnNgCagRVc2VyagZSZXZpZXdqB1Byb2R1Y3RiaxABYmcKB3Jldmlld3MaCFtSZXZpZXddQKLR7gFI5tGwAmI/EABiOwoGYXV0aG9yGgRVc2VyQL3gsgJIoL/YAmIZCgJpZBoDSUQhQMXl2QJIkd3aAmoEVXNlcmoGUmV2aWV3agdQcm9kdWN0YmsQAmJnCgdyZXZpZXdzGghbUmV2aWV3XUDw6YACSLilvgJiPxAAYjsKBmF1dGhvchoEVXNlckDB18ACSLqx2wJiGQoCaWQaA0lEIUCHpN4CSJGg3wJqBFVzZXJqBlJldmlld2oHUHJvZHVjdGoFUXVlcnn5AQAAAAAAAPA/ + code.filepath: + String: apollo-router/src/plugins/telemetry/mod.rs + code.namespace: + String: "apollo_router::plugins::telemetry" + thread.name: + String: tokio-runtime-worker + code.lineno: + I64: 327 + graphql.operation.name: + String: "" + busy_ns: + I64: 1683038 + idle_ns: + I64: 73618867 + evict_list: + - idle_ns + - busy_ns + - apollo_private.ftv1 + - graphql.operation.name + - graphql.document + - apollo.subgraph.name + - thread.name + - thread.id + - code.lineno + - code.namespace + - code.filepath + max_len: 128 + dropped_count: 0 + events: + queue: ~ + max_len: 128 + dropped_count: 0 + links: + queue: ~ + max_len: 128 + dropped_count: 0 + status_code: Unset + status_message: "" + resource: + attrs: + process.executable.name: + String: router + service.name: + String: router + service.version: + String: 1.4.0 +- span_context: + trace_id: 68597572214826976281453903110565151429 + span_id: 11405247984316043638 + trace_flags: 1 + is_remote: false + trace_state: ~ + parent_span_id: 17233494816129207457 + span_kind: Client + name: subgraph_request + start_time: + secs_since_epoch: 1669889687 + nanos_since_epoch: 815852881 + end_time: + secs_since_epoch: 1669889687 + nanos_since_epoch: 889705298 + attributes: + map: + thread.id: + I64: 8 + net.peer.name: + String: reviews.demo.starstuff.dev + apollo.subgraph.name: + String: reviews + busy_ns: + I64: 299201 + code.namespace: + String: "apollo_router::services::subgraph_service" + code.lineno: + I64: 173 + idle_ns: + I64: 73519063 + code.filepath: + String: apollo-router/src/services/subgraph_service.rs + net.peer.port: + String: "80" + thread.name: + String: tokio-runtime-worker + http.route: + String: /graphql + net.transport: + String: ip_tcp + evict_list: + - idle_ns + - busy_ns + - apollo.subgraph.name + - net.transport + - http.route + - net.peer.port + - net.peer.name + - thread.name + - thread.id + - code.lineno + - code.namespace + - code.filepath + max_len: 128 + dropped_count: 0 + events: + queue: ~ + max_len: 128 + dropped_count: 0 + links: + queue: ~ + max_len: 128 + dropped_count: 0 + status_code: Unset + status_message: "" + resource: + attrs: + process.executable.name: + String: router + service.name: + String: router + service.version: + String: 1.4.0 +- span_context: + trace_id: 68597572214826976281453903110565151429 + span_id: 5060734982312800774 + trace_flags: 1 + is_remote: false + trace_state: ~ + parent_span_id: 2133409655394903629 + span_kind: Internal + name: fetch + start_time: + secs_since_epoch: 1669889687 + nanos_since_epoch: 755593491 + end_time: + secs_since_epoch: 1669889687 + nanos_since_epoch: 814463456 + attributes: + map: + apollo_private.sent_time_offset: + I64: 2064512 + code.filepath: + String: apollo-router/src/query_planner/execution.rs + code.lineno: + I64: 183 + thread.id: + I64: 12 + apollo.subgraph.name: + String: products + idle_ns: + I64: 56632802 + code.namespace: + String: "apollo_router::query_planner::execution" + busy_ns: + I64: 2233740 + thread.name: + String: tokio-runtime-worker + evict_list: + - idle_ns + - busy_ns + - apollo_private.sent_time_offset + - apollo.subgraph.name + - thread.name + - thread.id + - code.lineno + - code.namespace + - code.filepath + max_len: 128 + dropped_count: 0 + events: + queue: ~ + max_len: 128 + dropped_count: 0 + links: + queue: ~ + max_len: 128 + dropped_count: 0 + status_code: Unset + status_message: "" + resource: + attrs: + process.executable.name: + String: router + service.name: + String: router + service.version: + String: 1.4.0 +- span_context: + trace_id: 68597572214826976281453903110565151429 + span_id: 5209234650142948103 + trace_flags: 1 + is_remote: false + trace_state: ~ + parent_span_id: 5060734982312800774 + span_kind: Internal + name: subgraph + start_time: + secs_since_epoch: 1669889687 + nanos_since_epoch: 755816286 + end_time: + secs_since_epoch: 1669889687 + nanos_since_epoch: 814189817 + attributes: + map: + graphql.document: + String: "{topProducts{__typename name upc}}" + busy_ns: + I64: 1623814 + idle_ns: + I64: 56753838 + code.lineno: + I64: 327 + code.namespace: + String: "apollo_router::plugins::telemetry" + thread.name: + String: tokio-runtime-worker + apollo.subgraph.name: + String: products + thread.id: + I64: 12 + code.filepath: + String: apollo-router/src/plugins/telemetry/mod.rs + graphql.operation.name: + String: "" + apollo_private.ftv1: + String: GgwIl/2hnAYQgPXN+gIiDAiX/aGcBhCA9c36Alix7i9y/AFi+QEKC3RvcFByb2R1Y3RzGglbUHJvZHVjdF1Al7QVSPiSHmJEEABiHwoEbmFtZRoGU3RyaW5nQOOrIkiN0CNqB1Byb2R1Y3RiHwoDdXBjGgdTdHJpbmchQIrUJEixmSVqB1Byb2R1Y3RiRBABYh8KBG5hbWUaBlN0cmluZ0CX0iZIi40nagdQcm9kdWN0Yh8KA3VwYxoHU3RyaW5nIUCR4idI3JAoagdQcm9kdWN0YkQQAmIfCgRuYW1lGgZTdHJpbmdAxKkpSPjVKWoHUHJvZHVjdGIfCgN1cGMaB1N0cmluZyFA7YUqSLvHKmoHUHJvZHVjdGoFUXVlcnn5AQAAAAAAAPA/ + evict_list: + - idle_ns + - busy_ns + - apollo_private.ftv1 + - graphql.operation.name + - graphql.document + - apollo.subgraph.name + - thread.name + - thread.id + - code.lineno + - code.namespace + - code.filepath + max_len: 128 + dropped_count: 0 + events: + queue: ~ + max_len: 128 + dropped_count: 0 + links: + queue: ~ + max_len: 128 + dropped_count: 0 + status_code: Unset + status_message: "" + resource: + attrs: + process.executable.name: + String: router + service.name: + String: router + service.version: + String: 1.4.0 +- span_context: + trace_id: 68597572214826976281453903110565151429 + span_id: 12727006893174321562 + trace_flags: 1 + is_remote: false + trace_state: ~ + parent_span_id: 5209234650142948103 + span_kind: Client + name: subgraph_request + start_time: + secs_since_epoch: 1669889687 + nanos_since_epoch: 756142166 + end_time: + secs_since_epoch: 1669889687 + nanos_since_epoch: 813160983 + attributes: + map: + net.peer.port: + String: "80" + apollo.subgraph.name: + String: products + busy_ns: + I64: 309119 + idle_ns: + I64: 56699222 + thread.name: + String: tokio-runtime-worker + http.route: + String: /graphql + code.lineno: + I64: 173 + thread.id: + I64: 12 + net.transport: + String: ip_tcp + code.namespace: + String: "apollo_router::services::subgraph_service" + code.filepath: + String: apollo-router/src/services/subgraph_service.rs + net.peer.name: + String: products.demo.starstuff.dev + evict_list: + - idle_ns + - busy_ns + - apollo.subgraph.name + - net.transport + - http.route + - net.peer.port + - net.peer.name + - thread.name + - thread.id + - code.lineno + - code.namespace + - code.filepath + max_len: 128 + dropped_count: 0 + events: + queue: ~ + max_len: 128 + dropped_count: 0 + links: + queue: ~ + max_len: 128 + dropped_count: 0 + status_code: Unset + status_message: "" + resource: + attrs: + process.executable.name: + String: router + service.name: + String: router + service.version: + String: 1.4.0 +- span_context: + trace_id: 68597572214826976281453903110565151429 + span_id: 17238021065393999245 + trace_flags: 1 + is_remote: false + trace_state: ~ + parent_span_id: 0 + span_kind: Server + name: request + start_time: + secs_since_epoch: 1669889687 + nanos_since_epoch: 752748920 + end_time: + secs_since_epoch: 1669889687 + nanos_since_epoch: 943291968 + attributes: + map: + code.lineno: + I64: 259 + http.method: + String: POST + trace_id: + String: 339b696e9d17212c0cab33a94c7242c5 + busy_ns: + I64: 6908016 + http.route: + String: / + code.filepath: + String: apollo-router/src/axum_factory/utils.rs + thread.name: + String: tokio-runtime-worker + code.namespace: + String: "apollo_router::axum_factory::utils" + http.flavor: + String: HTTP/1.1 + idle_ns: + I64: 183479705 + thread.id: + I64: 12 + apollo_private.duration_ns: + I64: 63124634 + evict_list: + - idle_ns + - busy_ns + - apollo_private.duration_ns + - trace_id + - http.flavor + - http.route + - http.method + - thread.name + - thread.id + - code.lineno + - code.namespace + - code.filepath + max_len: 128 + dropped_count: 0 + events: + queue: ~ + max_len: 128 + dropped_count: 0 + links: + queue: ~ + max_len: 128 + dropped_count: 0 + status_code: Ok + status_message: "" + resource: + attrs: + process.executable.name: + String: router + service.name: + String: router + service.version: + String: 1.4.0 diff --git a/apollo-router/src/query_planner/execution.rs b/apollo-router/src/query_planner/execution.rs index 21dcc605bbc..cf7350e008a 100644 --- a/apollo-router/src/query_planner/execution.rs +++ b/apollo-router/src/query_planner/execution.rs @@ -19,12 +19,17 @@ use crate::graphql::Response; use crate::json_ext::Path; use crate::json_ext::Value; use crate::json_ext::ValueExt; -use crate::query_planner::FlattenNode; use crate::query_planner::Primary; +use crate::query_planner::CONDITION_ELSE_SPAN_NAME; +use crate::query_planner::CONDITION_IF_SPAN_NAME; +use crate::query_planner::CONDITION_SPAN_NAME; +use crate::query_planner::DEFER_DEFERRED_SPAN_NAME; +use crate::query_planner::DEFER_SPAN_NAME; use crate::query_planner::FETCH_SPAN_NAME; use crate::query_planner::FLATTEN_SPAN_NAME; use crate::query_planner::PARALLEL_SPAN_NAME; use crate::query_planner::SEQUENCE_SPAN_NAME; +use crate::query_planner::{FlattenNode, DEFER_PRIMARY_SPAN_NAME}; use crate::services::subgraph_service::SubgraphServiceFactory; use crate::*; @@ -107,45 +112,50 @@ impl PlanNode { PlanNode::Sequence { nodes } => { value = parent_value.clone(); errors = Vec::new(); - let span = tracing::info_span!(SEQUENCE_SPAN_NAME); - for node in nodes { - let (v, subselect, err) = node - .execute_recursively(parameters, current_dir, &value, sender.clone()) - .instrument(span.clone()) - .in_current_span() - .await; - value.deep_merge(v); - errors.extend(err.into_iter()); - subselection = subselect; + async { + for node in nodes { + let (v, subselect, err) = node + .execute_recursively( + parameters, + current_dir, + &value, + sender.clone(), + ) + .in_current_span() + .await; + value.deep_merge(v); + errors.extend(err.into_iter()); + subselection = subselect; + } } + .instrument(tracing::info_span!(SEQUENCE_SPAN_NAME)) + .await } PlanNode::Parallel { nodes } => { value = Value::default(); errors = Vec::new(); + async { + let mut stream: stream::FuturesUnordered<_> = nodes + .iter() + .map(|plan| { + plan.execute_recursively( + parameters, + current_dir, + parent_value, + sender.clone(), + ) + .in_current_span() + }) + .collect(); - let span = tracing::info_span!(PARALLEL_SPAN_NAME); - let mut stream: stream::FuturesUnordered<_> = nodes - .iter() - .map(|plan| { - plan.execute_recursively( - parameters, - current_dir, - parent_value, - sender.clone(), - ) - .instrument(span.clone()) - }) - .collect(); - - while let Some((v, _subselect, err)) = stream - .next() - .instrument(span.clone()) - .in_current_span() - .await - { - value.deep_merge(v); - errors.extend(err.into_iter()); + while let Some((v, _subselect, err)) = stream.next().in_current_span().await + { + value.deep_merge(v); + errors.extend(err.into_iter()); + } } + .instrument(tracing::info_span!(PARALLEL_SPAN_NAME)) + .await } PlanNode::Flatten(FlattenNode { path, node }) => { // Note that the span must be `info` as we need to pick this up in apollo tracing @@ -158,9 +168,7 @@ impl PlanNode { parent_value, sender, ) - .instrument( - tracing::info_span!(FLATTEN_SPAN_NAME, apollo_private.path = %current_dir), - ) + .instrument(tracing::info_span!(FLATTEN_SPAN_NAME, path = %current_dir)) .await; value = v; @@ -200,66 +208,63 @@ impl PlanNode { }, deferred, } => { - let mut deferred_fetches: HashMap)>> = - HashMap::new(); - let mut futures = Vec::new(); - - let (primary_sender, _) = tokio::sync::broadcast::channel::(1); + value = parent_value.clone(); + errors = Vec::new(); + async { + let mut deferred_fetches: HashMap)>> = + HashMap::new(); + let mut futures = Vec::new(); - for deferred_node in deferred { - let fut = deferred_node.execute( - parameters, - parent_value, - sender.clone(), - &primary_sender, - &mut deferred_fetches, - ); + let (primary_sender, _) = tokio::sync::broadcast::channel::(1); - futures.push(fut); - } + for deferred_node in deferred { + let fut = deferred_node + .execute( + parameters, + parent_value, + sender.clone(), + &primary_sender, + &mut deferred_fetches, + ) + .in_current_span(); - tokio::task::spawn( - async move { - join_all(futures).await; + futures.push(fut); } - .in_current_span(), - ); - value = parent_value.clone(); - errors = Vec::new(); - let span = tracing::info_span!("primary"); - if let Some(node) = node { - let (v, _subselect, err) = node - .execute_recursively( - &ExecutionParameters { - context: parameters.context, - service_factory: parameters.service_factory, - schema: parameters.schema, - supergraph_request: parameters.supergraph_request, - deferred_fetches: &deferred_fetches, - options: parameters.options, - query: parameters.query, - }, - current_dir, - &value, - sender, - ) - .instrument(span.clone()) - .in_current_span() - .await; - let _guard = span.enter(); - value.deep_merge(v); - errors.extend(err.into_iter()); - subselection = primary_subselection.clone(); - - let _ = primary_sender.send(value.clone()); - } else { - let _guard = span.enter(); + tokio::task::spawn(async move { + join_all(futures).await; + }); - subselection = primary_subselection.clone(); + if let Some(node) = node { + let (v, _subselect, err) = node + .execute_recursively( + &ExecutionParameters { + context: parameters.context, + service_factory: parameters.service_factory, + schema: parameters.schema, + supergraph_request: parameters.supergraph_request, + deferred_fetches: &deferred_fetches, + options: parameters.options, + query: parameters.query, + }, + current_dir, + &value, + sender, + ) + .instrument(tracing::info_span!(DEFER_PRIMARY_SPAN_NAME)) + .await; + value.deep_merge(v); + errors.extend(err.into_iter()); + subselection = primary_subselection.clone(); - let _ = primary_sender.send(value.clone()); + let _ = primary_sender.send(value.clone()); + } else { + subselection = primary_subselection.clone(); + let _ = primary_sender.send(value.clone()); + } } + .instrument(tracing::info_span!(DEFER_SPAN_NAME)) + .await } PlanNode::Condition { condition, @@ -269,23 +274,37 @@ impl PlanNode { value = Value::default(); errors = Vec::new(); - let v = parameters - .query - .variable_value( - parameters - .supergraph_request - .body() - .operation_name - .as_deref(), - condition.as_str(), - ¶meters.supergraph_request.body().variables, - ) - .unwrap_or(&Value::Bool(true)); // the defer if clause is mandatory, and defaults to true - - if let &Value::Bool(true) = v { - //FIXME: should we show an error if the if_node was not present? - if let Some(node) = if_clause { - let span = tracing::info_span!("condition_if"); + async { + let v = parameters + .query + .variable_value( + parameters + .supergraph_request + .body() + .operation_name + .as_deref(), + condition.as_str(), + ¶meters.supergraph_request.body().variables, + ) + .unwrap_or(&Value::Bool(true)); // the defer if clause is mandatory, and defaults to true + + if let &Value::Bool(true) = v { + //FIXME: should we show an error if the if_node was not present? + if let Some(node) = if_clause { + let (v, subselect, err) = node + .execute_recursively( + parameters, + current_dir, + parent_value, + sender.clone(), + ) + .instrument(tracing::info_span!(CONDITION_IF_SPAN_NAME)) + .await; + value.deep_merge(v); + errors.extend(err.into_iter()); + subselection = subselect; + } + } else if let Some(node) = else_clause { let (v, subselect, err) = node .execute_recursively( parameters, @@ -293,29 +312,18 @@ impl PlanNode { parent_value, sender.clone(), ) - .instrument(span.clone()) - .in_current_span() + .instrument(tracing::info_span!(CONDITION_ELSE_SPAN_NAME)) .await; value.deep_merge(v); errors.extend(err.into_iter()); subselection = subselect; } - } else if let Some(node) = else_clause { - let span = tracing::info_span!("condition_else"); - let (v, subselect, err) = node - .execute_recursively( - parameters, - current_dir, - parent_value, - sender.clone(), - ) - .instrument(span.clone()) - .in_current_span() - .await; - value.deep_merge(v); - errors.extend(err.into_iter()); - subselection = subselect; } + .instrument(tracing::info_span!( + CONDITION_SPAN_NAME, + "condition" = condition + )) + .await } } @@ -374,7 +382,7 @@ impl DeferredNode { let query = parameters.query.clone(); let mut primary_receiver = primary_sender.subscribe(); let mut value = parent_value.clone(); - + let depends_json = serde_json::to_string(&self.depends).unwrap_or_default(); async move { let mut errors = Vec::new(); @@ -394,7 +402,6 @@ impl DeferredNode { } } - let span = tracing::info_span!("deferred"); let deferred_fetches = HashMap::new(); if let Some(node) = deferred_inner { @@ -413,8 +420,11 @@ impl DeferredNode { &value, tx.clone(), ) - .instrument(span.clone()) - .in_current_span() + .instrument(tracing::info_span!( + DEFER_DEFERRED_SPAN_NAME, + "label" = label, + "depends" = depends_json + )) .await; if !is_depends_empty { diff --git a/apollo-router/src/query_planner/mod.rs b/apollo-router/src/query_planner/mod.rs index 1163724e552..25a7d6a57ea 100644 --- a/apollo-router/src/query_planner/mod.rs +++ b/apollo-router/src/query_planner/mod.rs @@ -20,6 +20,12 @@ pub(crate) const FETCH_SPAN_NAME: &str = "fetch"; pub(crate) const FLATTEN_SPAN_NAME: &str = "flatten"; pub(crate) const SEQUENCE_SPAN_NAME: &str = "sequence"; pub(crate) const PARALLEL_SPAN_NAME: &str = "parallel"; +pub(crate) const DEFER_SPAN_NAME: &str = "defer"; +pub(crate) const DEFER_PRIMARY_SPAN_NAME: &str = "defer_primary"; +pub(crate) const DEFER_DEFERRED_SPAN_NAME: &str = "defer_deferred"; +pub(crate) const CONDITION_SPAN_NAME: &str = "condition"; +pub(crate) const CONDITION_IF_SPAN_NAME: &str = "condition_if"; +pub(crate) const CONDITION_ELSE_SPAN_NAME: &str = "condition_else"; // The code resides in a separate submodule to allow writing a log filter activating it // separately from the query planner logs, as follows: diff --git a/apollo-router/src/query_planner/plan.rs b/apollo-router/src/query_planner/plan.rs index 873b6d45934..2635d081b9c 100644 --- a/apollo-router/src/query_planner/plan.rs +++ b/apollo-router/src/query_planner/plan.rs @@ -132,17 +132,6 @@ impl PlanNode { } } - pub(crate) fn contains_condition_or_defer(&self) -> bool { - match self { - Self::Sequence { nodes } => nodes.iter().any(|n| n.contains_condition_or_defer()), - Self::Parallel { nodes } => nodes.iter().any(|n| n.contains_condition_or_defer()), - Self::Flatten(node) => node.node.contains_condition_or_defer(), - Self::Fetch(..) => false, - Self::Defer { .. } => true, - Self::Condition { .. } => true, - } - } - pub(crate) fn is_deferred( &self, operation: Option<&str>, diff --git a/apollo-router/src/spaceport/proto/reports.proto b/apollo-router/src/spaceport/proto/reports.proto index 831f3abaf3a..b7d8bea517c 100644 --- a/apollo-router/src/spaceport/proto/reports.proto +++ b/apollo-router/src/spaceport/proto/reports.proto @@ -169,7 +169,7 @@ message Trace { message DeferredNode { repeated DeferredNodeDepends depends = 1; string label = 2; - ResponsePathElement path = 3; + repeated ResponsePathElement path = 3; QueryPlanNode node = 4; } message DeferredNodeDepends { diff --git a/xtask/src/commands/all.rs b/xtask/src/commands/all.rs index 7d290002499..206d21fe858 100644 --- a/xtask/src/commands/all.rs +++ b/xtask/src/commands/all.rs @@ -18,7 +18,7 @@ pub struct All { impl All { pub fn run(&self) -> Result<()> { eprintln!("Checking licenses..."); - self.compliance.run_local()?; + self.compliance.run_local(); eprintln!("Checking format and clippy..."); self.lint.run_local()?; eprintln!("Running tests...");