*: use direct sentry Hub for start_span
This commit is contained in:
parent
6ebefc9f17
commit
219e16f8e5
|
@ -36,15 +36,7 @@ logconfig_dict = {
|
||||||
"console": {"class": "logging.StreamHandler", "formatter": "json_formatter"},
|
"console": {"class": "logging.StreamHandler", "formatter": "json_formatter"},
|
||||||
},
|
},
|
||||||
"loggers": {
|
"loggers": {
|
||||||
"uvicorn": {
|
"uvicorn": {"handlers": ["console"], "level": "WARNING", "propagate": False},
|
||||||
"handlers": ["console"],
|
"gunicorn": {"handlers": ["console"], "level": "INFO", "propagate": False},
|
||||||
"level": "WARNING",
|
|
||||||
"propagate": False,
|
|
||||||
},
|
|
||||||
"gunicorn": {
|
|
||||||
"handlers": ["console"],
|
|
||||||
"level": "INFO",
|
|
||||||
"propagate": False,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ from typing import Any, Dict, List, Optional
|
||||||
|
|
||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
from django.http import HttpRequest
|
from django.http import HttpRequest
|
||||||
from sentry_sdk import start_span
|
from sentry_sdk.hub import Hub
|
||||||
from sentry_sdk.tracing import Span
|
from sentry_sdk.tracing import Span
|
||||||
from structlog import get_logger
|
from structlog import get_logger
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ class FlowPlanner:
|
||||||
) -> FlowPlan:
|
) -> FlowPlan:
|
||||||
"""Check each of the flows' policies, check policies for each stage with PolicyBinding
|
"""Check each of the flows' policies, check policies for each stage with PolicyBinding
|
||||||
and return ordered list"""
|
and return ordered list"""
|
||||||
with start_span(op="flow.planner.plan") as span:
|
with Hub.current.start_span(op="flow.planner.plan") as span:
|
||||||
span: Span
|
span: Span
|
||||||
span.set_data("flow", self.flow)
|
span.set_data("flow", self.flow)
|
||||||
span.set_data("request", request)
|
span.set_data("request", request)
|
||||||
|
@ -146,7 +146,7 @@ class FlowPlanner:
|
||||||
) -> FlowPlan:
|
) -> FlowPlan:
|
||||||
"""Build flow plan by checking each stage in their respective
|
"""Build flow plan by checking each stage in their respective
|
||||||
order and checking the applied policies"""
|
order and checking the applied policies"""
|
||||||
with start_span(op="flow.planner.build_plan") as span:
|
with Hub.current.start_span(op="flow.planner.build_plan") as span:
|
||||||
span: Span
|
span: Span
|
||||||
span.set_data("flow", self.flow)
|
span.set_data("flow", self.flow)
|
||||||
span.set_data("user", user)
|
span.set_data("user", user)
|
||||||
|
|
|
@ -5,7 +5,7 @@ from typing import Any, Dict, Iterable, Optional
|
||||||
|
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from requests import Session
|
from requests import Session
|
||||||
from sentry_sdk import start_span
|
from sentry_sdk.hub import Hub
|
||||||
from sentry_sdk.tracing import Span
|
from sentry_sdk.tracing import Span
|
||||||
from structlog import get_logger
|
from structlog import get_logger
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ class BaseEvaluator:
|
||||||
"""Parse and evaluate expression. If the syntax is incorrect, a SyntaxError is raised.
|
"""Parse and evaluate expression. If the syntax is incorrect, a SyntaxError is raised.
|
||||||
If any exception is raised during execution, it is raised.
|
If any exception is raised during execution, it is raised.
|
||||||
The result is returned without any type-checking."""
|
The result is returned without any type-checking."""
|
||||||
with start_span(op="lib.evaluator.evaluate") as span:
|
with Hub.current.start_span(op="lib.evaluator.evaluate") as span:
|
||||||
span: Span
|
span: Span
|
||||||
span.set_data("expression", expression_source)
|
span.set_data("expression", expression_source)
|
||||||
param_keys = self._context.keys()
|
param_keys = self._context.keys()
|
||||||
|
|
|
@ -5,7 +5,7 @@ from typing import List, Optional
|
||||||
|
|
||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
from django.http import HttpRequest
|
from django.http import HttpRequest
|
||||||
from sentry_sdk import start_span
|
from sentry_sdk.hub import Hub
|
||||||
from sentry_sdk.tracing import Span
|
from sentry_sdk.tracing import Span
|
||||||
from structlog import get_logger
|
from structlog import get_logger
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ class PolicyEngine:
|
||||||
|
|
||||||
def build(self) -> "PolicyEngine":
|
def build(self) -> "PolicyEngine":
|
||||||
"""Build wrapper which monitors performance"""
|
"""Build wrapper which monitors performance"""
|
||||||
with start_span(op="policy.engine.build") as span:
|
with Hub.current.start_span(op="policy.engine.build") as span:
|
||||||
span: Span
|
span: Span
|
||||||
span.set_data("pbm", self.__pbm)
|
span.set_data("pbm", self.__pbm)
|
||||||
span.set_data("request", self.request)
|
span.set_data("request", self.request)
|
||||||
|
|
|
@ -4,7 +4,7 @@ from multiprocessing.connection import Connection
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
from sentry_sdk import start_span
|
from sentry_sdk.hub import Hub
|
||||||
from sentry_sdk.tracing import Span
|
from sentry_sdk.tracing import Span
|
||||||
from structlog import get_logger
|
from structlog import get_logger
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ class PolicyProcess(Process):
|
||||||
|
|
||||||
def execute(self) -> PolicyResult:
|
def execute(self) -> PolicyResult:
|
||||||
"""Run actual policy, returns result"""
|
"""Run actual policy, returns result"""
|
||||||
with start_span(op="policy.process.execute",) as span:
|
with Hub.current.start_span(op="policy.process.execute",) as span:
|
||||||
span: Span
|
span: Span
|
||||||
span.set_data("policy", self.binding.policy)
|
span.set_data("policy", self.binding.policy)
|
||||||
span.set_data("request", self.request)
|
span.set_data("request", self.request)
|
||||||
|
|
Reference in New Issue