当前位置: 首页>>代码示例>>Java>>正文


Java BaggageMetricLabel类代码示例

本文整理汇总了Java中io.opentracing.contrib.metrics.label.BaggageMetricLabel的典型用法代码示例。如果您正苦于以下问题:Java BaggageMetricLabel类的具体用法?Java BaggageMetricLabel怎么用?Java BaggageMetricLabel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BaggageMetricLabel类属于io.opentracing.contrib.metrics.label包,在下文中一共展示了BaggageMetricLabel类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testWithCustomLabel

import io.opentracing.contrib.metrics.label.BaggageMetricLabel; //导入依赖的package包/类
@Test
public void testWithCustomLabel() {
    MetricLabel metricLabel = new BaggageMetricLabel(METRIC_LABEL_NAME, METRIC_LABEL_VALUE);
    PrometheusMetricsReporter reporter = PrometheusMetricsReporter.newMetricsReporter()
            .withName("MyName")
            .withCollectorRegistry(collectorRegistry)
            .withCustomLabel(metricLabel)
            .withConstLabel("span.kind", Tags.SPAN_KIND_CLIENT) // Override the default, to make sure span metrics reported
            .build();

    SpanData spanData = mock(SpanData.class);
    when(spanData.getOperationName()).thenReturn("testop");
    when(spanData.getTags()).thenReturn(Collections.<String,Object>emptyMap());
    when(spanData.getDuration()).thenReturn(100000L);

    reporter.reportSpan(spanData);

    List<MetricFamilySamples> samples = reporter.getHistogram().collect();
    assertEquals(1, samples.size());

    for (Sample sample : samples.get(0).samples) {
        assertTrue("Expected MetricLabel with name " + METRIC_LABEL_NAME, sample.labelNames.contains(METRIC_LABEL_NAME));
        assertTrue("Expected MetricLabel with value " + METRIC_LABEL_VALUE , sample.labelValues.contains(METRIC_LABEL_VALUE));
    }
}
 
开发者ID:opentracing-contrib,项目名称:java-metrics,代码行数:26,代码来源:PrometheusMetricsReporterTest.java

示例2: testLabelDefault

import io.opentracing.contrib.metrics.label.BaggageMetricLabel; //导入依赖的package包/类
@Test
public void testLabelDefault() {
    MetricLabel label = new BaggageMetricLabel(TEST_LABEL, TEST_LABEL_DEFAULT);
    Span span = mock(Span.class);
    when(span.getBaggageItem(anyString())).thenReturn(null);

    assertEquals(TEST_LABEL, label.name());
    assertEquals(TEST_LABEL_DEFAULT, label.value(span, null, Collections.<String,Object>emptyMap()));
    verify(span, times(1)).getBaggageItem(TEST_LABEL);
}
 
开发者ID:objectiser,项目名称:java-metrics-prototype,代码行数:11,代码来源:BaggageMetricLabelTest.java

示例3: testLabelFromBaggage

import io.opentracing.contrib.metrics.label.BaggageMetricLabel; //导入依赖的package包/类
@Test
public void testLabelFromBaggage() {
    MetricLabel label = new BaggageMetricLabel(TEST_LABEL, TEST_LABEL_DEFAULT);
    Span span = mock(Span.class);
    when(span.getBaggageItem(anyString())).thenReturn("BaggageValue");
    
    assertEquals("BaggageValue", label.value(span, null, Collections.<String,Object>emptyMap()));
    verify(span, times(1)).getBaggageItem(TEST_LABEL);
}
 
开发者ID:objectiser,项目名称:java-metrics-prototype,代码行数:10,代码来源:BaggageMetricLabelTest.java

示例4: transactionLabel

import io.opentracing.contrib.metrics.label.BaggageMetricLabel; //导入依赖的package包/类
@Bean
public MetricLabel transactionLabel() {
    return new BaggageMetricLabel("transaction", "n/a");
}
 
开发者ID:objectiser,项目名称:opentracing-prometheus-example,代码行数:5,代码来源:MetricsConfiguration.java

示例5: withBaggageLabel

import io.opentracing.contrib.metrics.label.BaggageMetricLabel; //导入依赖的package包/类
public Builder withBaggageLabel(String name, Object defaultValue) {
    metricLabels.add(new BaggageMetricLabel(name, defaultValue));
    return this;
}
 
开发者ID:opentracing-contrib,项目名称:java-metrics,代码行数:5,代码来源:PrometheusMetricsReporter.java


注:本文中的io.opentracing.contrib.metrics.label.BaggageMetricLabel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。