4242@ Tag ("docker" )
4343class OTelCollectorIntegrationTest {
4444
45- // TODO: The OTel Prometheus exporter does not support openmetrics-text 1.0.0 yet
46- // see: https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/18913
47- private static final String OPENMETRICS_001 = "application/openmetrics-text; version=0.0.1; charset=utf-8" ;
45+ private static final String OPENMETRICS_TEXT = "application/openmetrics-text; version=1.0.0; charset=utf-8" ;
4846
4947 private static final String CONFIG_FILE_NAME = "collector-config.yml" ;
5048
@@ -55,8 +53,9 @@ class OTelCollectorIntegrationTest {
5553 private final GenericContainer <?> container = new GenericContainer (COLLECTOR_IMAGE )
5654 .withCommand ("--config=/etc/" + CONFIG_FILE_NAME )
5755 .withClasspathResourceMapping (CONFIG_FILE_NAME , "/etc/" + CONFIG_FILE_NAME , READ_ONLY )
56+ .withExposedPorts (4318 , 9090 ) // HTTP receiver, Prometheus exporter
5857 .waitingFor (Wait .forLogMessage (".*Everything is ready.*" , 1 ))
59- .withExposedPorts ( 4318 , 9090 ); // HTTP receiver, Prometheus exporter
58+ .waitingFor ( Wait . forListeningPorts ( 4318 ));
6059
6160 private static String getCollectorImageVersion () {
6261 String version = System .getProperty ("otel-collector-image.version" );
@@ -73,15 +72,15 @@ void collectorShouldExportMetrics() throws Exception {
7372 Counter .builder ("test.counter" ).register (registry ).increment (42 );
7473 Gauge .builder ("test.gauge" , () -> 12 ).register (registry );
7574 Timer .builder ("test.timer" ).register (registry ).record (Duration .ofMillis (123 ));
76- DistributionSummary .builder ("test.distributionsummary " ).register (registry ).record (24 );
75+ DistributionSummary .builder ("test.ds " ).register (registry ).record (24 );
7776
7877 // @formatter:off
7978 await ().atMost (Duration .ofSeconds (5 ))
8079 .pollDelay (Duration .ofMillis (100 ))
8180 .pollInterval (Duration .ofMillis (100 ))
8281 .untilAsserted (() -> whenPrometheusScraped ().then ()
8382 .statusCode (200 )
84- .contentType (OPENMETRICS_001 )
83+ .contentType (OPENMETRICS_TEXT )
8584 .body (endsWith ("# EOF\n " ), not (startsWith ("# EOF\n " )))
8685 );
8786
@@ -91,20 +90,29 @@ void collectorShouldExportMetrics() throws Exception {
9190 whenPrometheusScraped ().then ().body (
9291 containsString ("{job=\" test\" ,service_name=\" test\" ,telemetry_sdk_language=\" java\" ,telemetry_sdk_name=\" io.micrometer\" " ),
9392
93+ containsString ("# HELP test_counter \n " ),
94+ containsString ("# TYPE test_counter counter\n " ),
9495 matchesPattern ("(?s)^.*test_counter_total\\ {.+} 42\\ .0\\ n.*$" ),
96+
97+ containsString ("# HELP test_gauge \n " ),
98+ containsString ("# TYPE test_gauge gauge\n " ),
9599 matchesPattern ("(?s)^.*test_gauge\\ {.+} 12\\ .0\\ n.*$" ),
96100
101+ containsString ("# HELP test_timer_milliseconds \n " ),
102+ containsString ("# TYPE test_timer_milliseconds histogram\n " ),
97103 matchesPattern ("(?s)^.*test_timer_milliseconds_count\\ {.+} 1\\ n.*$" ),
98- // TODO: Earlier this was 123s (123), should have been 123ms (0.123)
104+ // Earlier this was 123s (123), should have been 123ms (0.123)
99105 // see: https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/18903
100106 // it seems units are still not converted but at least the unit is in the name now (breaking change)
101107 // see: https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/20519
102108 matchesPattern ("(?s)^.*test_timer_milliseconds_sum\\ {.+} 123\\ .0\\ n.*$" ),
103109 matchesPattern ("(?s)^.*test_timer_milliseconds_bucket\\ {.+,le=\" \\ +Inf\" } 1\\ n.*$" ),
104110
105- matchesPattern ("(?s)^.*test_distributionsummary_count\\ {.+} 1\\ n.*$" ),
106- matchesPattern ("(?s)^.*test_distributionsummary_sum\\ {.+} 24\\ .0\\ n.*$" ),
107- matchesPattern ("(?s)^.*test_distributionsummary_bucket\\ {.+,le=\" \\ +Inf\" } 1\\ n.*$" )
111+ containsString ("# HELP test_ds \n " ),
112+ containsString ("# TYPE test_ds histogram\n " ),
113+ matchesPattern ("(?s)^.*test_ds_count\\ {.+} 1\\ n.*$" ),
114+ matchesPattern ("(?s)^.*test_ds_sum\\ {.+} 24\\ .0\\ n.*$" ),
115+ matchesPattern ("(?s)^.*test_ds_bucket\\ {.+,le=\" \\ +Inf\" } 1\\ n.*$" )
108116 );
109117 // @formatter:on
110118 }
@@ -137,7 +145,7 @@ private Response whenPrometheusScraped() {
137145 // @formatter:off
138146 return given ()
139147 .port (container .getMappedPort (9090 ))
140- .accept (OPENMETRICS_001 )
148+ .accept (OPENMETRICS_TEXT )
141149 .when ()
142150 .get ("/metrics" );
143151 // @formatter:on
0 commit comments