Skip to content

Commit

Permalink
Add Support for AWS X-Ray Tracing Propagator (apollographql#3580)
Browse files Browse the repository at this point in the history
Adds support for the OpenTelemetry AWS X-Ray tracing
[propagator](https://docs.rs/opentelemetry-aws/latest/opentelemetry_aws/).

This propagator helps propagate tracing information from upstream
services (such as AWS load balancers) to downstream services and handles
conversion between the X-Ray trace id format and OpenTelemetry span
contexts.
  • Loading branch information
scottmace authored and johnnywalker committed Sep 21, 2023
1 parent a16ad64 commit 1d17cac
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changesets/feat_sm_add_awsxray_propagator.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Adds support for the OpenTelemetry AWS X-Ray tracing propagator.

This propagator helps propagate tracing information from upstream services (such as AWS load balancers) to downstream services and handles conversion between the X-Ray trace id format and OpenTelemetry span contexts.

By [@scottmace](https://github.com/scottmace) in https://github.com/apollographql/router/pull/3580
11 changes: 11 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ dependencies = [
"nu-ansi-term 0.49.0",
"once_cell",
"opentelemetry",
"opentelemetry-aws",
"opentelemetry-datadog",
"opentelemetry-http",
"opentelemetry-jaeger",
Expand Down Expand Up @@ -4080,6 +4081,16 @@ dependencies = [
"opentelemetry_sdk",
]

[[package]]
name = "opentelemetry-aws"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72a394d24777936802edd6c03a68daab4db39630418c7e431a5648e9befa80b8"
dependencies = [
"once_cell",
"opentelemetry",
]

[[package]]
name = "opentelemetry-datadog"
version = "0.7.0"
Expand Down
1 change: 1 addition & 0 deletions apollo-router/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ once_cell = "1.18.0"
# there (and on `tracing` packages below) should be updated should this change.
opentelemetry = { version = "0.19.0", features = ["rt-tokio", "metrics"] }
opentelemetry_api = "0.19.0"
opentelemetry-aws = "0.7.0"
opentelemetry-datadog = { version = "0.7.0", features = ["reqwest-client"] }
opentelemetry-http = "0.8.0"
opentelemetry-jaeger = { version = "0.18.0", features = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4993,6 +4993,11 @@ expression: "&schema"
"description": "Propagation configuration",
"type": "object",
"properties": {
"awsxray": {
"description": "Propagate AWS X-Ray",
"default": false,
"type": "boolean"
},
"baggage": {
"description": "Propagate baggage https://www.w3.org/TR/baggage/",
"default": false,
Expand Down
2 changes: 2 additions & 0 deletions apollo-router/src/plugins/telemetry/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,8 @@ pub(crate) struct Propagation {
pub(crate) datadog: bool,
/// Propagate Zipkin
pub(crate) zipkin: bool,
/// Propagate AWS X-Ray
pub(crate) awsxray: bool,
}

#[derive(Clone, Debug, Deserialize, JsonSchema, Default)]
Expand Down
3 changes: 3 additions & 0 deletions apollo-router/src/plugins/telemetry/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,9 @@ impl Telemetry {
if propagation.datadog || tracing.datadog.is_some() {
propagators.push(Box::<opentelemetry_datadog::DatadogPropagator>::default());
}
if propagation.awsxray {
propagators.push(Box::<opentelemetry_aws::XrayPropagator>::default());
}
if let Some(from_request_header) = &propagation.request.header_name {
propagators.push(Box::new(CustomTraceIdPropagator::new(
from_request_header.to_string(),
Expand Down
3 changes: 3 additions & 0 deletions docs/source/configuration/tracing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ telemetry:
# https://zipkin.io/ (compliant with opentracing)
zipkin: false
# https://aws.amazon.com/xray/ (compliant with opentracing)
awsxray: false
# If you have your own way to generate a trace id and you want to pass it via a custom request header
request:
header_name: my-trace-id
Expand Down

0 comments on commit 1d17cac

Please sign in to comment.