def get_interval_histogram(interval: int) -> Type[Histogram]: """Creates histogram with a buckets that fit the given interval. 10 buckets below the interval and two buckets with 10 second steps larger than the interval. """ steps = 10 step_size = round(interval / steps, 0) return telemetry.histogram( "round_duration_seconds", "Histogram for duration", buckets=[x * step_size for x in range(steps)] + [interval + 10, interval + 20, float("inf"),], )
def get_interval_histogram(interval: int) -> Histogram: """Create histogram with buckets that fit the given interval. 10 buckets below the interval and two buckets with 10 second steps larger than the interval. Args: interval (int): Interval PromED is running at. Returns: Histogram: Prometheus Histogram object. """ steps = 10 step_size = round(interval / steps, 0) return telemetry.histogram( "round_duration_seconds", "Histogram for duration", buckets=tuple([x * step_size for x in range(steps)] + [ interval + 10, interval + 20, float("inf"), ]), )
""" The only place in this package that directly interacts with the AWS API. Contains the cached fetcher that ensures that expensive calls to the AWS API are cached. """ # Telemetry ==================================================================== CLUSTERS = telemetry.gauge("clusters", "Fetched clusters.") CINSTANCES = telemetry.gauge( "container_instances", "Fetched container instances.", ("cluster",) ) TASKS = telemetry.gauge("tasks", "Fetched tasks.", ("cluster",)) DURATION = telemetry.histogram( "api_requests_duration_seconds", "Duration of requests to the AWS API.", ("method",) ) # ============================================================================== class CachedFetcher: """Works with the AWS API and leverages a sliding cache. Reduces the amount of request made to the AWS API helping to stay below the request limits. Only implements necessary methods. So not a generic class. Rember to flush all caches with `flush_caches()` after every "full round". """ def __init__(
def test_histogram(): histogram = telemetry.histogram("gauge", "doc") assert histogram._name.startswith( f"{s.PROMETHEUS_NAMESPACE}_{s.PROMETHEUS_SUBSYSTEM}")