_both.py (1978B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\monolithmetrics\_both.py 2 from __future__ import absolute_import 3 from . import _statsd 4 from . import _prometheus 5 from monolithconfig import on_client 6 7 def gauge(metric, value, tags = None, sample_rate = 1, prometheus_only = False): 8 if on_client(): 9 return 10 _prometheus.gauge(metric, value, tags=tags) 11 if prometheus_only: 12 return 13 _statsd.gauge(metric, value, tags=tags, sample_rate=sample_rate) 14 15 16 def increment(metric, value = 1, tags = None, sample_rate = 1, prometheus_only = False): 17 if on_client(): 18 return 19 _prometheus.increment(metric, value, tags=tags) 20 if prometheus_only: 21 return 22 _statsd.increment(metric, value, tags=tags, sample_rate=sample_rate) 23 24 25 def decrement(metric, value = 1, tags = None, sample_rate = 1, prometheus_only = False): 26 if on_client(): 27 return 28 if prometheus_only: 29 return 30 _statsd.decrement(metric, value, tags=tags, sample_rate=sample_rate) 31 32 33 def histogram(metric, value, tags = None, sample_rate = 1, buckets = None, prometheus_only = False): 34 if on_client(): 35 return 36 _prometheus.histogram(metric, value, tags=tags, buckets=buckets) 37 if prometheus_only: 38 return 39 _statsd.histogram(metric, value, tags=tags, sample_rate=sample_rate) 40 41 42 def timing(metric, value, tags = None, sample_rate = 1, buckets = None, prometheus_only = False): 43 if on_client(): 44 return 45 _prometheus.histogram(metric, value, tags=tags, buckets=buckets) 46 if prometheus_only: 47 return 48 _statsd.timing(metric, value, tags=tags, sample_rate=sample_rate) 49 50 51 def event(title, text = '', tags = None, prometheus_only = False): 52 if on_client(): 53 return 54 _prometheus.event(title, text=text, tags=tags) 55 if prometheus_only: 56 return 57 _statsd.event(title, text=text, tags=tags) 58 59 60 def flush(): 61 if on_client(): 62 return 63 _statsd.flush()