@@ -86,22 +86,6 @@ public void shouldPublishMetricsTracesAndLogs() throws Exception {
8686 .execute (() -> new OtlpMeterRegistry (otlpConfig , Clock .SYSTEM ));
8787 Counter .builder ("test.counter" ).register (meterRegistry ).increment (2 );
8888
89- Awaitility
90- .given ()
91- .pollInterval (Duration .ofSeconds (2 ))
92- .atMost (Duration .ofSeconds (5 ))
93- .ignoreExceptions ()
94- .untilAsserted (() -> {
95- Response response = RestAssured
96- .given ()
97- .queryParam ("query" , "test_counter_total{job=\" testcontainers\" }" )
98- .get (String .format ("%s/api/v1/query" , lgtm .getPrometheusHttpUrl ()))
99- .prettyPeek ()
100- .thenReturn ();
101- assertThat (response .getStatusCode ()).isEqualTo (200 );
102- assertThat (response .body ().jsonPath ().getList ("data.result[0].value" )).contains ("2" );
103- });
104-
10589 // Logs
10690 Logger logger = openTelemetry .getSdkLoggerProvider ().loggerBuilder ("test" ).build ();
10791 logger
@@ -110,41 +94,43 @@ public void shouldPublishMetricsTracesAndLogs() throws Exception {
11094 .setAttribute (AttributeKey .stringKey ("job" ), "test-job" )
11195 .emit ();
11296
97+ // Traces
98+ Tracer tracer = openTelemetry .getTracer ("test" );
99+ Span span = tracer .spanBuilder ("test" ).startSpan ();
100+ span .end ();
101+
113102 Awaitility
114103 .given ()
115104 .pollInterval (Duration .ofSeconds (2 ))
116105 .atMost (Duration .ofSeconds (5 ))
117106 .ignoreExceptions ()
118107 .untilAsserted (() -> {
119- Response response = RestAssured
108+ Response metricResponse = RestAssured
109+ .given ()
110+ .queryParam ("query" , "test_counter_total{job=\" testcontainers\" }" )
111+ .get (String .format ("%s/api/v1/query" , lgtm .getPrometheusHttpUrl ()))
112+ .prettyPeek ()
113+ .thenReturn ();
114+ assertThat (metricResponse .getStatusCode ()).isEqualTo (200 );
115+ assertThat (metricResponse .body ().jsonPath ().getList ("data.result[0].value" )).contains ("2" );
116+
117+ Response logResponse = RestAssured
120118 .given ()
121119 .queryParam ("query" , "{service_name=\" unknown_service:java\" }" )
122120 .get (String .format ("%s/loki/api/v1/query_range" , lgtm .getLokiUrl ()))
123121 .prettyPeek ()
124122 .thenReturn ();
125- assertThat (response .getStatusCode ()).isEqualTo (200 );
126- assertThat (response .body ().jsonPath ().getString ("data.result[0].values[0][1]" ))
123+ assertThat (logResponse .getStatusCode ()).isEqualTo (200 );
124+ assertThat (logResponse .body ().jsonPath ().getString ("data.result[0].values[0][1]" ))
127125 .isEqualTo ("Test log!" );
128- });
129-
130- // Traces
131- Tracer tracer = openTelemetry .getTracer ("test" );
132- Span span = tracer .spanBuilder ("test" ).startSpan ();
133- span .end ();
134126
135- Awaitility
136- .given ()
137- .pollInterval (Duration .ofSeconds (2 ))
138- .atMost (Duration .ofSeconds (5 ))
139- .ignoreExceptions ()
140- .untilAsserted (() -> {
141- Response response = RestAssured
127+ Response traceResponse = RestAssured
142128 .given ()
143129 .get (String .format ("%s/api/search" , lgtm .getTempoUrl ()))
144130 .prettyPeek ()
145131 .thenReturn ();
146- assertThat (response .getStatusCode ()).isEqualTo (200 );
147- assertThat (response .body ().jsonPath ().getString ("traces[0].rootServiceName" ))
132+ assertThat (traceResponse .getStatusCode ()).isEqualTo (200 );
133+ assertThat (traceResponse .body ().jsonPath ().getString ("traces[0].rootServiceName" ))
148134 .isEqualTo ("test-service" );
149135 });
150136
0 commit comments