flows: add additional sentry spans to flow executor
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
4e2457560d
commit
6efc7578ef
|
@ -19,6 +19,7 @@ from drf_spectacular.utils import OpenApiParameter, PolymorphicProxySerializer,
|
|||
from rest_framework.permissions import AllowAny
|
||||
from rest_framework.views import APIView
|
||||
from sentry_sdk import capture_exception
|
||||
from sentry_sdk.hub import Hub
|
||||
from structlog.stdlib import BoundLogger, get_logger
|
||||
|
||||
from authentik.core.models import USER_ATTRIBUTE_DEBUG
|
||||
|
@ -156,6 +157,8 @@ class FlowExecutorView(APIView):
|
|||
|
||||
# pylint: disable=unused-argument, too-many-return-statements
|
||||
def dispatch(self, request: HttpRequest, flow_slug: str) -> HttpResponse:
|
||||
with Hub.current.start_span(op="flow.executor.dispatch") as span:
|
||||
span.set_data("flow", self.flow.flow_uuid)
|
||||
get_params = QueryDict(request.GET.get("query", ""))
|
||||
if QS_KEY_TOKEN in get_params:
|
||||
plan = self._check_flow_token(get_params)
|
||||
|
@ -197,7 +200,9 @@ class FlowExecutorView(APIView):
|
|||
# in which case we just delete the plan and invalidate everything
|
||||
next_binding = self.plan.next(self.request)
|
||||
except Exception as exc: # pylint: disable=broad-except
|
||||
self._logger.warning("f(exec): found incompatible flow plan, invalidating run", exc=exc)
|
||||
self._logger.warning(
|
||||
"f(exec): found incompatible flow plan, invalidating run", exc=exc
|
||||
)
|
||||
cache.delete_pattern("flow_*")
|
||||
return self.stage_invalid()
|
||||
if not next_binding:
|
||||
|
@ -264,6 +269,10 @@ class FlowExecutorView(APIView):
|
|||
stage=self.current_stage,
|
||||
)
|
||||
try:
|
||||
with Hub.current.start_span(op="flow.executor.stage") as span:
|
||||
span.set_data("method", "get")
|
||||
span.set_data("stage", self.current_stage_view)
|
||||
span.set_data("flow", self.flow.flow_uuid)
|
||||
stage_response = self.current_stage_view.get(request, *args, **kwargs)
|
||||
return to_stage_response(request, stage_response)
|
||||
except Exception as exc: # pylint: disable=broad-except
|
||||
|
@ -301,6 +310,10 @@ class FlowExecutorView(APIView):
|
|||
stage=self.current_stage,
|
||||
)
|
||||
try:
|
||||
with Hub.current.start_span(op="flow.executor.stage") as span:
|
||||
span.set_data("method", "post")
|
||||
span.set_data("stage", self.current_stage_view)
|
||||
span.set_data("flow", self.flow.flow_uuid)
|
||||
stage_response = self.current_stage_view.post(request, *args, **kwargs)
|
||||
return to_stage_response(request, stage_response)
|
||||
except Exception as exc: # pylint: disable=broad-except
|
||||
|
|
Reference in a new issue