Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Renamed operation name for graphql to avoid conflict with SQL

Mikail KOCAK392dd76f4299
diff --git a/saleor/graphql/middleware.py b/saleor/graphql/middleware.py
index f08f509d71..f25f546c3b 100644
--- a/saleor/graphql/middleware.py
+++ b/saleor/graphql/middleware.py
@@ -47,9 +47,10 @@ def should_trace(info):
class OpentracingGrapheneMiddleware:
@staticmethod
def resolve(next, root, info, **kwargs):
- with ot.global_tracer().start_active_span(
- operation_name=info.operation.operation
- ) as scope:
+ operation = (
+ f"{info.operation.operation}.{info.parent_type.name}.{info.field_name}"
+ )
+ with ot.global_tracer().start_active_span(operation_name=operation) as scope:
span = scope.span
span.set_tag(ot_tags.COMPONENT, "graphql")
span.set_tag("graphql.parent_type", info.parent_type.name)
diff --git a/saleor/graphql/views.py b/saleor/graphql/views.py
index 15e2889911..6e4c38aba1 100644
--- a/saleor/graphql/views.py
+++ b/saleor/graphql/views.py
@@ -7,6 +7,7 @@ import opentracing as ot
import opentracing.tags as ot_tags
from django.conf import settings
from django.db import connection
+from django.db.backends.postgresql.base import DatabaseWrapper
from django.http import HttpRequest, HttpResponseNotAllowed, JsonResponse
from django.shortcuts import render_to_response
from django.urls import reverse
@@ -30,10 +31,13 @@ handled_errors_logger = logging.getLogger("saleor.graphql.errors.handled")
def tracing_wrapper(execute, sql, params, many, context):
- with ot.global_tracer().start_active_span(operation_name="query") as scope:
+ conn: DatabaseWrapper = context["connection"]
+ operation = f"{conn.alias} {conn.display_name}"
+ with ot.global_tracer().start_active_span(operation_name=operation) as scope:
span = scope.span
span.set_tag(ot_tags.COMPONENT, "db")
span.set_tag(ot_tags.DATABASE_STATEMENT, sql)
+ span.set_tag(ot_tags.DATABASE_TYPE, conn.display_name)
return execute(sql, params, many, context)