本文整理汇总了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));
}
}
示例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);
}
示例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);
}
示例4: transactionLabel
import io.opentracing.contrib.metrics.label.BaggageMetricLabel; //导入依赖的package包/类
@Bean
public MetricLabel transactionLabel() {
return new BaggageMetricLabel("transaction", "n/a");
}
示例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;
}