@@ -86,7 +86,7 @@ def error_middleware(next, root, info, **args):
8686
8787
8888@dt_enabled
89- def test_basic (app , graphql_run ):
89+ def test_basic (app , graphql_run , is_graphql_2 ):
9090 from graphql import __version__ as version
9191
9292 FRAMEWORK_METRICS = [
@@ -114,6 +114,7 @@ def test_basic(app, graphql_run):
114114 "graphql.field.name" : "storage_add" ,
115115 "graphql.field.parentType" : "Mutation" ,
116116 "graphql.field.path" : "storage_add" ,
117+ "graphql.field.returnType" : "[String]" if is_graphql_2 else "String" ,
117118 }
118119 _expected_query_operation_attributes = {
119120 "graphql.operation.type" : "query" ,
@@ -123,6 +124,7 @@ def test_basic(app, graphql_run):
123124 "graphql.field.name" : "storage" ,
124125 "graphql.field.parentType" : "Query" ,
125126 "graphql.field.path" : "storage" ,
127+ "graphql.field.returnType" : "[String]" ,
126128 }
127129
128130 @validate_transaction_metrics (
@@ -189,14 +191,15 @@ def test_exception_in_middleware(app, graphql_run):
189191 _test_exception_rollup_metrics = [
190192 ("Errors/all" , 1 ),
191193 ("Errors/allOther" , 1 ),
192- ("Errors/OtherTransaction/GraphQL/query/MyQuery/%s" % field , 1 ),
194+ ("Errors/OtherTransaction/GraphQL/test_application:error_middleware" , 1 ),
193195 ] + _test_exception_scoped_metrics
194196
195197 # Attributes
196198 _expected_exception_resolver_attributes = {
197199 "graphql.field.name" : field ,
198200 "graphql.field.parentType" : "Query" ,
199201 "graphql.field.path" : field ,
202+ "graphql.field.returnType" : "String" ,
200203 }
201204 _expected_exception_operation_attributes = {
202205 "graphql.operation.type" : "query" ,
@@ -205,7 +208,7 @@ def test_exception_in_middleware(app, graphql_run):
205208 }
206209
207210 @validate_transaction_metrics (
208- "query/MyQuery/hello " ,
211+ "test_application:error_middleware " ,
209212 "GraphQL" ,
210213 scoped_metrics = _test_exception_scoped_metrics ,
211214 rollup_metrics = _test_exception_rollup_metrics + _graphql_base_rollup_metrics ,
@@ -224,13 +227,10 @@ def _test():
224227
225228@pytest .mark .parametrize ("field" , ("error" , "error_non_null" ))
226229@dt_enabled
227- def test_exception_in_resolver (app , graphql_run , is_graphql_2 , field ):
230+ def test_exception_in_resolver (app , graphql_run , field ):
228231 query = "query MyQuery { %s }" % field
229232
230- if is_graphql_2 and field == "error_non_null" :
231- txn_name = "_target_application:resolve_error"
232- else :
233- txn_name = "query/MyQuery/%s" % field
233+ txn_name = "_target_application:resolve_error"
234234
235235 # Metrics
236236 _test_exception_scoped_metrics = [
@@ -248,6 +248,7 @@ def test_exception_in_resolver(app, graphql_run, is_graphql_2, field):
248248 "graphql.field.name" : field ,
249249 "graphql.field.parentType" : "Query" ,
250250 "graphql.field.path" : field ,
251+ "graphql.field.returnType" : "String!" if "non_null" in field else "String" ,
251252 }
252253 _expected_exception_operation_attributes = {
253254 "graphql.operation.type" : "query" ,
@@ -366,6 +367,7 @@ def test_field_resolver_metrics_and_attrs(app, graphql_run):
366367 "graphql.field.name" : "hello" ,
367368 "graphql.field.parentType" : "Query" ,
368369 "graphql.field.path" : "hello" ,
370+ "graphql.field.returnType" : "String" ,
369371 }
370372
371373 @validate_transaction_metrics (
@@ -462,8 +464,13 @@ def _test():
462464@dt_enabled
463465@pytest .mark .parametrize ("query,expected_path" , _test_queries )
464466def test_deepest_unique_path (app , graphql_run , query , expected_path ):
467+ if expected_path == "/error" :
468+ txn_name = "_target_application:resolve_error"
469+ else :
470+ txn_name = "query/<anonymous>%s" % expected_path
471+
465472 @validate_transaction_metrics (
466- "query/<anonymous>%s" % expected_path ,
473+ txn_name ,
467474 "GraphQL" ,
468475 background_task = True ,
469476 )
0 commit comments