def __init__(self, stat_counter_name, message_count_timer=0.25, **kwargs): self.dimensions = kwargs self.message_count_timer = message_count_timer self._meteorite_counter = yelp_meteorite.create_counter( stat_counter_name, self.dimensions ) self._reset()
def report_metric_to_meteorite(backend, metric, value, paasta_cluster): try: paasta_service, paasta_instance = parse_haproxy_backend_name(backend) except IndexError: return meteorite_dims = { "paasta_service": paasta_service, "paasta_cluster": paasta_cluster, "paasta_instance": paasta_instance, } path = f"paasta.service.requests.{metric}" if metric in GUAGES: guage = yelp_meteorite.create_gauge(path, meteorite_dims) guage.set(value) elif metric in COUNTERS: counter = yelp_meteorite.create_counter(path, meteorite_dims) counter.count(value) else: raise ValueError( f"{metric} hasn't been configured as a guage or counter") print(f"Sent {path}: {value} to meteorite")
def create_counter(self, name: str, **kwargs: Any) -> CounterProtocol: return yelp_meteorite.create_counter(self.base_name + "." + name, kwargs)
def create_counter(name: str, *args: Any, **kwargs: Any) -> CounterProtocol: return yelp_meteorite.create_counter(name, *args, **kwargs)
def get_counter_emitter(self, metric, default_dimensions=None): return yelp_meteorite.create_counter( metric, default_dimensions )