1212
1313import io .opentelemetry .api .common .Attributes ;
1414import io .opentelemetry .exporter .internal .ExporterMetrics ;
15- import java .io .IOException ;
16- import java .net .URI ;
17- import java .util .function .Consumer ;
1815import io .opentelemetry .exporter .internal .marshal .Marshaler ;
1916import io .opentelemetry .sdk .common .HealthMetricLevel ;
2017import io .opentelemetry .sdk .internal .ComponentId ;
2118import io .opentelemetry .sdk .internal .SemConvAttributes ;
2219import io .opentelemetry .sdk .metrics .SdkMeterProvider ;
2320import io .opentelemetry .sdk .testing .assertj .OpenTelemetryAssertions ;
2421import io .opentelemetry .sdk .testing .exporter .InMemoryMetricReader ;
22+ import java .io .IOException ;
23+ import java .net .URI ;
24+ import java .util .function .Consumer ;
2525import org .junit .jupiter .api .Test ;
2626import org .junit .jupiter .params .ParameterizedTest ;
2727import org .junit .jupiter .params .provider .EnumSource ;
@@ -95,52 +95,52 @@ void testHealthMetrics(ExporterMetrics.Signal signal) {
9595 HealthMetricLevel .ON ,
9696 id ,
9797 () -> meterProvider ,
98- Attributes .builder ().put ("foo" , "bar" ).build ()
99- );
98+ Attributes .builder ().put ("foo" , "bar" ).build ());
10099
101100 doAnswer (
102- invoc -> {
103- Consumer <GrpcResponse > onResponse = invoc .getArgument (1 );
104-
105- assertThat (inMemoryMetrics .collectAllMetrics ())
106- .hasSize (1 )
107- .anySatisfy (
108- metric ->
109- OpenTelemetryAssertions .assertThat (metric )
110- .hasName (signalMetricPrefix + "inflight" )
111- .hasUnit (expectedUnit )
112- .hasLongSumSatisfying (
113- ma ->
114- ma .isNotMonotonic ()
115- .hasPointsSatisfying (
116- pa ->
117- pa .hasAttributes (expectedAttributes )
118- .hasValue (42 ))));
119-
120- onResponse .accept (GrpcResponse .create (0 , null ));
121- return null ;
122- })
101+ invoc -> {
102+ Consumer <GrpcResponse > onResponse = invoc .getArgument (1 );
103+
104+ assertThat (inMemoryMetrics .collectAllMetrics ())
105+ .hasSize (1 )
106+ .anySatisfy (
107+ metric ->
108+ OpenTelemetryAssertions .assertThat (metric )
109+ .hasName (signalMetricPrefix + "inflight" )
110+ .hasUnit (expectedUnit )
111+ .hasLongSumSatisfying (
112+ ma ->
113+ ma .isNotMonotonic ()
114+ .hasPointsSatisfying (
115+ pa ->
116+ pa .hasAttributes (expectedAttributes )
117+ .hasValue (42 ))));
118+
119+ onResponse .accept (GrpcResponse .create (0 , null ));
120+ return null ;
121+ })
123122 .when (mockSender )
124123 .send (any (), any (), any ());
125124
126125 exporter .export (mockMarshaller , 42 );
127126
128127 doAnswer (
129- invoc -> {
130- Consumer <GrpcResponse > onResponse = invoc .getArgument (1 );
131- onResponse .accept (GrpcResponse .create (GrpcExporterUtil .GRPC_STATUS_UNAVAILABLE , null ));
132- return null ;
133- })
128+ invoc -> {
129+ Consumer <GrpcResponse > onResponse = invoc .getArgument (1 );
130+ onResponse .accept (
131+ GrpcResponse .create (GrpcExporterUtil .GRPC_STATUS_UNAVAILABLE , null ));
132+ return null ;
133+ })
134134 .when (mockSender )
135- .send (any (),any (), any ());
135+ .send (any (), any (), any ());
136136 exporter .export (mockMarshaller , 15 );
137137
138138 doAnswer (
139- invoc -> {
140- Consumer <Throwable > onError = invoc .getArgument (2 );
141- onError .accept (new IOException ("Computer says no" ));
142- return null ;
143- })
139+ invoc -> {
140+ Consumer <Throwable > onError = invoc .getArgument (2 );
141+ onError .accept (new IOException ("Computer says no" ));
142+ return null ;
143+ })
144144 .when (mockSender )
145145 .send (any (), any (), any ());
146146 exporter .export (mockMarshaller , 7 );
@@ -168,7 +168,9 @@ void testHealthMetrics(ExporterMetrics.Signal signal) {
168168 pa ->
169169 pa .hasAttributes (
170170 expectedAttributes .toBuilder ()
171- .put (SemConvAttributes .ERROR_TYPE , "" +GrpcExporterUtil .GRPC_STATUS_UNAVAILABLE )
171+ .put (
172+ SemConvAttributes .ERROR_TYPE ,
173+ "" + GrpcExporterUtil .GRPC_STATUS_UNAVAILABLE )
172174 .build ())
173175 .hasValue (15 ),
174176 pa ->
@@ -191,7 +193,9 @@ void testHealthMetrics(ExporterMetrics.Signal signal) {
191193 pa ->
192194 pa .hasAttributes (
193195 expectedAttributes .toBuilder ()
194- .put (SemConvAttributes .ERROR_TYPE , "" +GrpcExporterUtil .GRPC_STATUS_UNAVAILABLE )
196+ .put (
197+ SemConvAttributes .ERROR_TYPE ,
198+ "" + GrpcExporterUtil .GRPC_STATUS_UNAVAILABLE )
195199 .build ())
196200 .hasBucketCounts (1 ),
197201 pa ->
@@ -224,25 +228,25 @@ void testHealthMetricsDisabled() {
224228 HealthMetricLevel .OFF ,
225229 id ,
226230 () -> meterProvider ,
227- Attributes .empty ()
228- );
231+ Attributes .empty ());
229232
230233 doAnswer (
231- invoc -> {
232- Consumer <GrpcResponse > onResponse = invoc .getArgument (1 );
233- onResponse .accept (GrpcResponse .create (0 , null ));
234- return null ;
235- })
234+ invoc -> {
235+ Consumer <GrpcResponse > onResponse = invoc .getArgument (1 );
236+ onResponse .accept (GrpcResponse .create (0 , null ));
237+ return null ;
238+ })
236239 .when (mockSender )
237240 .send (any (), any (), any ());
238241 exporter .export (mockMarshaller , 42 );
239242
240243 doAnswer (
241- invoc -> {
242- Consumer <GrpcResponse > onResponse = invoc .getArgument (1 );
243- onResponse .accept (GrpcResponse .create (GrpcExporterUtil .GRPC_STATUS_UNAVAILABLE , null ));
244- return null ;
245- })
244+ invoc -> {
245+ Consumer <GrpcResponse > onResponse = invoc .getArgument (1 );
246+ onResponse .accept (
247+ GrpcResponse .create (GrpcExporterUtil .GRPC_STATUS_UNAVAILABLE , null ));
248+ return null ;
249+ })
246250 .when (mockSender )
247251 .send (any (), any (), any ());
248252 exporter .export (mockMarshaller , 42 );
0 commit comments