Skip to content

Commit

Permalink
Added tests for and fixed override of span names
Browse files Browse the repository at this point in the history
  • Loading branch information
bryn committed Jul 2, 2024
1 parent 15ff38f commit fcc2d7a
Show file tree
Hide file tree
Showing 6 changed files with 271 additions and 129 deletions.
4 changes: 3 additions & 1 deletion apollo-router/src/plugins/telemetry/dynamic_attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,9 @@ impl SpanDynAttribute for ::tracing::Span {

fn update_otel_data(otel_data: &mut OtelData, key: &Key, value: &opentelemetry::Value) {
match key.as_str() {
OTEL_NAME => otel_data.forced_span_name = Some(value.to_string()),
OTEL_NAME if otel_data.forced_span_name.is_none() => {
otel_data.forced_span_name = Some(value.to_string())
}
OTEL_KIND => otel_data.builder.span_kind = str_to_span_kind(&value.as_str()),
OTEL_STATUS_CODE => otel_data.forced_status = str_to_status(&value.as_str()).into(),
OTEL_STATUS_MESSAGE => {
Expand Down
3 changes: 3 additions & 0 deletions apollo-router/src/plugins/telemetry/span_factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ impl SpanMode {
"http.route" = %request.uri(),
"http.flavor" = ?request.version(),
"http.status" = 500, // This prevents setting later
"otel.name" = ::tracing::field::Empty,
"otel.kind" = "SERVER",
"graphql.operation.name" = ::tracing::field::Empty,
"graphql.operation.type" = ::tracing::field::Empty,
Expand All @@ -58,6 +59,7 @@ impl SpanMode {
"http.request.method" = %request.method(),
"http.route" = %request.uri(),
"http.flavor" = ?request.version(),
"otel.name" = ::tracing::field::Empty,
"otel.kind" = "SERVER",
"graphql.operation.name" = ::tracing::field::Empty,
"graphql.operation.type" = ::tracing::field::Empty,
Expand Down Expand Up @@ -98,6 +100,7 @@ impl SpanMode {
// Needed for apollo_telemetry and datadog span mapping
"http.route" = %request.uri(),
"http.request.method" = %request.method(),
"otel.name" = ::tracing::field::Empty,
"otel.kind" = "SERVER",
"otel.status_code" = ::tracing::field::Empty,
"apollo_router.license" = ::tracing::field::Empty,
Expand Down
Loading

0 comments on commit fcc2d7a

Please sign in to comment.