Skip to content

Commit

Permalink
fix: disable metrics if endpoint not set (#3213)
Browse files Browse the repository at this point in the history
fixes: #3156
  • Loading branch information
stuartwdouglas authored Oct 28, 2024
1 parent 3277cee commit 9311f72
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
public class StaticConfigSource implements ConfigSource {

public static final String QUARKUS_BANNER_ENABLED = "quarkus.banner.enabled";
final static String OTEL_METRICS_ENABLED = "quarkus.otel.metrics.enabled";

@Override
public Set<String> getPropertyNames() {
Expand All @@ -16,13 +15,8 @@ public Set<String> getPropertyNames() {

@Override
public String getValue(String propertyName) {
switch (propertyName) {
case (QUARKUS_BANNER_ENABLED) -> {
return "false";
}
case OTEL_METRICS_ENABLED -> {
return "true";
}
if (propertyName.equals(QUARKUS_BANNER_ENABLED)) {
return "false";
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.nio.charset.StandardCharsets;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.regex.Matcher;
Expand All @@ -23,9 +24,11 @@ public class FTLConfigSource implements ConfigSource {
final static String HOST = "quarkus.http.host";

final static String FTL_BIND = "FTL_BIND";
private static final String OTEL_ENV_VAR = "OTEL_EXPORTER_OTLP_ENDPOINT";

final FTLController controller;

private static final String OTEL_METRICS_DISABLED = "quarkus.otel.sdk.disabled";
private static final String DEFAULT_USER = "quarkus.datasource.username";
private static final String DEFAULT_PASSWORD = "quarkus.datasource.password";
private static final String DEFAULT_URL = "quarkus.datasource.jdbc.url";
Expand Down Expand Up @@ -67,6 +70,12 @@ public int getOrdinal() {
@Override
public String getValue(String s) {
switch (s) {
case OTEL_METRICS_DISABLED -> {
var v = System.getenv(OTEL_ENV_VAR);
return Boolean
.toString(v == null || Objects.equals(v, "false") || Objects.equals(v, "0") || Objects.equals(v, "no")
|| Objects.equals(v, ""));
}
case SEPARATE_SERVER -> {
return "false";
}
Expand Down

0 comments on commit 9311f72

Please sign in to comment.