From 83c12ad4839d9987de2757cd9cad950a72b4d5d0 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sun, 12 Dec 2021 21:35:33 +0100 Subject: [PATCH] flows: fix description for spans Signed-off-by: Jens Langhammer --- authentik/flows/planner.py | 5 +++-- authentik/flows/views/executor.py | 14 +++++++++++--- authentik/policies/engine.py | 3 ++- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/authentik/flows/planner.py b/authentik/flows/planner.py index df8342e54..5d3fdbd9f 100644 --- a/authentik/flows/planner.py +++ b/authentik/flows/planner.py @@ -126,7 +126,7 @@ class FlowPlanner: ) -> FlowPlan: """Check each of the flows' policies, check policies for each stage with PolicyBinding and return ordered list""" - with Hub.current.start_span(op="flow.planner.plan") as span: + with Hub.current.start_span(op="flow.planner.plan", description=self.flow.slug) as span: span: Span span.set_data("flow", self.flow) span.set_data("request", request) @@ -181,7 +181,8 @@ class FlowPlanner: """Build flow plan by checking each stage in their respective order and checking the applied policies""" with Hub.current.start_span( - op="flow.planner.build_plan" + op="flow.planner.build_plan", + description=self.flow.slug, ) as span, HIST_FLOWS_PLAN_TIME.labels(flow_slug=self.flow.slug).time(): span: Span span.set_data("flow", self.flow) diff --git a/authentik/flows/views/executor.py b/authentik/flows/views/executor.py index 229c6a72f..6d017e332 100644 --- a/authentik/flows/views/executor.py +++ b/authentik/flows/views/executor.py @@ -159,7 +159,9 @@ 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: + with Hub.current.start_span( + op="flow.executor.dispatch", description=self.flow.slug + ) as span: span.set_data("authentik Flow", self.flow.slug) get_params = QueryDict(request.GET.get("query", "")) if QS_KEY_TOKEN in get_params: @@ -272,7 +274,10 @@ class FlowExecutorView(APIView): stage=self.current_stage, ) try: - with Hub.current.start_span(op="flow.executor.stage") as span: + with Hub.current.start_span( + op="flow.executor.stage", + description=class_to_path(self.current_stage_view.__class__), + ) as span: span.set_data("Method", "GET") span.set_data("authentik Stage", self.current_stage_view) span.set_data("authentik Flow", self.flow.slug) @@ -313,7 +318,10 @@ class FlowExecutorView(APIView): stage=self.current_stage, ) try: - with Hub.current.start_span(op="flow.executor.stage") as span: + with Hub.current.start_span( + op="flow.executor.stage", + description=class_to_path(self.current_stage_view.__class__), + ) as span: span.set_data("Method", "POST") span.set_data("authentik Stage", self.current_stage_view) span.set_data("authentik Flow", self.flow.slug) diff --git a/authentik/policies/engine.py b/authentik/policies/engine.py index 2f6f00caf..74dabe513 100644 --- a/authentik/policies/engine.py +++ b/authentik/policies/engine.py @@ -90,7 +90,8 @@ class PolicyEngine: def build(self) -> "PolicyEngine": """Build wrapper which monitors performance""" with Hub.current.start_span( - op="policy.engine.build" + op="policy.engine.build", + description=self.__pbm, ) as span, HIST_POLICIES_BUILD_TIME.labels( object_name=self.__pbm, object_type=f"{self.__pbm._meta.app_label}.{self.__pbm._meta.model_name}",