Skip to content

Commit b192079

Browse files
authored
skip tracing when noop tracer (#43)
1 parent 497daa3 commit b192079

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

graphene_tornado/ext/opencensus/opencensus_tracing_extension.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
from __future__ import absolute_import
2-
31
import json
42

53
from opencensus.trace import execution_context
6-
from tornado.gen import Return, coroutine
4+
from opencensus.trace.tracers.noop_tracer import NoopTracer
75

86
from graphene_tornado.apollo_tooling.query_hash import compute
97
from graphene_tornado.ext.extension_helpers import get_signature
108
from graphene_tornado.extension_stack import GraphQLExtension
119
from graphene_tornado.request_context import SIGNATURE_HASH_KEY
1210

1311

12+
async def _pass(*args):
13+
pass
14+
15+
1416
class OpenCensusExtension(GraphQLExtension):
1517

1618
def __init__(self):
@@ -23,6 +25,9 @@ async def request_started(self, request, query_string, parsed_query, operation_n
2325
self.document = parsed_query
2426

2527
tracer = execution_context.get_opencensus_tracer()
28+
if isinstance(tracer, NoopTracer):
29+
return _pass
30+
2631
tracer.start_span('gql')
2732

2833
async def on_request_ended(errors):

0 commit comments

Comments
 (0)