*: fix deprecated calls to sentry start_span (#11655)

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
Jens L.
2024-10-11 13:35:24 +02:00
committed by GitHub
parent 7fe3b7f353
commit d636002f4d
9 changed files with 16 additions and 16 deletions

View File

@ -50,7 +50,7 @@ class ASNContextProcessor(MMDBContextProcessor):
"""Wrapper for Reader.asn"""
with start_span(
op="authentik.events.asn.asn",
description=ip_address,
name=ip_address,
):
if not self.configured():
return None

View File

@ -51,7 +51,7 @@ class GeoIPContextProcessor(MMDBContextProcessor):
"""Wrapper for Reader.city"""
with start_span(
op="authentik.events.geo.city",
description=ip_address,
name=ip_address,
):
if not self.configured():
return None

View File

@ -166,7 +166,7 @@ class FlowPlanner:
def plan(self, request: HttpRequest, default_context: dict[str, Any] | None = None) -> FlowPlan:
"""Check each of the flows' policies, check policies for each stage with PolicyBinding
and return ordered list"""
with start_span(op="authentik.flow.planner.plan", description=self.flow.slug) as span:
with start_span(op="authentik.flow.planner.plan", name=self.flow.slug) as span:
span: Span
span.set_data("flow", self.flow)
span.set_data("request", request)
@ -233,7 +233,7 @@ class FlowPlanner:
with (
start_span(
op="authentik.flow.planner.build_plan",
description=self.flow.slug,
name=self.flow.slug,
) as span,
HIST_FLOWS_PLAN_TIME.labels(flow_slug=self.flow.slug).time(),
):

View File

@ -125,7 +125,7 @@ class ChallengeStageView(StageView):
with (
start_span(
op="authentik.flow.stage.challenge_invalid",
description=self.__class__.__name__,
name=self.__class__.__name__,
),
HIST_FLOWS_STAGE_TIME.labels(
stage_type=self.__class__.__name__, method="challenge_invalid"
@ -135,7 +135,7 @@ class ChallengeStageView(StageView):
with (
start_span(
op="authentik.flow.stage.challenge_valid",
description=self.__class__.__name__,
name=self.__class__.__name__,
),
HIST_FLOWS_STAGE_TIME.labels(
stage_type=self.__class__.__name__, method="challenge_valid"
@ -161,7 +161,7 @@ class ChallengeStageView(StageView):
with (
start_span(
op="authentik.flow.stage.get_challenge",
description=self.__class__.__name__,
name=self.__class__.__name__,
),
HIST_FLOWS_STAGE_TIME.labels(
stage_type=self.__class__.__name__, method="get_challenge"
@ -174,7 +174,7 @@ class ChallengeStageView(StageView):
return self.executor.stage_invalid()
with start_span(
op="authentik.flow.stage._get_challenge",
description=self.__class__.__name__,
name=self.__class__.__name__,
):
if not hasattr(challenge, "initial_data"):
challenge.initial_data = {}

View File

@ -153,7 +153,7 @@ class FlowExecutorView(APIView):
return plan
def dispatch(self, request: HttpRequest, flow_slug: str) -> HttpResponse:
with start_span(op="authentik.flow.executor.dispatch", description=self.flow.slug) as span:
with start_span(op="authentik.flow.executor.dispatch", name=self.flow.slug) as span:
span.set_data("authentik Flow", self.flow.slug)
get_params = QueryDict(request.GET.get(QS_QUERY, ""))
if QS_KEY_TOKEN in get_params:
@ -273,7 +273,7 @@ class FlowExecutorView(APIView):
with (
start_span(
op="authentik.flow.executor.stage",
description=class_path,
name=class_path,
) as span,
HIST_FLOW_EXECUTION_STAGE_TIME.labels(
method=request.method.upper(),
@ -324,7 +324,7 @@ class FlowExecutorView(APIView):
with (
start_span(
op="authentik.flow.executor.stage",
description=class_path,
name=class_path,
) as span,
HIST_FLOW_EXECUTION_STAGE_TIME.labels(
method=request.method.upper(),

View File

@ -113,7 +113,7 @@ class PolicyEngine:
with (
start_span(
op="authentik.policy.engine.build",
description=self.__pbm,
name=self.__pbm,
) as span,
HIST_POLICIES_ENGINE_TOTAL_TIME.labels(
obj_type=class_to_path(self.__pbm.__class__),

View File

@ -22,7 +22,7 @@ def create_admin_group(user: User) -> Group:
return group
def create_recovery_token(user: User, expiry: datetime, generated_from: str) -> (Token, str):
def create_recovery_token(user: User, expiry: datetime, generated_from: str) -> tuple[Token, str]:
"""Create recovery token and associated link"""
_now = now()
token = Token.objects.create(

View File

@ -104,7 +104,7 @@ class IdentificationChallengeResponse(ChallengeResponse):
if not pre_user:
with start_span(
op="authentik.stages.identification.validate_invalid_wait",
description="Sleep random time on invalid user identifier",
name="Sleep random time on invalid user identifier",
):
# Sleep a random time (between 90 and 210ms) to "prevent" user enumeration attacks
sleep(0.030 * SystemRandom().randint(3, 7))
@ -146,7 +146,7 @@ class IdentificationChallengeResponse(ChallengeResponse):
try:
with start_span(
op="authentik.stages.identification.authenticate",
description="User authenticate call (combo stage)",
name="User authenticate call (combo stage)",
):
user = authenticate(
self.stage.request,

View File

@ -49,7 +49,7 @@ def authenticate(
LOGGER.debug("Attempting authentication...", backend=backend_path)
with start_span(
op="authentik.stages.password.authenticate",
description=backend_path,
name=backend_path,
):
user = backend.authenticate(request, **credentials)
if user is None: