Skip to content

Commit 8e6fb0d

Browse files
committed
add noqa
1 parent d22af7f commit 8e6fb0d

3 files changed

+178
-71
lines changed

tests/contrib/graphene/test_graphene.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def resolve_patron(root, info):
3232
class Query(graphene.ObjectType):
3333
user = graphene.String(id=graphene.ID())
3434

35-
def resolve_user(self, info, id):
35+
def resolve_user(self, info, id): # noqa: A002
3636
if id != "123":
3737
raise graphql.error.GraphQLError(
3838
"User not found",
@@ -114,7 +114,7 @@ async def test_schema_execute_async_with_resolvers(test_schema, test_source_str,
114114
assert result.data == {"patron": {"id": "1", "name": "Syrus", "age": 27}}
115115

116116

117-
@pytest.mark.snapshot
117+
@pytest.mark.snapshot(ignores=["meta.events", "meta.error.stack"])
118118
def test_schema_failing_extensions(test_schema, test_source_str, enable_graphql_resolvers):
119119
schema = graphene.Schema(query=Query)
120120
os.environ["DD_TRACE_GRAPHQL_ERROR_EXTENSIONS"] = "code, status"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
[[
2+
{
3+
"name": "graphql.request",
4+
"service": "graphql",
5+
"resource": "{ user(id: \"999\") }",
6+
"trace_id": 0,
7+
"span_id": 1,
8+
"parent_id": 0,
9+
"type": "graphql",
10+
"error": 1,
11+
"meta": {
12+
"_dd.base_service": "tests.contrib.graphene",
13+
"_dd.p.dm": "-0",
14+
"_dd.p.tid": "67a1663a00000000",
15+
"component": "graphql",
16+
"error.message": "User not found\n\nGraphQL request:1:3\n1 | { user(id: \"999\") }\n | ^",
17+
"error.stack": "Traceback (most recent call last):\n File \"/Users/quinna.halim/dd-trace-py/.riot/venv_py3130_mock_pytest_pytest-mock_coverage_pytest-cov_opentracing_hypothesis6451_graphene~300_pytest-asyncio0211_graphql-relay_pytest-randomly/lib/python3.13/site-packages/graphql/execution/execute.py\", line 617, in resolve_field\n result = resolve_fn(source, info, **args)\n File \"/Users/quinna.halim/dd-trace-py/ddtrace/contrib/internal/graphql/patch.py\", line 242, in _resolver_middleware\n return next_middleware(root, info, **args)\n File \"/Users/quinna.halim/dd-trace-py/tests/contrib/graphene/test_graphene.py\", line 37, in resolve_user\n raise graphql.error.GraphQLError(\n ...<7 lines>...\n )\ngraphql.error.graphql_error.GraphQLError: User not found\n\nGraphQL request:1:3\n1 | { user(id: \"999\") }\n | ^\n",
18+
"error.type": "graphql.error.graphql_error.GraphQLError",
19+
"events": "[{\"name\": \"dd.graphql.query.error\", \"time_unix_nano\": 1738630714389656000, \"attributes\": {\"message\": \"User not found\", \"type\": \"graphql.error.graphql_error.GraphQLError\", \"locations\": \"1:3\", \"stacktrace\": \"Traceback (most recent call last):\\n File \\\"/Users/quinna.halim/dd-trace-py/.riot/venv_py3130_mock_pytest_pytest-mock_coverage_pytest-cov_opentracing_hypothesis6451_graphene~300_pytest-asyncio0211_graphql-relay_pytest-randomly/lib/python3.13/site-packages/graphql/execution/execute.py\\\", line 617, in resolve_field\\n result = resolve_fn(source, info, **args)\\n File \\\"/Users/quinna.halim/dd-trace-py/ddtrace/contrib/internal/graphql/patch.py\\\", line 242, in _resolver_middleware\\n return next_middleware(root, info, **args)\\n File \\\"/Users/quinna.halim/dd-trace-py/tests/contrib/graphene/test_graphene.py\\\", line 37, in resolve_user\\n raise graphql.error.GraphQLError(\\n ...<7 lines>...\\n )\\ngraphql.error.graphql_error.GraphQLError: User not found\\n\\nGraphQL request:1:3\\n1 | { user(id: \\\"999\\\") }\\n | ^\\n\", \"path\": \"user\", \"code\": \"USER_NOT_FOUND\", \"extensions\": \"{'code': 'USER_NOT_FOUND', 'status': 404}\"}}]",
20+
"language": "python",
21+
"runtime-id": "eee5cdadb35249afb9f5d6e1c304be24"
22+
},
23+
"metrics": {
24+
"_dd.measured": 1,
25+
"_dd.top_level": 1,
26+
"_dd.tracer_kr": 1.0,
27+
"_sampling_priority_v1": 1,
28+
"process_id": 43930
29+
},
30+
"duration": 3813000,
31+
"start": 1738630714385845000
32+
},
33+
{
34+
"name": "graphql.parse",
35+
"service": "graphql",
36+
"resource": "graphql.parse",
37+
"trace_id": 0,
38+
"span_id": 2,
39+
"parent_id": 1,
40+
"type": "graphql",
41+
"error": 0,
42+
"meta": {
43+
"_dd.base_service": "tests.contrib.graphene",
44+
"component": "graphql",
45+
"graphql.source": "{ user(id: \"999\") }"
46+
},
47+
"duration": 180000,
48+
"start": 1738630714386234000
49+
},
50+
{
51+
"name": "graphql.validate",
52+
"service": "graphql",
53+
"resource": "graphql.validate",
54+
"trace_id": 0,
55+
"span_id": 3,
56+
"parent_id": 1,
57+
"type": "graphql",
58+
"error": 0,
59+
"meta": {
60+
"_dd.base_service": "tests.contrib.graphene",
61+
"component": "graphql",
62+
"graphql.source": "{ user(id: \"999\") }"
63+
},
64+
"duration": 888000,
65+
"start": 1738630714386488000
66+
},
67+
{
68+
"name": "graphql.execute",
69+
"service": "graphql",
70+
"resource": "{ user(id: \"999\") }",
71+
"trace_id": 0,
72+
"span_id": 4,
73+
"parent_id": 1,
74+
"type": "graphql",
75+
"error": 1,
76+
"meta": {
77+
"_dd.base_service": "tests.contrib.graphene",
78+
"component": "graphql",
79+
"error.message": "User not found\n\nGraphQL request:1:3\n1 | { user(id: \"999\") }\n | ^",
80+
"error.stack": "Traceback (most recent call last):\n File \"/Users/quinna.halim/dd-trace-py/.riot/venv_py3130_mock_pytest_pytest-mock_coverage_pytest-cov_opentracing_hypothesis6451_graphene~300_pytest-asyncio0211_graphql-relay_pytest-randomly/lib/python3.13/site-packages/graphql/execution/execute.py\", line 617, in resolve_field\n result = resolve_fn(source, info, **args)\n File \"/Users/quinna.halim/dd-trace-py/ddtrace/contrib/internal/graphql/patch.py\", line 242, in _resolver_middleware\n return next_middleware(root, info, **args)\n File \"/Users/quinna.halim/dd-trace-py/tests/contrib/graphene/test_graphene.py\", line 37, in resolve_user\n raise graphql.error.GraphQLError(\n ...<7 lines>...\n )\ngraphql.error.graphql_error.GraphQLError: User not found\n\nGraphQL request:1:3\n1 | { user(id: \"999\") }\n | ^\n",
81+
"error.type": "graphql.error.graphql_error.GraphQLError",
82+
"events": "[{\"name\": \"dd.graphql.query.error\", \"time_unix_nano\": 1738630714389350000, \"attributes\": {\"message\": \"User not found\", \"type\": \"graphql.error.graphql_error.GraphQLError\", \"locations\": \"1:3\", \"stacktrace\": \"Traceback (most recent call last):\\n File \\\"/Users/quinna.halim/dd-trace-py/.riot/venv_py3130_mock_pytest_pytest-mock_coverage_pytest-cov_opentracing_hypothesis6451_graphene~300_pytest-asyncio0211_graphql-relay_pytest-randomly/lib/python3.13/site-packages/graphql/execution/execute.py\\\", line 617, in resolve_field\\n result = resolve_fn(source, info, **args)\\n File \\\"/Users/quinna.halim/dd-trace-py/ddtrace/contrib/internal/graphql/patch.py\\\", line 242, in _resolver_middleware\\n return next_middleware(root, info, **args)\\n File \\\"/Users/quinna.halim/dd-trace-py/tests/contrib/graphene/test_graphene.py\\\", line 37, in resolve_user\\n raise graphql.error.GraphQLError(\\n ...<7 lines>...\\n )\\ngraphql.error.graphql_error.GraphQLError: User not found\\n\\nGraphQL request:1:3\\n1 | { user(id: \\\"999\\\") }\\n | ^\\n\", \"path\": \"user\", \"code\": \"USER_NOT_FOUND\", \"extensions\": \"{'code': 'USER_NOT_FOUND', 'status': 404}\"}}]",
83+
"graphql.operation.type": "query",
84+
"graphql.source": "{ user(id: \"999\") }"
85+
},
86+
"metrics": {
87+
"_dd.measured": 1
88+
},
89+
"duration": 1921000,
90+
"start": 1738630714387431000
91+
},
92+
{
93+
"name": "graphql.resolve",
94+
"service": "graphql",
95+
"resource": "user",
96+
"trace_id": 0,
97+
"span_id": 5,
98+
"parent_id": 4,
99+
"type": "graphql",
100+
"error": 1,
101+
"meta": {
102+
"_dd.base_service": "tests.contrib.graphene",
103+
"component": "graphql",
104+
"error.message": "User not found",
105+
"error.stack": "Traceback (most recent call last):\n File \"/Users/quinna.halim/dd-trace-py/ddtrace/contrib/internal/graphql/patch.py\", line 242, in _resolver_middleware\n return next_middleware(root, info, **args)\n File \"/Users/quinna.halim/dd-trace-py/tests/contrib/graphene/test_graphene.py\", line 37, in resolve_user\n raise graphql.error.GraphQLError(\n ...<7 lines>...\n )\ngraphql.error.graphql_error.GraphQLError: User not found\n",
106+
"error.type": "graphql.error.graphql_error.GraphQLError"
107+
},
108+
"duration": 1152000,
109+
"start": 1738630714387593000
110+
}]]
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,68 @@
1-
[
2-
[
3-
{
4-
"name": "graphql.request",
5-
"service": "graphql",
6-
"resource": "query my_query{ invalid_schema }",
7-
"trace_id": 0,
8-
"span_id": 1,
9-
"parent_id": 0,
10-
"type": "graphql",
11-
"error": 1,
12-
"meta": {
13-
"_dd.base_service": "tests.contrib.graphql",
14-
"_dd.p.dm": "-0",
15-
"_dd.p.tid": "679b96df00000000",
16-
"component": "graphql",
17-
"error.message": "Cannot query field 'invalid_schema' on type 'RootQueryType'.\n\nGraphQL request:1:17\n1 | query my_query{ invalid_schema }\n | ^",
18-
"error.type": "graphql.error.graphql_error.GraphQLError",
19-
"events": "[{\"name\": \"dd.graphql.query.error\", \"time_unix_nano\": 1738249951802662000, \"attributes\": {\"message\": \"Cannot query field 'invalid_schema' on type 'RootQueryType'.\", \"type\": \"graphql.error.graphql_error.GraphQLError\", \"locations\": \"1:17\"}}]",
20-
"language": "python",
21-
"runtime-id": "9a4c224e6fdd49cea07a7a3954fd5db7"
22-
},
23-
"metrics": {
24-
"_dd.measured": 1,
25-
"_dd.top_level": 1,
26-
"_dd.tracer_kr": 1.0,
27-
"_sampling_priority_v1": 1,
28-
"process_id": 26822
29-
},
30-
"duration": 1221000,
31-
"start": 1738249951801442000
1+
[[
2+
{
3+
"name": "graphql.request",
4+
"service": "graphql",
5+
"resource": "query my_query{ invalid_schema }",
6+
"trace_id": 0,
7+
"span_id": 1,
8+
"parent_id": 0,
9+
"type": "graphql",
10+
"error": 1,
11+
"meta": {
12+
"_dd.base_service": "tests.contrib.graphql",
13+
"_dd.p.dm": "-0",
14+
"_dd.p.tid": "679b96df00000000",
15+
"component": "graphql",
16+
"error.message": "Cannot query field 'invalid_schema' on type 'RootQueryType'.\n\nGraphQL request:1:17\n1 | query my_query{ invalid_schema }\n | ^",
17+
"error.type": "graphql.error.graphql_error.GraphQLError",
18+
"events": "[{\"name\": \"dd.graphql.query.error\", \"time_unix_nano\": 1738249951802662000, \"attributes\": {\"message\": \"Cannot query field 'invalid_schema' on type 'RootQueryType'.\", \"type\": \"graphql.error.graphql_error.GraphQLError\", \"locations\": \"1:17\"}}]",
19+
"language": "python",
20+
"runtime-id": "9a4c224e6fdd49cea07a7a3954fd5db7"
3221
},
33-
{
34-
"name": "graphql.parse",
35-
"service": "graphql",
36-
"resource": "graphql.parse",
37-
"trace_id": 0,
38-
"span_id": 2,
39-
"parent_id": 1,
40-
"type": "graphql",
41-
"error": 0,
42-
"meta": {
43-
"_dd.base_service": "tests.contrib.graphql",
44-
"component": "graphql",
45-
"graphql.source": "query my_query{ invalid_schema }"
46-
},
47-
"duration": 143000,
48-
"start": 1738249951801693000
22+
"metrics": {
23+
"_dd.measured": 1,
24+
"_dd.top_level": 1,
25+
"_dd.tracer_kr": 1.0,
26+
"_sampling_priority_v1": 1,
27+
"process_id": 26822
4928
},
50-
{
51-
"name": "graphql.validate",
52-
"service": "graphql",
53-
"resource": "graphql.validate",
54-
"trace_id": 0,
55-
"span_id": 3,
56-
"parent_id": 1,
57-
"type": "graphql",
58-
"error": 1,
59-
"meta": {
60-
"_dd.base_service": "tests.contrib.graphql",
61-
"component": "graphql",
62-
"error.message": "Cannot query field 'invalid_schema' on type 'RootQueryType'.\n\nGraphQL request:1:17\n1 | query my_query{ invalid_schema }\n | ^",
63-
"error.type": "graphql.error.graphql_error.GraphQLError",
64-
"events": "[{\"name\": \"dd.graphql.query.error\", \"time_unix_nano\": 1738249951802627000, \"attributes\": {\"message\": \"Cannot query field 'invalid_schema' on type 'RootQueryType'.\", \"type\": \"graphql.error.graphql_error.GraphQLError\", \"locations\": \"1:17\"}}]",
65-
"graphql.source": "query my_query{ invalid_schema }"
66-
},
67-
"duration": 745000,
68-
"start": 1738249951801884000
69-
}
70-
]
71-
]
29+
"duration": 1221000,
30+
"start": 1738249951801442000
31+
},
32+
{
33+
"name": "graphql.parse",
34+
"service": "graphql",
35+
"resource": "graphql.parse",
36+
"trace_id": 0,
37+
"span_id": 2,
38+
"parent_id": 1,
39+
"type": "graphql",
40+
"error": 0,
41+
"meta": {
42+
"_dd.base_service": "tests.contrib.graphql",
43+
"component": "graphql",
44+
"graphql.source": "query my_query{ invalid_schema }"
45+
},
46+
"duration": 143000,
47+
"start": 1738249951801693000
48+
},
49+
{
50+
"name": "graphql.validate",
51+
"service": "graphql",
52+
"resource": "graphql.validate",
53+
"trace_id": 0,
54+
"span_id": 3,
55+
"parent_id": 1,
56+
"type": "graphql",
57+
"error": 1,
58+
"meta": {
59+
"_dd.base_service": "tests.contrib.graphql",
60+
"component": "graphql",
61+
"error.message": "Cannot query field 'invalid_schema' on type 'RootQueryType'.\n\nGraphQL request:1:17\n1 | query my_query{ invalid_schema }\n | ^",
62+
"error.type": "graphql.error.graphql_error.GraphQLError",
63+
"events": "[{\"name\": \"dd.graphql.query.error\", \"time_unix_nano\": 1738249951802627000, \"attributes\": {\"message\": \"Cannot query field 'invalid_schema' on type 'RootQueryType'.\", \"type\": \"graphql.error.graphql_error.GraphQLError\", \"locations\": \"1:17\"}}]",
64+
"graphql.source": "query my_query{ invalid_schema }"
65+
},
66+
"duration": 745000,
67+
"start": 1738249951801884000
68+
}]]

0 commit comments

Comments
 (0)