8000 feat: add tracing-otel feature for descriptive otel span naming · async-graphql/async-graphql@f77e438 · GitHub
[go: up one dir, main page]

Skip to content

Commit f77e438

Browse files
committed
feat: add tracing-otel feature for descriptive otel span naming
1 parent 3001a02 commit f77e438

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ password-strength-validator = ["zxcvbn"]
2626
string_number = []
2727
tokio-sync = ["tokio"]
2828
tracing = ["tracinglib", "tracing-futures"]
29+
tracing-otel = []
2930
unblock = ["blocking"]
3031
dynamic-schema = []
3132
graphiql = ["handlebars"]

src/extensions/tracing.rs

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,25 @@ impl Extension for TracingExtension {
132132
next: NextResolve<'_>,
133133
) -> ServerResult<Option<Value>> {
134134
let span = if !info.is_for_introspection {
135-
Some(span!(
136-
target: "async_graphql::graphql",
137-
Level::INFO,
138-
"field",
139-
path = %info.path_node,
140-
parent_type = %info.parent_type,
141-
return_type = %info.return_type,
142-
))
135+
if cfg!(feature = "tracing-otel") {
136+
Some(span!(
137+
target: "async_graphql::graphql",
138+
Level::INFO,
139+
"field",
140+
otel.name = %info.path_node,
141+
parent_type = %info.parent_type,
142+
return_type = %info.return_type,
143+
))
144+
} else {
145+
Some(span!(
146+
target: "async_graphql::graphql",
147+
Level::INFO,
148+
"field",
149+
path = %info.path_node,
150+
parent_type = %info.parent_type,
151+
return_type = %info.return_type,
152+
))
153+
}
143154
} else {
144155
None
145156
};

0 commit comments

Comments
 (0)
0