Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Remove condition of opentracing enabled
Tomasz Szymańskib56c316ce644
diff --git a/saleor/graphql/middleware.py b/saleor/graphql/middleware.pyindex f1f7ee782f..67fcd27799 100644--- a/saleor/graphql/middleware.py+++ b/saleor/graphql/middleware.py@@ -46,16 +46,13 @@ def should_trace(info):class OpentracingGrapheneMiddleware:@staticmethoddef resolve(next, root, info, **kwargs):- if settings.ENABLE_OPENTRACING and should_trace(info):- with opentracing.global_tracer().start_span(- operation_name=info.operation.operation- ) as span:- span.set_tag("component", "graphql")- span.set_tag("graphql.parent_type", info.parent_type.name)- span.set_tag("graphql.field_name", info.field_name)- return next(root, info, **kwargs)-- return next(root, info, **kwargs)+ with opentracing.global_tracer().start_span(+ operation_name=info.operation.operation+ ) as span:+ span.set_tag("component", "graphql")+ span.set_tag("graphql.parent_type", info.parent_type.name)+ span.set_tag("graphql.field_name", info.field_name)+ return next(root, info, **kwargs)def get_service_account(auth_token) -> Optional[ServiceAccount]:diff --git a/saleor/graphql/views.py b/saleor/graphql/views.pyindex 2e264116ad..5a7d71b5f5 100644--- a/saleor/graphql/views.py+++ b/saleor/graphql/views.py@@ -29,9 +29,6 @@ handled_errors_logger = logging.getLogger("saleor.graphql.errors.handled")def tracing_wrapper(execute, sql, params, many, context):- if not settings.ENABLE_OPENTRACING:- return execute(sql, params, many, context)-with opentracing.global_tracer().start_span(operation_name="query") as span:span.set_tag("component", "db")span.set_tag("db.statement", sql)@@ -124,17 +121,13 @@ class GraphQLView(View):def get_response(self, request: HttpRequest, data: dict) -> Tuple[Optional[Dict[str, List[Any]]], int]:- if settings.ENABLE_OPENTRACING:- with opentracing.global_tracer().start_span(- operation_name="request"- ) as span:- span.set_tag("component", "http")- span.set_tag("http.method", request.method)- span.set_tag("http.path", request.path)- result, status_code = self._get_response(request, data)- span.set_tag("http.status_code", status_code)- return result, status_code- return self._get_response(request, data)+ with opentracing.global_tracer().start_span(operation_name="request") as span:+ span.set_tag("component", "http")+ span.set_tag("http.method", request.method)+ span.set_tag("http.path", request.path)+ result, status_code = self._get_response(request, data)+ span.set_tag("http.status_code", status_code)+ return result, status_codedef _get_response(self, request: HttpRequest, data: dictdiff --git a/saleor/settings.py b/saleor/settings.pyindex 540c68232a..15c47e4d2b 100644--- a/saleor/settings.py+++ b/saleor/settings.py@@ -558,6 +558,3 @@ if ("Make sure you've added storefront address to ALLOWED_CLIENT_HOSTS ""if ENABLE_ACCOUNT_CONFIRMATION_BY_EMAIL is enabled.")---ENABLE_OPENTRACING = get_bool_from_env("ENABLE_OPENTRACING", False)