Skip to content

Commit da92198

Browse files
committed
Use ConfigHelper.env() instead of System.getenv()
System.getenv() is forbidden by the project's forbiddenApis rules. Replace with ConfigHelper.env() which is the approved way to read environment variables. Add config-utils as compileOnly dependency.
1 parent 18c0441 commit da92198

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

products/feature-flagging/feature-flagging-api/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ dependencies {
4444
api("dev.openfeature:sdk:1.20.1")
4545

4646
compileOnly(project(":products:feature-flagging:feature-flagging-bootstrap"))
47+
compileOnly(project(":utils:config-utils"))
4748
compileOnly("io.opentelemetry:opentelemetry-api:1.47.0")
4849
compileOnly("io.opentelemetry:opentelemetry-sdk-metrics:1.47.0")
4950
compileOnly("io.opentelemetry:opentelemetry-exporter-otlp:1.47.0")

products/feature-flagging/feature-flagging-api/src/main/java/datadog/trace/api/openfeature/FlagEvalMetrics.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package datadog.trace.api.openfeature;
22

3+
import datadog.trace.config.inversion.ConfigHelper;
34
import dev.openfeature.sdk.ErrorCode;
45
import io.opentelemetry.api.common.AttributeKey;
56
import io.opentelemetry.api.common.Attributes;
@@ -43,9 +44,9 @@ class FlagEvalMetrics implements Closeable {
4344

4445
FlagEvalMetrics() {
4546
try {
46-
String endpoint = System.getenv(ENDPOINT_ENV);
47+
String endpoint = ConfigHelper.env(ENDPOINT_ENV);
4748
if (endpoint == null || endpoint.isEmpty()) {
48-
String base = System.getenv(ENDPOINT_GENERIC_ENV);
49+
String base = ConfigHelper.env(ENDPOINT_GENERIC_ENV);
4950
if (base != null && !base.isEmpty()) {
5051
endpoint = base.endsWith("/") ? base + "v1/metrics" : base + "/v1/metrics";
5152
} else {

0 commit comments

Comments
 (0)