Skip to content

Commit

Permalink
Check OS for scraping host
Browse files Browse the repository at this point in the history
  • Loading branch information
alesj committed Feb 3, 2025
1 parent 4d42956 commit e8635a1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions extensions/observability-devservices/testcontainers/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
<name>Quarkus - Observability Dev Services - Testcontainers</name>

<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-devtools-utilities</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-devservices-common</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import io.quarkus.observability.common.config.AbstractGrafanaConfig;
import io.quarkus.observability.common.config.LgtmConfig;
import io.quarkus.runtime.LaunchMode;
import io.quarkus.utilities.OS;

public class LgtmContainer extends GrafanaContainer<LgtmContainer, LgtmConfig> {
protected static final String LGTM_NETWORK_ALIAS = "ltgm.testcontainer.docker";
Expand Down Expand Up @@ -177,8 +178,11 @@ private String getPrometheusConfig() {
Optional<Integer> optionalValue = runtimeConfig.getOptionalValue(httpPortKey, Integer.class);
int httpPort = optionalValue.orElse(isTest ? 8081 : 8080); // when not set use default

// try 'localhost' on Linux / CI ...
String host = OS.determineOS() == OS.LINUX ? "localhost" : "host.docker.internal";

prometheusConfig += String.format(PROMETHEUS_CONFIG_SCRAPE, config.serviceName(), rootPath, metricsPath, scraping,
"host.docker.internal", httpPort);
host, httpPort);
}
return prometheusConfig;
}
Expand Down

0 comments on commit e8635a1

Please sign in to comment.