Skip to content

Commit

Permalink
Merge pull request #43625 from alesj/otel_protocol1
Browse files Browse the repository at this point in the history
Fix how OTLP protocol and port are used in LGTM, upgrade LGTM image version
  • Loading branch information
brunobat authored Oct 1, 2024
2 parents a4fcec1 + a98dad5 commit 7aa6f66
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ public final class ContainerConstants {

// Images

public static final String LGTM = "docker.io/grafana/otel-lgtm:0.6.0";
public static final String LGTM = "docker.io/grafana/otel-lgtm:0.7.5";

// Ports

public static final int GRAFANA_PORT = 3000;

public static final int OTEL_GRPC_EXPORTER_PORT = 4317;
public static final int OTEL_HTTP_EXPORTER_PORT = 4318;

public static final String OTEL_HTTP_PROTOCOL = "http/protobuf";
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,13 @@ public interface LgtmConfig extends GrafanaConfig {
@WithDefault("quarkus-dev-service-lgtm")
String label();

// this is duplicated for a reason - not all collectors speak grpc,
// which is the default in OTEL exporter,
// where we want http as a default with LGTM

/**
* The port on which LGTM's OTLP port will be exposed.
* The LGTM's OTLP protocol.
*/
@WithDefault("4318")
int otlpPort();
@WithDefault(ContainerConstants.OTEL_HTTP_PROTOCOL)
String otlpProtocol();
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public LgtmContainer() {

public LgtmContainer(LgtmConfig config) {
super(config);
addExposedPorts(config.otlpPort());
addExposedPorts(getOtlpPortInternal());
// cannot override grafana-dashboards.yaml in the container because it's on a version dependent path:
// ./grafana-v11.0.0/conf/provisioning/dashboards/grafana-dashboards.yaml
// will replace contents of current dashboards
Expand All @@ -59,8 +59,18 @@ public LgtmContainer(LgtmConfig config) {

}

public String getOtlpProtocol() {
return config.otlpProtocol();
}

public int getOtlpPort() {
return getMappedPort(config.otlpPort());
int port = getOtlpPortInternal();
return getMappedPort(port);
}

private int getOtlpPortInternal() {
return ContainerConstants.OTEL_HTTP_PROTOCOL.equals(getOtlpProtocol()) ? ContainerConstants.OTEL_HTTP_EXPORTER_PORT
: ContainerConstants.OTEL_GRPC_EXPORTER_PORT;
}

private String getPrometheusConfig() {
Expand All @@ -87,8 +97,8 @@ public Optional<Set<String>> networkAliases() {
}

@Override
public int otlpPort() {
return ContainerConstants.OTEL_HTTP_EXPORTER_PORT;
public String otlpProtocol() {
return ContainerConstants.OTEL_HTTP_PROTOCOL;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public Map<String, String> doStart() {
if (catalog != null && catalog.hasOpenTelemetry()) {
containerConfigs.put("quarkus.otel.exporter.otlp.endpoint",
String.format("http://%s:%s", host, container.getOtlpPort()));
containerConfigs.put("quarkus.otel.exporter.otlp.protocol", "http/protobuf");
containerConfigs.put("quarkus.otel.exporter.otlp.protocol", container.getOtlpProtocol());
}
if (catalog != null && catalog.hasMicrometerOtlp()) {
containerConfigs.put("quarkus.micrometer.export.otlp.url",
Expand Down

0 comments on commit 7aa6f66

Please sign in to comment.