From fc904f88482fa3ef898c4e73166d867365849089 Mon Sep 17 00:00:00 2001 From: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com> Date: Thu, 25 Jul 2024 17:14:59 +0200 Subject: [PATCH 1/3] add support of other format for trace id Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com> --- apollo-router/src/plugins/telemetry/config.rs | 25 ++++++++- .../plugins/telemetry/config_new/logging.rs | 42 +++++++++++++-- .../plugins/telemetry/config_new/selectors.rs | 51 ++++++++++++------- .../src/plugins/telemetry/formatters/json.rs | 25 +++++++-- .../src/plugins/telemetry/formatters/text.rs | 21 +++++++- apollo-router/src/plugins/telemetry/mod.rs | 6 ++- 6 files changed, 140 insertions(+), 30 deletions(-) diff --git a/apollo-router/src/plugins/telemetry/config.rs b/apollo-router/src/plugins/telemetry/config.rs index 1f36eb4c34..59eee4939a 100644 --- a/apollo-router/src/plugins/telemetry/config.rs +++ b/apollo-router/src/plugins/telemetry/config.rs @@ -232,14 +232,18 @@ pub(crate) struct ExposeTraceId { pub(crate) format: TraceIdFormat, } -#[derive(Clone, Default, Debug, Deserialize, JsonSchema)] -#[serde(deny_unknown_fields, rename_all = "lowercase")] +#[derive(Clone, Default, Debug, Deserialize, JsonSchema, PartialEq, Eq)] +#[serde(deny_unknown_fields, rename_all = "snake_case")] pub(crate) enum TraceIdFormat { /// Format the Trace ID as a hexadecimal number /// /// (e.g. Trace ID 16 -> 00000000000000000000000000000010) #[default] Hexadecimal, + /// Format the Trace ID as a hexadecimal number + /// + /// (e.g. Trace ID 16 -> 00000000000000000000000000000010) + OpenTelemetry, /// Format the Trace ID as a decimal number /// /// (e.g. Trace ID 16 -> 16) @@ -247,6 +251,23 @@ pub(crate) enum TraceIdFormat { /// Datadog Datadog, + + /// UUID format with dashes + /// (eg. 67e55044-10b1-426f-9247-bb680e5fe0c8) + Uuid, +} + +impl TraceIdFormat { + pub(crate) fn format(&self, trace_id: TraceId) -> String { + match self { + TraceIdFormat::Hexadecimal | TraceIdFormat::OpenTelemetry => { + format!("{:032x}", trace_id) + } + TraceIdFormat::Decimal => format!("{}", u128::from_be_bytes(trace_id.to_bytes())), + TraceIdFormat::Datadog => trace_id.to_datadog(), + TraceIdFormat::Uuid => Uuid::from_bytes(trace_id.to_bytes()).to_string(), + } + } } /// Apollo usage report signature normalization algorithm diff --git a/apollo-router/src/plugins/telemetry/config_new/logging.rs b/apollo-router/src/plugins/telemetry/config_new/logging.rs index 0439142c5e..be9aeefdb4 100644 --- a/apollo-router/src/plugins/telemetry/config_new/logging.rs +++ b/apollo-router/src/plugins/telemetry/config_new/logging.rs @@ -18,6 +18,7 @@ use serde::Deserializer; use crate::configuration::ConfigurationError; use crate::plugins::telemetry::config::AttributeValue; +use crate::plugins::telemetry::config::TraceIdFormat; use crate::plugins::telemetry::config_new::experimental_when_header::HeaderLoggingCondition; use crate::plugins::telemetry::resource::ConfigResource; use crate::services::SupergraphRequest; @@ -335,11 +336,44 @@ pub(crate) struct JsonFormat { /// Include the resource with the log event. (default: true) pub(crate) display_resource: bool, /// Include the trace id (if any) with the log event. (default: true) - pub(crate) display_trace_id: bool, + pub(crate) display_trace_id: DisplayTraceIdFormat, /// Include the span id (if any) with the log event. (default: true) pub(crate) display_span_id: bool, } +#[derive(Clone, Debug, Deserialize, JsonSchema, PartialEq, Eq)] +#[serde(deny_unknown_fields, rename_all = "snake_case", untagged)] +pub(crate) enum DisplayTraceIdFormat { + // /// Format the Trace ID as a hexadecimal number + // /// + // /// (e.g. Trace ID 16 -> 00000000000000000000000000000010) + // #[default] + // Hexadecimal, + // /// Format the Trace ID as a hexadecimal number + // /// + // /// (e.g. Trace ID 16 -> 00000000000000000000000000000010) + // OpenTelemetry, + // /// Format the Trace ID as a decimal number + // /// + // /// (e.g. Trace ID 16 -> 16) + // Decimal, + + // /// Datadog + // Datadog, + + // /// UUID format with dashes + // /// (eg. 67e55044-10b1-426f-9247-bb680e5fe0c8) + // Uuid, + TraceIdFormat(TraceIdFormat), + Bool(bool), +} + +impl Default for DisplayTraceIdFormat { + fn default() -> Self { + Self::TraceIdFormat(TraceIdFormat::default()) + } +} + impl Default for JsonFormat { fn default() -> Self { JsonFormat { @@ -353,7 +387,7 @@ impl Default for JsonFormat { display_current_span: false, display_span_list: true, display_resource: true, - display_trace_id: true, + display_trace_id: DisplayTraceIdFormat::Bool(true), display_span_id: true, } } @@ -389,7 +423,7 @@ pub(crate) struct TextFormat { /// Include all of the containing span information with the log event. (default: true) pub(crate) display_span_list: bool, /// Include the trace id (if any) with the log event. (default: false) - pub(crate) display_trace_id: bool, + pub(crate) display_trace_id: DisplayTraceIdFormat, /// Include the span id (if any) with the log event. (default: false) pub(crate) display_span_id: bool, } @@ -410,7 +444,7 @@ impl Default for TextFormat { display_resource: false, display_current_span: true, display_span_list: true, - display_trace_id: false, + display_trace_id: DisplayTraceIdFormat::Bool(false), display_span_id: false, } } diff --git a/apollo-router/src/plugins/telemetry/config_new/selectors.rs b/apollo-router/src/plugins/telemetry/config_new/selectors.rs index 3f8cde2faf..7e33c420de 100644 --- a/apollo-router/src/plugins/telemetry/config_new/selectors.rs +++ b/apollo-router/src/plugins/telemetry/config_new/selectors.rs @@ -16,13 +16,13 @@ use crate::plugins::cache::entity::CacheSubgraph; use crate::plugins::cache::metrics::CacheMetricContextKey; use crate::plugins::demand_control::CostContext; use crate::plugins::telemetry::config::AttributeValue; +use crate::plugins::telemetry::config::TraceIdFormat; use crate::plugins::telemetry::config_new::cost::CostValue; use crate::plugins::telemetry::config_new::get_baggage; use crate::plugins::telemetry::config_new::instruments::Event; use crate::plugins::telemetry::config_new::instruments::InstrumentValue; use crate::plugins::telemetry::config_new::instruments::Standard; use crate::plugins::telemetry::config_new::trace_id; -use crate::plugins::telemetry::config_new::DatadogId; use crate::plugins::telemetry::config_new::Selector; use crate::plugins::telemetry::config_new::ToOtelValue; use crate::query_planner::APOLLO_OPERATION_ID; @@ -33,15 +33,6 @@ use crate::services::FIRST_EVENT_CONTEXT_KEY; use crate::spec::operation_limits::OperationLimits; use crate::Context; -#[derive(Deserialize, JsonSchema, Clone, Debug, PartialEq)] -#[serde(deny_unknown_fields, rename_all = "snake_case")] -pub(crate) enum TraceIdFormat { - /// Open Telemetry trace ID, a hex string. - OpenTelemetry, - /// Datadog trace ID, a u64. - Datadog, -} - #[derive(Deserialize, JsonSchema, Clone, Debug, PartialEq)] #[serde(deny_unknown_fields, rename_all = "snake_case")] pub(crate) enum OperationName { @@ -681,13 +672,7 @@ impl Selector for RouterSelector { .map(opentelemetry::Value::from), RouterSelector::TraceId { trace_id: trace_id_format, - } => trace_id().map(|id| { - match trace_id_format { - TraceIdFormat::OpenTelemetry => id.to_string(), - TraceIdFormat::Datadog => id.to_datadog(), - } - .into() - }), + } => trace_id().map(|id| trace_id_format.format(id).into()), RouterSelector::Baggage { baggage, default, .. } => get_baggage(baggage).or_else(|| default.maybe_to_otel_value()), @@ -2318,7 +2303,7 @@ mod test { let subscriber = tracing_subscriber::registry().with(otel::layer()); subscriber::with_default(subscriber, || { let selector = RouterSelector::TraceId { - trace_id: TraceIdFormat::OpenTelemetry, + trace_id: TraceIdFormat::Hexadecimal, }; assert_eq!( selector.on_request( @@ -2367,6 +2352,36 @@ mod test { .unwrap(), opentelemetry::Value::String("42".into()) ); + + let selector = RouterSelector::TraceId { + trace_id: TraceIdFormat::Uuid, + }; + + assert_eq!( + selector + .on_request( + &crate::services::RouterRequest::fake_builder() + .build() + .unwrap(), + ) + .unwrap(), + opentelemetry::Value::String("00000000-0000-0000-0000-00000000002a".into()) + ); + + let selector = RouterSelector::TraceId { + trace_id: TraceIdFormat::Decimal, + }; + + assert_eq!( + selector + .on_request( + &crate::services::RouterRequest::fake_builder() + .build() + .unwrap(), + ) + .unwrap(), + opentelemetry::Value::String("42".into()) + ); }); } diff --git a/apollo-router/src/plugins/telemetry/formatters/json.rs b/apollo-router/src/plugins/telemetry/formatters/json.rs index 8b0dd7fcf2..b7952c2701 100644 --- a/apollo-router/src/plugins/telemetry/formatters/json.rs +++ b/apollo-router/src/plugins/telemetry/formatters/json.rs @@ -21,6 +21,8 @@ use super::EventFormatter; use super::APOLLO_PRIVATE_PREFIX; use super::EXCLUDED_ATTRIBUTES; use crate::plugins::telemetry::config::AttributeValue; +use crate::plugins::telemetry::config::TraceIdFormat; +use crate::plugins::telemetry::config_new::logging::DisplayTraceIdFormat; use crate::plugins::telemetry::config_new::logging::JsonFormat; use crate::plugins::telemetry::dynamic_attribute::EventAttributes; use crate::plugins::telemetry::dynamic_attribute::LogAttributes; @@ -227,12 +229,29 @@ where if let Some(ref span) = current_span { if let Some((trace_id, span_id)) = get_trace_and_span_id(span) { - if self.config.display_trace_id { + let trace_id = match self.config.display_trace_id { + DisplayTraceIdFormat::Bool(true) + | DisplayTraceIdFormat::TraceIdFormat(TraceIdFormat::Hexadecimal) + | DisplayTraceIdFormat::TraceIdFormat(TraceIdFormat::OpenTelemetry) => { + Some(TraceIdFormat::Hexadecimal.format(trace_id)) + } + DisplayTraceIdFormat::TraceIdFormat(TraceIdFormat::Decimal) => { + Some(TraceIdFormat::Decimal.format(trace_id)) + } + DisplayTraceIdFormat::TraceIdFormat(TraceIdFormat::Datadog) => { + Some(TraceIdFormat::Datadog.format(trace_id)) + } + DisplayTraceIdFormat::TraceIdFormat(TraceIdFormat::Uuid) => { + Some(TraceIdFormat::Uuid.format(trace_id)) + } + DisplayTraceIdFormat::Bool(false) => None, + }; + if let Some(trace_id) = trace_id { serializer - .serialize_entry("trace_id", &trace_id.to_string()) + .serialize_entry("trace_id", &trace_id) .unwrap_or(()); } - if self.config.display_trace_id { + if self.config.display_span_id { serializer .serialize_entry("span_id", &span_id.to_string()) .unwrap_or(()); diff --git a/apollo-router/src/plugins/telemetry/formatters/text.rs b/apollo-router/src/plugins/telemetry/formatters/text.rs index 4ea440bacc..d809496964 100644 --- a/apollo-router/src/plugins/telemetry/formatters/text.rs +++ b/apollo-router/src/plugins/telemetry/formatters/text.rs @@ -27,6 +27,8 @@ use super::get_trace_and_span_id; use super::EventFormatter; use super::APOLLO_PRIVATE_PREFIX; use super::EXCLUDED_ATTRIBUTES; +use crate::plugins::telemetry::config::TraceIdFormat; +use crate::plugins::telemetry::config_new::logging::DisplayTraceIdFormat; use crate::plugins::telemetry::config_new::logging::TextFormat; use crate::plugins::telemetry::dynamic_attribute::EventAttributes; use crate::plugins::telemetry::dynamic_attribute::LogAttributes; @@ -324,7 +326,24 @@ where if let Some(ref span) = current_span { if let Some((trace_id, span_id)) = get_trace_and_span_id(span) { - if self.config.display_trace_id { + let trace_id = match self.config.display_trace_id { + DisplayTraceIdFormat::Bool(true) + | DisplayTraceIdFormat::TraceIdFormat(TraceIdFormat::Hexadecimal) + | DisplayTraceIdFormat::TraceIdFormat(TraceIdFormat::OpenTelemetry) => { + Some(TraceIdFormat::Hexadecimal.format(trace_id)) + } + DisplayTraceIdFormat::TraceIdFormat(TraceIdFormat::Decimal) => { + Some(TraceIdFormat::Decimal.format(trace_id)) + } + DisplayTraceIdFormat::TraceIdFormat(TraceIdFormat::Datadog) => { + Some(TraceIdFormat::Datadog.format(trace_id)) + } + DisplayTraceIdFormat::TraceIdFormat(TraceIdFormat::Uuid) => { + Some(TraceIdFormat::Uuid.format(trace_id)) + } + DisplayTraceIdFormat::Bool(false) => None, + }; + if let Some(trace_id) = trace_id { write!(writer, "trace_id: {} ", trace_id)?; } if self.config.display_span_id { diff --git a/apollo-router/src/plugins/telemetry/mod.rs b/apollo-router/src/plugins/telemetry/mod.rs index 42b34cbfae..43c96bf6b1 100644 --- a/apollo-router/src/plugins/telemetry/mod.rs +++ b/apollo-router/src/plugins/telemetry/mod.rs @@ -56,6 +56,7 @@ use tokio::runtime::Handle; use tower::BoxError; use tower::ServiceBuilder; use tower::ServiceExt; +use uuid::Uuid; use self::apollo::ForwardValues; use self::apollo::LicensedOperationCountByType; @@ -594,9 +595,10 @@ impl Plugin for Telemetry { // Append the trace ID with the right format, based on the config let format_id = |trace_id: TraceId| { let id = match config.exporters.tracing.response_trace_id.format { - TraceIdFormat::Hexadecimal => format!("{:032x}", trace_id), + TraceIdFormat::Hexadecimal | TraceIdFormat::OpenTelemetry => format!("{:032x}", trace_id), TraceIdFormat::Decimal => format!("{}", u128::from_be_bytes(trace_id.to_bytes())), - TraceIdFormat::Datadog => trace_id.to_datadog() + TraceIdFormat::Datadog => trace_id.to_datadog(), + TraceIdFormat::Uuid => Uuid::from_bytes(trace_id.to_bytes()).to_string(), }; HeaderValue::from_str(&id).ok() From 7c1669d83caa140e4c721eea1d73073dc07d46cd Mon Sep 17 00:00:00 2001 From: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com> Date: Mon, 29 Jul 2024 11:05:31 +0200 Subject: [PATCH 2/3] changelog Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com> --- .changesets/feat_bnjjj_feat_417.md | 27 ++++++++++ ...nfiguration__tests__schema_generation.snap | 49 ++++++++++--------- 2 files changed, 54 insertions(+), 22 deletions(-) create mode 100644 .changesets/feat_bnjjj_feat_417.md diff --git a/.changesets/feat_bnjjj_feat_417.md b/.changesets/feat_bnjjj_feat_417.md new file mode 100644 index 0000000000..d4aa827ccd --- /dev/null +++ b/.changesets/feat_bnjjj_feat_417.md @@ -0,0 +1,27 @@ +### Add support of other format for trace id in telemetry ([PR #5735](https://github.com/apollographql/router/pull/5735)) + +Currently we support datadog and otel traceID formats and decimal. However we would like to also support UUID. + +Unify the two `TraceIdFormat` enums into a single enum that us used across selectors and experimental_expose_trace id. + +Ensure the following formats are supported: + ++ open_telemetry ++ hexadecimal (same as opentelemetry) ++ decimal ++ datadog ++ uuid (this has dashes) + +Add support for logging to output using `TraceIdFormat` + +```yaml + telemetry: + exporters: + logging: + stdout: + format: + json: + disaplay_trace_id: (true|false|open_telemetry|hexadecimal|decimal|datadog|uuid) +``` + +By [@bnjjj](https://github.com/bnjjj) in https://github.com/apollographql/router/pull/5735 \ No newline at end of file diff --git a/apollo-router/src/configuration/snapshots/apollo_router__configuration__tests__schema_generation.snap b/apollo-router/src/configuration/snapshots/apollo_router__configuration__tests__schema_generation.snap index 1f66e536ba..b898226b84 100644 --- a/apollo-router/src/configuration/snapshots/apollo_router__configuration__tests__schema_generation.snap +++ b/apollo-router/src/configuration/snapshots/apollo_router__configuration__tests__schema_generation.snap @@ -2114,6 +2114,17 @@ expression: "&schema" ], "type": "string" }, + "DisplayTraceIdFormat": { + "anyOf": [ + { + "$ref": "#/definitions/TraceIdFormat", + "description": "#/definitions/TraceIdFormat" + }, + { + "type": "boolean" + } + ] + }, "Enabled": { "enum": [ "enabled" @@ -2527,8 +2538,8 @@ expression: "&schema" "type": "boolean" }, "format": { - "$ref": "#/definitions/TraceIdFormat2", - "description": "#/definitions/TraceIdFormat2" + "$ref": "#/definitions/TraceIdFormat", + "description": "#/definitions/TraceIdFormat" }, "header_name": { "description": "Choose the header name to expose trace_id (default: apollo-trace-id)", @@ -7101,27 +7112,16 @@ expression: "&schema" "TraceIdFormat": { "oneOf": [ { - "description": "Open Telemetry trace ID, a hex string.", + "description": "Format the Trace ID as a hexadecimal number\n\n(e.g. Trace ID 16 -> 00000000000000000000000000000010)", "enum": [ - "open_telemetry" + "hexadecimal" ], "type": "string" }, - { - "description": "Datadog trace ID, a u64.", - "enum": [ - "datadog" - ], - "type": "string" - } - ] - }, - "TraceIdFormat2": { - "oneOf": [ { "description": "Format the Trace ID as a hexadecimal number\n\n(e.g. Trace ID 16 -> 00000000000000000000000000000010)", "enum": [ - "hexadecimal" + "open_telemetry" ], "type": "string" }, @@ -7138,6 +7138,13 @@ expression: "&schema" "datadog" ], "type": "string" + }, + { + "description": "UUID format with dashes (eg. 67e55044-10b1-426f-9247-bb680e5fe0c8)", + "enum": [ + "uuid" + ], + "type": "string" } ] }, @@ -8086,9 +8093,8 @@ expression: "&schema" "type": "boolean" }, "display_trace_id": { - "default": true, - "description": "Include the trace id (if any) with the log event. (default: true)", - "type": "boolean" + "$ref": "#/definitions/DisplayTraceIdFormat", + "description": "#/definitions/DisplayTraceIdFormat" } }, "type": "object" @@ -8184,9 +8190,8 @@ expression: "&schema" "type": "boolean" }, "display_trace_id": { - "default": false, - "description": "Include the trace id (if any) with the log event. (default: false)", - "type": "boolean" + "$ref": "#/definitions/DisplayTraceIdFormat", + "description": "#/definitions/DisplayTraceIdFormat" } }, "type": "object" From 93ed3a6f61433e0b17f66e241164da16464c745c Mon Sep 17 00:00:00 2001 From: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com> Date: Wed, 31 Jul 2024 16:10:48 +0200 Subject: [PATCH 3/3] add integration tests Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com> --- apollo-router/tests/common.rs | 3 +- .../telemetry/fixtures/json.uuid.router.yaml | 30 +++++++++ .../telemetry/fixtures/text.uuid.router.yaml | 31 +++++++++ .../tests/integration/telemetry/logging.rs | 64 +++++++++++++++++++ 4 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 apollo-router/tests/integration/telemetry/fixtures/json.uuid.router.yaml create mode 100644 apollo-router/tests/integration/telemetry/fixtures/text.uuid.router.yaml diff --git a/apollo-router/tests/common.rs b/apollo-router/tests/common.rs index 6eddc3dc70..8cd6ffc1c0 100644 --- a/apollo-router/tests/common.rs +++ b/apollo-router/tests/common.rs @@ -540,7 +540,7 @@ impl IntegrationTest { async move { let span = info_span!("client_request"); let span_id = span.context().span().span_context().trace_id(); - + dbg!(&span_id); async move { let client = reqwest::Client::new(); @@ -558,6 +558,7 @@ impl IntegrationTest { .build() .unwrap(); telemetry.inject_context(&mut request); + dbg!(&request.headers()); request.headers_mut().remove(ACCEPT); match client.execute(request).await { Ok(response) => (span_id, response), diff --git a/apollo-router/tests/integration/telemetry/fixtures/json.uuid.router.yaml b/apollo-router/tests/integration/telemetry/fixtures/json.uuid.router.yaml new file mode 100644 index 0000000000..7b9a97af99 --- /dev/null +++ b/apollo-router/tests/integration/telemetry/fixtures/json.uuid.router.yaml @@ -0,0 +1,30 @@ +telemetry: + instrumentation: + spans: + mode: spec_compliant + events: + router: + # Standard events + request: info + response: info + error: info + exporters: + tracing: + propagation: + trace_context: true + jaeger: true + jaeger: + enabled: true + batch_processor: + scheduled_delay: 100ms + agent: + endpoint: default + logging: + experimental_when_header: + - name: content-type + value: "application/json" + body: true + stdout: + format: + json: + display_trace_id: uuid diff --git a/apollo-router/tests/integration/telemetry/fixtures/text.uuid.router.yaml b/apollo-router/tests/integration/telemetry/fixtures/text.uuid.router.yaml new file mode 100644 index 0000000000..13b6084b49 --- /dev/null +++ b/apollo-router/tests/integration/telemetry/fixtures/text.uuid.router.yaml @@ -0,0 +1,31 @@ +telemetry: + instrumentation: + spans: + mode: spec_compliant + events: + router: + # Standard events + request: info + response: info + error: info + exporters: + tracing: + propagation: + trace_context: true + jaeger: true + jaeger: + enabled: true + batch_processor: + scheduled_delay: 100ms + agent: + endpoint: default + logging: + experimental_when_header: + - name: content-type + value: "application/json" + body: true + stdout: + format: + text: + display_trace_id: uuid + display_span_id: true diff --git a/apollo-router/tests/integration/telemetry/logging.rs b/apollo-router/tests/integration/telemetry/logging.rs index c0d8998f51..74cecef1c5 100644 --- a/apollo-router/tests/integration/telemetry/logging.rs +++ b/apollo-router/tests/integration/telemetry/logging.rs @@ -1,5 +1,6 @@ use serde_json::json; use tower::BoxError; +use uuid::Uuid; use crate::integration::common::graph_os_enabled; use crate::integration::common::IntegrationTest; @@ -8,6 +9,7 @@ use crate::integration::common::Telemetry; #[tokio::test(flavor = "multi_thread")] async fn test_json() -> Result<(), BoxError> { if !graph_os_enabled() { + eprintln!("test skipped"); return Ok(()); } @@ -34,6 +36,66 @@ async fn test_json() -> Result<(), BoxError> { Ok(()) } +#[tokio::test(flavor = "multi_thread")] +async fn test_json_uuid_format() -> Result<(), BoxError> { + if !graph_os_enabled() { + eprintln!("test skipped"); + return Ok(()); + } + + let mut router = IntegrationTest::builder() + .telemetry(Telemetry::Jaeger) + .config(include_str!("fixtures/json.uuid.router.yaml")) + .build() + .await; + + router.start().await; + router.assert_started().await; + + let query = json!({"query":"query ExampleQuery {topProducts{name}}","variables":{}}); + router.execute_query(&query).await; + router.assert_log_contains("trace_id").await; + let (trace_id, _) = router.execute_query(&query).await; + router + .assert_log_contains(&format!("{}", Uuid::from_bytes(trace_id.to_bytes()))) + .await; + router.execute_query(&query).await; + router.assert_log_contains("span_id").await; + router.graceful_shutdown().await; + + Ok(()) +} + +#[tokio::test(flavor = "multi_thread")] +async fn test_text_uuid_format() -> Result<(), BoxError> { + if !graph_os_enabled() { + eprintln!("test skipped"); + return Ok(()); + } + + let mut router = IntegrationTest::builder() + .telemetry(Telemetry::Jaeger) + .config(include_str!("fixtures/text.uuid.router.yaml")) + .build() + .await; + + router.start().await; + router.assert_started().await; + + let query = json!({"query":"query ExampleQuery {topProducts{name}}","variables":{}}); + router.execute_query(&query).await; + router.assert_log_contains("trace_id").await; + let (trace_id, _) = router.execute_query(&query).await; + router + .assert_log_contains(&format!("{}", Uuid::from_bytes(trace_id.to_bytes()))) + .await; + router.execute_query(&query).await; + router.assert_log_contains("span_id").await; + router.graceful_shutdown().await; + + Ok(()) +} + #[tokio::test(flavor = "multi_thread")] async fn test_json_sampler_off() -> Result<(), BoxError> { if !graph_os_enabled() { @@ -66,6 +128,7 @@ async fn test_json_sampler_off() -> Result<(), BoxError> { #[tokio::test(flavor = "multi_thread")] async fn test_text() -> Result<(), BoxError> { if !graph_os_enabled() { + eprintln!("test skipped"); return Ok(()); } @@ -93,6 +156,7 @@ async fn test_text() -> Result<(), BoxError> { #[tokio::test(flavor = "multi_thread")] async fn test_text_sampler_off() -> Result<(), BoxError> { if !graph_os_enabled() { + eprintln!("test skipped"); return Ok(()); }