예제 #1
0
 def measure_job_duration(job, final_status):
     labels = {
         "dotted_name": job.function_name,
         "final_status": final_status,
         "container_id": job.data.get("container_id"),
     }
     duration = time.time() - job._started
     metric_measure(amqp_job_duration, duration, labels)
예제 #2
0
 def measure_job_duration(job, final_status):
     labels = {
         'dotted_name': job.function_name,
         'final_status': final_status,
         'container_id': job.data.get('container_id'),
     }
     duration = time.time() - job._started
     metric_measure(amqp_job_duration, duration, labels)
예제 #3
0
def test_metric_measure():
    # Measure with None metric just returns
    metric_measure(None, "foo", "bar")

    # Measure fills labels and observe
    histogram = MockPrometheusMetric(["label1", "label2"])
    metric_measure(histogram, 20, {"label1": "foo", "label2": "bar"})
    assert histogram.labels_called
    assert histogram.observe_called
    assert histogram._labels["label1"] == "foo"
    assert histogram._labels["label2"] == "bar"
    assert histogram._values == [20]
예제 #4
0
def test_metric_measure():
    # Measure with None metric just returns
    metric_measure(None, 'foo', 'bar')

    # Measure fills labels and observe
    histogram = MockPrometheusMetric(['label1', 'label2'])
    metric_measure(histogram, 20, {
        'label1': 'foo',
        'label2': 'bar',
    })
    assert histogram.labels_called
    assert histogram.observe_called
    assert histogram._labels['label1'] == 'foo'
    assert histogram._labels['label2'] == 'bar'
    assert histogram._values == [20]
예제 #5
0
 def measure_running_jobs(currently_running):
     metric_measure(amqp_running_jobs, currently_running)