Merge pull request #117 from BeryJu/apm

Support for Elastic APM
This commit is contained in:
Jens L
2020-07-07 18:48:40 +02:00
committed by GitHub
11 changed files with 72 additions and 5 deletions

View File

@ -5,6 +5,7 @@ from typing import List, Optional
from django.core.cache import cache
from django.http import HttpRequest
from elasticapm import capture_span
from structlog import get_logger
from passbook.core.models import User
@ -69,6 +70,7 @@ class PolicyEngine:
if policy.__class__ == Policy:
raise TypeError(f"Policy '{policy}' is root type")
@capture_span(name="PolicyEngine", span_type="policy.engine.build")
def build(self) -> "PolicyEngine":
"""Build task group"""
for binding in self._iter_bindings():

View File

@ -4,6 +4,7 @@ from multiprocessing.connection import Connection
from typing import Optional
from django.core.cache import cache
from elasticapm import capture_span
from structlog import get_logger
from passbook.policies.exceptions import PolicyException
@ -44,6 +45,7 @@ class PolicyProcess(Process):
if connection:
self.connection = connection
@capture_span(name="PolicyEngine", span_type="policy.process.execute")
def execute(self) -> PolicyResult:
"""Run actual policy, returns result"""
LOGGER.debug(