1515import static io .opentelemetry .api .common .AttributeKey .stringKey ;
1616import static io .opentelemetry .sdk .testing .assertj .OpenTelemetryAssertions .assertThat ;
1717import static io .opentelemetry .sdk .testing .assertj .OpenTelemetryAssertions .equalTo ;
18+ import static java .util .Collections .singletonList ;
1819import static java .util .stream .Collectors .joining ;
1920import static org .assertj .core .api .Assertions .assertThatCode ;
2021import static org .assertj .core .api .Assertions .assertThatThrownBy ;
@@ -135,7 +136,7 @@ void nothingChangedAfterEnd() {
135136 spanData ,
136137 Attributes .empty (),
137138 Collections .emptyList (),
138- Collections . singletonList (link ),
139+ singletonList (link ),
139140 SPAN_NAME ,
140141 START_EPOCH_NANOS ,
141142 START_EPOCH_NANOS ,
@@ -161,14 +162,14 @@ void onEnding_spanStillMutable() {
161162
162163 AtomicBoolean endedStateInProcessor = new AtomicBoolean ();
163164 doAnswer (
164- invocation -> {
165- ReadWriteSpan sp = invocation .getArgument (0 , ReadWriteSpan .class );
166- assertThat (sp .hasEnded ()).isFalse ();
167- sp .end (); // should have no effect, nested end should be detected
168- endedStateInProcessor .set (sp .hasEnded ());
169- sp .setAttribute (dummyAttrib , "bar" );
170- return null ;
171- })
165+ invocation -> {
166+ ReadWriteSpan sp = invocation .getArgument (0 , ReadWriteSpan .class );
167+ assertThat (sp .hasEnded ()).isFalse ();
168+ sp .end (); // should have no effect, nested end should be detected
169+ endedStateInProcessor .set (sp .hasEnded ());
170+ sp .setAttribute (dummyAttrib , "bar" );
171+ return null ;
172+ })
172173 .when (spanProcessor )
173174 .onEnding (any ());
174175
@@ -187,21 +188,21 @@ void onEnding_concurrentModificationsPrevented() {
187188 AttributeKey <String > concurrentAttrib = AttributeKey .stringKey ("concurrent_foo" );
188189
189190 doAnswer (
190- invocation -> {
191- ReadWriteSpan sp = invocation .getArgument (0 , ReadWriteSpan .class );
191+ invocation -> {
192+ ReadWriteSpan sp = invocation .getArgument (0 , ReadWriteSpan .class );
192193
193- Thread concurrent =
194- new Thread (
195- () -> {
196- sp .setAttribute (concurrentAttrib , "concurrent_bar" );
197- });
198- concurrent .start ();
199- concurrent .join ();
194+ Thread concurrent =
195+ new Thread (
196+ () -> {
197+ sp .setAttribute (concurrentAttrib , "concurrent_bar" );
198+ });
199+ concurrent .start ();
200+ concurrent .join ();
200201
201- sp .setAttribute (syncAttrib , "sync_bar" );
202+ sp .setAttribute (syncAttrib , "sync_bar" );
202203
203- return null ;
204- })
204+ return null ;
205+ })
205206 .when (spanProcessor )
206207 .onEnding (any ());
207208
@@ -217,13 +218,13 @@ void onEnding_latencyPinned() {
217218
218219 AtomicLong spanLatencyInProcessor = new AtomicLong ();
219220 doAnswer (
220- invocation -> {
221- ReadWriteSpan sp = invocation .getArgument (0 , ReadWriteSpan .class );
221+ invocation -> {
222+ ReadWriteSpan sp = invocation .getArgument (0 , ReadWriteSpan .class );
222223
223- testClock .advance (Duration .ofSeconds (100 ));
224- spanLatencyInProcessor .set (sp .getLatencyNanos ());
225- return null ;
226- })
224+ testClock .advance (Duration .ofSeconds (100 ));
225+ spanLatencyInProcessor .set (sp .getLatencyNanos ());
226+ return null ;
227+ })
227228 .when (spanProcessor )
228229 .onEnding (any ());
229230
@@ -251,8 +252,8 @@ void toSpanData_ActiveSpan() {
251252 verifySpanData (
252253 spanData ,
253254 expectedAttributes ,
254- Collections . singletonList (event ),
255- Collections . singletonList (link ),
255+ singletonList (event ),
256+ singletonList (link ),
256257 SPAN_NEW_NAME ,
257258 START_EPOCH_NANOS ,
258259 0 ,
@@ -282,8 +283,8 @@ void toSpanData_EndedSpan() {
282283 verifySpanData (
283284 spanData ,
284285 expectedAttributes ,
285- Collections . singletonList (event ),
286- Collections . singletonList (link ),
286+ singletonList (event ),
287+ singletonList (link ),
287288 SPAN_NEW_NAME ,
288289 START_EPOCH_NANOS ,
289290 testClock .now (),
@@ -306,7 +307,7 @@ void toSpanData_immutableEvents() {
306307 SpanData spanData = span .toSpanData ();
307308
308309 assertThatThrownBy (
309- () -> spanData .getEvents ().add (EventData .create (1000 , "test" , Attributes .empty ())))
310+ () -> spanData .getEvents ().add (EventData .create (1000 , "test" , Attributes .empty ())))
310311 .isInstanceOf (UnsupportedOperationException .class );
311312 }
312313
@@ -317,7 +318,7 @@ void toSpanData_immutableEvents_ended() {
317318 SpanData spanData = span .toSpanData ();
318319
319320 assertThatThrownBy (
320- () -> spanData .getEvents ().add (EventData .create (1000 , "test" , Attributes .empty ())))
321+ () -> spanData .getEvents ().add (EventData .create (1000 , "test" , Attributes .empty ())))
321322 .isInstanceOf (UnsupportedOperationException .class );
322323 }
323324
@@ -466,7 +467,8 @@ void getAttributes_Empty() {
466467 }
467468
468469 @ Test
469- @ SuppressWarnings ("deprecation" ) // Testing deprecated code
470+ @ SuppressWarnings ("deprecation" )
471+ // Testing deprecated code
470472 void getInstrumentationLibraryInfo () {
471473 SdkSpan span = createTestSpan (SpanKind .CLIENT );
472474 try {
@@ -552,13 +554,10 @@ void setAttribute() {
552554 span .setAttribute (doubleArrayKey ("NullArrayDoubleKey" ), null );
553555 span .setAttribute (booleanArrayKey ("NullArrayBooleanKey" ), null );
554556 // These should be maintained
555- span .setAttribute (longArrayKey ("ArrayWithNullLongKey" ), Arrays .asList (new Long [] {null }));
556- span .setAttribute (
557- stringArrayKey ("ArrayWithNullStringKey" ), Arrays .asList (new String [] {null }));
558- span .setAttribute (
559- doubleArrayKey ("ArrayWithNullDoubleKey" ), Arrays .asList (new Double [] {null }));
560- span .setAttribute (
561- booleanArrayKey ("ArrayWithNullBooleanKey" ), Arrays .asList (new Boolean [] {null }));
557+ span .setAttribute (longArrayKey ("ArrayWithNullLongKey" ), singletonList (null ));
558+ span .setAttribute (stringArrayKey ("ArrayWithNullStringKey" ), singletonList (null ));
559+ span .setAttribute (doubleArrayKey ("ArrayWithNullDoubleKey" ), singletonList (null ));
560+ span .setAttribute (booleanArrayKey ("ArrayWithNullBooleanKey" ), singletonList (null ));
562561 } finally {
563562 span .end ();
564563 }
@@ -691,10 +690,10 @@ void setAllAttributes() {
691690 .put (doubleArrayKey ("NullArrayDoubleKey" ), (Double []) null )
692691 .put (booleanArrayKey ("NullArrayBooleanKey" ), (Boolean []) null )
693692 // These should be maintained
694- .put (longArrayKey ("ArrayWithNullLongKey" ), Arrays . asList ( new Long [] { null } ))
695- .put (stringArrayKey ("ArrayWithNullStringKey" ), Arrays . asList ( new String [] { null } ))
696- .put (doubleArrayKey ("ArrayWithNullDoubleKey" ), Arrays . asList ( new Double [] { null } ))
697- .put (booleanArrayKey ("ArrayWithNullBooleanKey" ), Arrays . asList ( new Boolean [] { null } ))
693+ .put (longArrayKey ("ArrayWithNullLongKey" ), singletonList ( null ))
694+ .put (stringArrayKey ("ArrayWithNullStringKey" ), singletonList ( null ))
695+ .put (doubleArrayKey ("ArrayWithNullDoubleKey" ), singletonList ( null ))
696+ .put (booleanArrayKey ("ArrayWithNullBooleanKey" ), singletonList ( null ))
698697 .build ();
699698
700699 try {
@@ -1315,7 +1314,7 @@ public void setExceptionAttributes(
13151314 SpanLimits .getDefault (),
13161315 parentSpanId ,
13171316 null ,
1318- Collections . singletonList (link ),
1317+ singletonList (link ),
13191318 exceptionAttributeResolver );
13201319
13211320 span .recordException (new IllegalStateException ("error" ));
@@ -1374,8 +1373,8 @@ void onStartOnEndNotRequired() {
13741373 SpanKind .INTERNAL ,
13751374 parentSpanId != null
13761375 ? Span .wrap (
1377- SpanContext .create (
1378- traceId , parentSpanId , TraceFlags .getDefault (), TraceState .getDefault ()))
1376+ SpanContext .create (
1377+ traceId , parentSpanId , TraceFlags .getDefault (), TraceState .getDefault ()))
13791378 : Span .getInvalid (),
13801379 Context .root (),
13811380 spanLimits ,
@@ -1405,7 +1404,8 @@ void setStatus(Consumer<Span> spanConsumer, StatusData expectedSpanData) {
14051404 private static Stream <Arguments > setStatusArgs () {
14061405 return Stream .of (
14071406 // Default status is UNSET
1408- Arguments .of (spanConsumer (span -> {}), StatusData .unset ()),
1407+ Arguments .of (spanConsumer (span -> {
1408+ }), StatusData .unset ()),
14091409 // Simple cases
14101410 Arguments .of (spanConsumer (span -> span .setStatus (StatusCode .OK )), StatusData .ok ()),
14111411 Arguments .of (spanConsumer (span -> span .setStatus (StatusCode .ERROR )), StatusData .error ()),
@@ -1462,7 +1462,7 @@ private SdkSpan createTestSpanWithAttributes(Map<AttributeKey, Object> attribute
14621462 SpanLimits .getDefault (),
14631463 null ,
14641464 attributesMap ,
1465- Collections . singletonList (link ),
1465+ singletonList (link ),
14661466 ExceptionAttributeResolver .getDefault ());
14671467 }
14681468
@@ -1472,7 +1472,7 @@ private SdkSpan createTestRootSpan() {
14721472 SpanLimits .getDefault (),
14731473 SpanId .getInvalid (),
14741474 null ,
1475- Collections . singletonList (link ),
1475+ singletonList (link ),
14761476 ExceptionAttributeResolver .getDefault ());
14771477 }
14781478
@@ -1482,7 +1482,7 @@ private SdkSpan createTestSpan(SpanKind kind) {
14821482 SpanLimits .getDefault (),
14831483 parentSpanId ,
14841484 null ,
1485- Collections . singletonList (link ),
1485+ singletonList (link ),
14861486 ExceptionAttributeResolver .getDefault ());
14871487 }
14881488
@@ -1492,7 +1492,7 @@ private SdkSpan createTestSpan(SpanLimits config) {
14921492 config ,
14931493 parentSpanId ,
14941494 null ,
1495- Collections . singletonList (link ),
1495+ singletonList (link ),
14961496 ExceptionAttributeResolver .getDefault ());
14971497 }
14981498
@@ -1513,8 +1513,8 @@ private SdkSpan createTestSpan(
15131513 kind ,
15141514 parentSpanId != null
15151515 ? Span .wrap (
1516- SpanContext .create (
1517- traceId , parentSpanId , TraceFlags .getDefault (), TraceState .getDefault ()))
1516+ SpanContext .create (
1517+ traceId , parentSpanId , TraceFlags .getDefault (), TraceState .getDefault ()))
15181518 : Span .getInvalid (),
15191519 Context .root (),
15201520 config ,
@@ -1601,8 +1601,8 @@ void testAsSpanData() {
16011601 kind ,
16021602 parentSpanId != null
16031603 ? Span .wrap (
1604- SpanContext .create (
1605- traceId , parentSpanId , TraceFlags .getDefault (), TraceState .getDefault ()))
1604+ SpanContext .create (
1605+ traceId , parentSpanId , TraceFlags .getDefault (), TraceState .getDefault ()))
16061606 : Span .getInvalid (),
16071607 Context .root (),
16081608 spanLimits ,
@@ -1611,7 +1611,7 @@ void testAsSpanData() {
16111611 clock ,
16121612 resource ,
16131613 attributesWithCapacity ,
1614- Collections . singletonList (link1 ),
1614+ singletonList (link1 ),
16151615 1 ,
16161616 0 );
16171617 long startEpochNanos = clock .now ();
@@ -1638,7 +1638,7 @@ void testAsSpanData() {
16381638 result ,
16391639 attributesWithCapacity ,
16401640 events ,
1641- Collections . singletonList (link1 ),
1641+ singletonList (link1 ),
16421642 name ,
16431643 startEpochNanos ,
16441644 endEpochNanos ,
0 commit comments