use of io.opentelemetry.api.common.Attributes in project ApplicationInsights-Java by microsoft.
the class SamplingOverridesTest method shouldFilterStrictMatch.
@Test
void shouldFilterStrictMatch() {
// given
List<SamplingOverride> overrides = singletonList(newOverride(Configuration.SpanKind.SERVER, 0, newStrictAttribute("one", "1")));
SamplingOverrides sampler = new SamplingOverrides(overrides);
Attributes attributes = Attributes.of(AttributeKey.stringKey("one"), "1");
// expect
assertThat(sampler.getOverride(SpanKind.SERVER, attributes).getPercentage()).isEqualTo(0);
}
use of io.opentelemetry.api.common.Attributes in project ApplicationInsights-Java by microsoft.
the class SamplingOverridesTest method shouldFilterKeyOnlyMatch.
@Test
void shouldFilterKeyOnlyMatch() {
// given
List<SamplingOverride> overrides = singletonList(newOverride(Configuration.SpanKind.SERVER, 0, newKeyOnlyAttribute("one")));
SamplingOverrides sampler = new SamplingOverrides(overrides);
Attributes attributes = Attributes.of(AttributeKey.stringKey("one"), "11");
// expect
assertThat(sampler.getOverride(SpanKind.SERVER, attributes).getPercentage()).isEqualTo(0);
}
use of io.opentelemetry.api.common.Attributes in project ApplicationInsights-Java by microsoft.
the class SamplingOverridesTest method shouldNotFilterStrictMatchWithWrongSpanKind.
@Test
void shouldNotFilterStrictMatchWithWrongSpanKind() {
// given
List<SamplingOverride> overrides = singletonList(newOverride(Configuration.SpanKind.SERVER, 0, newStrictAttribute("one", "1")));
SamplingOverrides sampler = new SamplingOverrides(overrides);
Attributes attributes = Attributes.of(AttributeKey.stringKey("one"), "1");
// expect
assertThat(sampler.getOverride(SpanKind.CLIENT, attributes)).isNull();
}
use of io.opentelemetry.api.common.Attributes in project ApplicationInsights-Java by microsoft.
the class SamplingOverridesTest method shouldSampleByDefault.
@Test
void shouldSampleByDefault() {
// given
List<SamplingOverride> overrides = new ArrayList<>();
SamplingOverrides sampler = new SamplingOverrides(overrides);
Attributes attributes = Attributes.empty();
// expect
assertThat(sampler.getOverride(SpanKind.SERVER, attributes)).isNull();
}
use of io.opentelemetry.api.common.Attributes in project ApplicationInsights-Java by microsoft.
the class SamplingOverridesTest method shouldNotFilterBySpanKind.
@Test
void shouldNotFilterBySpanKind() {
// given
List<SamplingOverride> overrides = singletonList(newOverride(Configuration.SpanKind.SERVER, 0));
SamplingOverrides sampler = new SamplingOverrides(overrides);
Attributes attributes = Attributes.empty();
// expect
assertThat(sampler.getOverride(SpanKind.CLIENT, attributes)).isNull();
}
Aggregations