Skip to content

Commit 41b0e0b

Browse files
fix(graphql): rename service entry span (#4053) (#4055)
The graphql top level span is currently named `graphql.query`. This span wraps the execution of the `graphql.graphql()`. The current span name can be misleading since `graphql.graphql()` can execute graphql queries, graphql mutations or graphql subscriptions. This fix proposes setting the span name to `graphql.request` instead. An alternative fix would be to set the span name to `graphql.query`, `graphql.mutation` or `graphql.subscription` depending on the operation name. However getting the operation name would require parsing the query and this can be expensive. Co-authored-by: Munir Abdinur <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent fa358f8 commit 41b0e0b

5 files changed

+5
-5
lines changed

ddtrace/contrib/graphql/patch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def _traced_query(func, args, kwargs):
182182
resource = _get_source_str(source)
183183

184184
with pin.tracer.trace(
185-
name="graphql.query",
185+
name="graphql.request",
186186
resource=resource,
187187
service=trace_utils.int_service(pin, config.graphql),
188188
span_type=SpanTypes.GRAPHQL,

tests/snapshots/tests.contrib.graphql.test_graphql.test_graphql.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[[
22
{
3-
"name": "graphql.query",
3+
"name": "graphql.request",
44
"service": "graphql",
55
"resource": "query HELLO { hello }",
66
"trace_id": 0,

tests/snapshots/tests.contrib.graphql.test_graphql.test_graphql_error.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[[
22
{
3-
"name": "graphql.query",
3+
"name": "graphql.request",
44
"service": "graphql",
55
"resource": "{ invalid_schema }",
66
"trace_id": 0,

tests/snapshots/tests.contrib.graphql.test_graphql.test_graphql_v2_with_document.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
}],
2525
[
2626
{
27-
"name": "graphql.query",
27+
"name": "graphql.request",
2828
"service": "graphql",
2929
"resource": "query HELLO { hello }",
3030
"trace_id": 1,

tests/snapshots/tests.contrib.graphql.test_graphql.test_graphql_with_traced_resolver.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[[
22
{
3-
"name": "graphql.query",
3+
"name": "graphql.request",
44
"service": "graphql",
55
"resource": "query HELLO { hello }",
66
"trace_id": 0,

0 commit comments

Comments
 (0)