def create_datadog_event(title, text, alert_type=ALERT_INFO, tags=None, aggregation_key=None): tags = COMMON_TAGS + (tags or []) if datadog_initialized(): try: api.Event.create(title=title, text=text, tags=tags, alert_type=alert_type, aggregation_key=aggregation_key) except DatadogException: datadog_logger.exception("Error creating Datadog event") else: datadog_logger.debug("Datadog event: (%s) %s\n%s", alert_type, title, text)
def _inner(*args, **kwargs): response = fn(*args, **kwargs) try: metric_name = '{}.{}'.format(metric_prefix, response.status_code) statsd.increment(metric_name) except Exception: datadog_logger.exception('Unable to record Datadog stats') return response
def _inner(*args, **kwargs): response = fn(*args, **kwargs) try: datadog_counter(metric_name, tags=[ 'status_code:{}'.format(response.status_code) ]) except Exception: datadog_logger.exception('Unable to record Datadog stats') return response
def _inner(*args, **kwargs): response = fn(*args, **kwargs) try: datadog_counter( metric_name, tags=['status_code:{}'.format(response.status_code)]) except Exception: datadog_logger.exception('Unable to record Datadog stats') return response
def create_datadog_event(title, text, alert_type=ALERT_INFO, tags=None, aggregation_key=None): tags = COMMON_TAGS + (tags or []) if datadog_initialized(): try: api.Event.create( title=title, text=text, tags=tags, alert_type=alert_type, aggregation_key=aggregation_key, ) except Exception as e: datadog_logger.exception('Error creating Datadog event', e) else: datadog_logger.debug('Datadog event: (%s) %s\n%s', alert_type, title, text)
def _datadog_record(fn, name, value, enforce_prefix='commcare', tags=None): _enforce_prefix(name, enforce_prefix) try: fn(name, value, tags=tags) except Exception: datadog_logger.exception('Unable to record Datadog stats')