File tree Expand file tree Collapse file tree 1 file changed +23
-2
lines changed
src/test/java/com/spotify/github/tracing Expand file tree Collapse file tree 1 file changed +23
-2
lines changed Original file line number Diff line number Diff line change 27
27
28
28
import java .util .Collections ;
29
29
30
- import static org .mockito .Mockito .mock ;
31
- import static org .mockito .Mockito .verify ;
30
+ import static org .mockito .Mockito .*;
32
31
33
32
class OpenTelemetrySpanTest {
34
33
private final io .opentelemetry .api .trace .Span wrapped = mock (io .opentelemetry .api .trace .Span .class );
@@ -66,4 +65,26 @@ public void failOnServerError() {
66
65
verify (wrapped ).end ();
67
66
}
68
67
68
+ @ Test
69
+ public void failWithNullThrowable () {
70
+ final Span span = new OpenTelemetrySpan (wrapped );
71
+ span .failure (null );
72
+ span .close ();
73
+
74
+ verify (wrapped ).setStatus (StatusCode .UNSET );
75
+ verify (wrapped , never ()).setAttribute (anyString (), any ());
76
+ verify (wrapped ).end ();
77
+ }
78
+
79
+ @ Test
80
+ public void failWithNonRequestNotOkException () {
81
+ final Span span = new OpenTelemetrySpan (wrapped );
82
+ span .failure (new RuntimeException ("Unexpected error" ));
83
+ span .close ();
84
+
85
+ verify (wrapped ).setStatus (StatusCode .UNSET );
86
+ verify (wrapped , never ()).setAttribute ("http.status_code" , 404 );
87
+ verify (wrapped , never ()).setAttribute ("error" , true );
88
+ verify (wrapped ).end ();
89
+ }
69
90
}
You can’t perform that action at this time.
0 commit comments