Beispiel #1
0
def test_prometheus_metrics_counter():
    metrics = PrometheusMetricsFactory(namespace='test')
    counter1 = metrics.create_counter(name='jaeger:test_counter', tags={'result': 'ok'})
    counter1(1)
    counter2 = metrics.create_counter(name='jaeger:test_counter', tags={'result': 'ok'})
    counter2(1)
    after = REGISTRY.get_sample_value('test_jaeger:test_counter', {'result': 'ok'})
    assert 2 == after
def test_prometheus_metrics_counter():
    metrics = PrometheusMetricsFactory(namespace='test')
    counter1 = metrics.create_counter(name='jaeger:test_counter',
                                      tags={'result': 'ok'})
    counter1(1)
    counter2 = metrics.create_counter(name='jaeger:test_counter',
                                      tags={'result': 'ok'})
    counter2(1)
    after = REGISTRY.get_sample_value('test_jaeger:test_counter',
                                      {'result': 'ok'})
    assert 2 == after
def test_prometheus_metrics_metric_without_service_name_label():
    metrics = PrometheusMetricsFactory()
    gauge = metrics.create_gauge(
        name='jaeger:test_gauge_without_service_name_label')
    gauge(1)
    gauge_after = REGISTRY.get_sample_value(
        'jaeger:test_gauge_without_service_name_label')
    counter = metrics.create_counter(
        name='jaeger:test_counter_without_service_name_label')
    counter(1)
    counter_after = REGISTRY.get_sample_value(
        'jaeger:test_counter_without_service_name_label')
    assert 1 == counter_after
    assert 1 == gauge_after
def test_prometheus_metrics_metric_with_service_name_label():
    metrics = PrometheusMetricsFactory(service_name_label='test')
    gauge = metrics.create_gauge(
        name='jaeger:test_gauge_with_service_name_label')
    gauge(1)
    gauge_after = REGISTRY.get_sample_value(
        'jaeger:test_gauge_with_service_name_label', {'service': 'test'})
    counter = metrics.create_counter(
        name='jaeger:test_counter_with_service_name_label', tags={'x': 'y'})
    counter(1)
    counter_after = REGISTRY.get_sample_value(
        'jaeger:test_counter_with_service_name_label', {
            'service': 'test',
            'x': 'y'
        })
    assert 1 == counter_after
    assert 1 == gauge_after
def test_prometheus_metrics_counter_without_tags():
    metrics = PrometheusMetricsFactory()
    counter = metrics.create_counter(name='jaeger:test_counter_no_tags')
    counter(1)
    after = REGISTRY.get_sample_value('jaeger:test_counter_no_tags')
    assert 1 == after
def test_prometheus_metrics_counter_without_tags():
    metrics = PrometheusMetricsFactory()
    counter = metrics.create_counter(name='jaeger:test_counter_no_tags')
    counter(1)
    after = REGISTRY.get_sample_value('jaeger:test_counter_no_tags')
    assert 1 == after