-
Notifications
You must be signed in to change notification settings - Fork 234
Closed as not planned
Description
We should make it easy to instrument Django management commands. It is not a lot of work now, but it could be made even easier by providing a base class that calls the right APIs
Currently, the user would need to do something like
from django.core.management.base import BaseCommand, CommandError
import elasticapm
from elasticapm.contrib.django.client import get_client
class Command(BaseCommand):
def handle(self, *args, **options):
elasticapm.instrument()
client = get_client()
client.begin_transaction(transaction_type="command")
try:
# do some work
status = "success"
except Exception as e:
client.capture_exception()
status = "failure"
raise e # Python 3
# for Python 2, use this instead:
#
# import sys
# t, v, tb = sys.exc_info()
# raise t, v, tb
finally:
# use module name as transaction name
client.end_transaction(name=__name__, result=status)
basepi and TSivaID