6
6
package io .opentelemetry .sdk .trace ;
7
7
8
8
import static org .assertj .core .api .Assertions .assertThat ;
9
+ import static org .mockito .Mockito .mock ;
9
10
10
11
import io .opentelemetry .api .common .AttributeKey ;
11
12
import io .opentelemetry .api .common .Attributes ;
12
13
import io .opentelemetry .sdk .resources .Resource ;
14
+ import org .assertj .core .api .InstanceOfAssertFactories ;
13
15
import org .junit .jupiter .api .Test ;
14
16
15
17
public class SdkTracerProviderBuilderTest {
@@ -28,4 +30,23 @@ void addResource() {
28
30
.extracting ("sharedState" )
29
31
.hasFieldOrPropertyWithValue ("resource" , Resource .getDefault ().merge (customResource ));
30
32
}
33
+
34
+ @ Test
35
+ void addSpanProcessorFirst () {
36
+ SpanProcessor firstProcessor = mock (SpanProcessor .class );
37
+ SpanProcessor anotherProcessor = mock (SpanProcessor .class );
38
+
39
+ SdkTracerProvider sdkTracerProvider =
40
+ SdkTracerProvider .builder ()
41
+ .addSpanProcessor (anotherProcessor )
42
+ .addSpanProcessorFirst (firstProcessor )
43
+ .build ();
44
+
45
+ assertThat (sdkTracerProvider )
46
+ .extracting ("sharedState" )
47
+ .extracting ("activeSpanProcessor" )
48
+ .extracting ("spanProcessorsAll" , InstanceOfAssertFactories .list (SpanProcessor .class ))
49
+ .hasSize (2 )
50
+ .containsExactly (firstProcessor , anotherProcessor );
51
+ }
31
52
}
0 commit comments