Files
zulip/zerver/management/commands/send_stats.py
Anders Kaseorg becef760bf cleanup: Delete leading newlines.
Previous cleanups (mostly the removals of Python __future__ imports)
were done in a way that introduced leading newlines.  Delete leading
newlines from all files, except static/assets/zulip-emoji/NOTICE,
which is a verbatim copy of the Apache 2.0 license.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-08-06 23:29:11 -07:00

27 lines
940 B
Python

from argparse import ArgumentParser
from typing import Any
from django.conf import settings
from django.core.management.base import BaseCommand
class Command(BaseCommand):
help = """Send some stats to statsd."""
def add_arguments(self, parser: ArgumentParser) -> None:
parser.add_argument('operation', metavar='<operation>', type=str,
choices=['incr', 'decr', 'timing', 'timer', 'gauge'],
help="incr|decr|timing|timer|gauge")
parser.add_argument('name', metavar='<name>', type=str)
parser.add_argument('val', metavar='<val>', type=str)
def handle(self, *args: Any, **options: str) -> None:
operation = options['operation']
name = options['name']
val = options['val']
if settings.STATSD_HOST != '':
from statsd import statsd
func = getattr(statsd, operation)
func(name, val)