blob: 64a8045df387dad4d5f02861937b6f503b92e278 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.streamingvisitors.tracing;
import org.junit.jupiter.api.Test;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
public class SamplingTraceExporterTest {
@Test
void sampling_decision_is_deferred_to_provided_sampler() {
var exporter = mock(TraceExporter.class);
var sampler = mock(SamplingStrategy.class);
when(sampler.shouldSample()).thenReturn(true, false);
var samplingExporter = new SamplingTraceExporter(exporter, sampler);
samplingExporter.maybeExport(() -> new TraceDescription(null, ""));
verify(exporter, times(1)).maybeExport(any());
samplingExporter.maybeExport(() -> new TraceDescription(null, ""));
verify(exporter, times(1)).maybeExport(any()); // No further invocations since last
}
}
|