Skip to content

Commit 4120f07

Browse files
committed
feat(config): Refactoring config into its own module
Using `utils` for now as it has `:dd-trace-api` as dependency so can't be considered as a `:component`.
1 parent 646403a commit 4120f07

File tree

48 files changed

+305
-236
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+305
-236
lines changed

dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/Agent.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
import static datadog.trace.util.AgentThreadFactory.AgentThread.PROFILER_STARTUP;
1515
import static datadog.trace.util.AgentThreadFactory.AgentThread.TRACE_STARTUP;
1616
import static datadog.trace.util.AgentThreadFactory.newAgentThread;
17-
import static datadog.trace.util.Strings.propertyNameToSystemPropertyName;
18-
import static datadog.trace.util.Strings.toEnvVar;
17+
import static datadog.trace.util.ConfigStrings.propertyNameToSystemPropertyName;
18+
import static datadog.trace.util.ConfigStrings.toEnvVar;
1919

2020
import datadog.environment.EnvironmentVariables;
2121
import datadog.environment.JavaVirtualMachine;

dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/ProcessHierarchy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import static datadog.trace.api.config.CiVisibilityConfig.CIVISIBILITY_SIGNAL_SERVER_HOST;
44
import static datadog.trace.api.config.CiVisibilityConfig.CIVISIBILITY_SIGNAL_SERVER_PORT;
55
import static datadog.trace.bootstrap.instrumentation.api.AgentPropagation.extractContextAndGetSpanContext;
6-
import static datadog.trace.util.Strings.propertyNameToSystemPropertyName;
6+
import static datadog.trace.util.ConfigStrings.propertyNameToSystemPropertyName;
77

88
import datadog.environment.SystemProperties;
99
import datadog.trace.bootstrap.instrumentation.api.AgentPropagation;

dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/buildsystem/BuildSystemModuleImpl.java

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import datadog.trace.civisibility.ipc.SignalType;
3232
import datadog.trace.civisibility.source.LinesResolver;
3333
import datadog.trace.civisibility.source.SourcePathResolver;
34-
import datadog.trace.util.Strings;
34+
import datadog.trace.util.ConfigStrings;
3535
import java.net.InetSocketAddress;
3636
import java.nio.file.Path;
3737
import java.util.Collection;
@@ -148,75 +148,76 @@ private Map<String, String> getPropertiesPropagatedToChildProcess(
148148
}
149149

150150
propagatedSystemProperties.put(
151-
Strings.propertyNameToSystemPropertyName(CiVisibilityConfig.CIVISIBILITY_ITR_ENABLED),
151+
ConfigStrings.propertyNameToSystemPropertyName(CiVisibilityConfig.CIVISIBILITY_ITR_ENABLED),
152152
Boolean.toString(executionSettings.isItrEnabled()));
153153

154154
propagatedSystemProperties.put(
155-
Strings.propertyNameToSystemPropertyName(
155+
ConfigStrings.propertyNameToSystemPropertyName(
156156
CiVisibilityConfig.CIVISIBILITY_CODE_COVERAGE_ENABLED),
157157
Boolean.toString(executionSettings.isCodeCoverageEnabled()));
158158

159159
propagatedSystemProperties.put(
160-
Strings.propertyNameToSystemPropertyName(
160+
ConfigStrings.propertyNameToSystemPropertyName(
161161
CiVisibilityConfig.CIVISIBILITY_TEST_SKIPPING_ENABLED),
162162
Boolean.toString(executionSettings.isTestSkippingEnabled()));
163163

164164
propagatedSystemProperties.put(
165-
Strings.propertyNameToSystemPropertyName(
165+
ConfigStrings.propertyNameToSystemPropertyName(
166166
CiVisibilityConfig.CIVISIBILITY_FLAKY_RETRY_ENABLED),
167167
Boolean.toString(executionSettings.isFlakyTestRetriesEnabled()));
168168

169169
propagatedSystemProperties.put(
170-
Strings.propertyNameToSystemPropertyName(
170+
ConfigStrings.propertyNameToSystemPropertyName(
171171
CiVisibilityConfig.CIVISIBILITY_IMPACTED_TESTS_DETECTION_ENABLED),
172172
Boolean.toString(executionSettings.isImpactedTestsDetectionEnabled()));
173173

174174
propagatedSystemProperties.put(
175-
Strings.propertyNameToSystemPropertyName(
175+
ConfigStrings.propertyNameToSystemPropertyName(
176176
CiVisibilityConfig.CIVISIBILITY_EARLY_FLAKE_DETECTION_ENABLED),
177177
Boolean.toString(executionSettings.getEarlyFlakeDetectionSettings().isEnabled()));
178178

179179
propagatedSystemProperties.put(
180-
Strings.propertyNameToSystemPropertyName(CiVisibilityConfig.TEST_MANAGEMENT_ENABLED),
180+
ConfigStrings.propertyNameToSystemPropertyName(CiVisibilityConfig.TEST_MANAGEMENT_ENABLED),
181181
Boolean.toString(executionSettings.getTestManagementSettings().isEnabled()));
182182

183183
// explicitly disable build instrumentation in child processes,
184184
// because some projects run "embedded" Maven/Gradle builds as part of their integration tests,
185185
// and we don't want to show those as if they were regular build executions
186186
propagatedSystemProperties.put(
187-
Strings.propertyNameToSystemPropertyName(
187+
ConfigStrings.propertyNameToSystemPropertyName(
188188
CiVisibilityConfig.CIVISIBILITY_BUILD_INSTRUMENTATION_ENABLED),
189189
Boolean.toString(false));
190190

191191
propagatedSystemProperties.put(
192-
Strings.propertyNameToSystemPropertyName(
192+
ConfigStrings.propertyNameToSystemPropertyName(
193193
CiVisibilityConfig.CIVISIBILITY_INJECTED_TRACER_VERSION),
194194
TracerVersion.TRACER_VERSION);
195195

196196
propagatedSystemProperties.put(
197-
Strings.propertyNameToSystemPropertyName(GeneralConfig.SERVICE_NAME), serviceName);
197+
ConfigStrings.propertyNameToSystemPropertyName(GeneralConfig.SERVICE_NAME), serviceName);
198198
propagatedSystemProperties.put(
199-
Strings.propertyNameToSystemPropertyName(GeneralConfig.SERVICE_NAME_SET_BY_USER),
199+
ConfigStrings.propertyNameToSystemPropertyName(GeneralConfig.SERVICE_NAME_SET_BY_USER),
200200
String.valueOf(userProvidedServiceName));
201201
propagatedSystemProperties.put(
202-
Strings.propertyNameToSystemPropertyName(CiVisibilityConfig.CIVISIBILITY_MODULE_NAME),
202+
ConfigStrings.propertyNameToSystemPropertyName(CiVisibilityConfig.CIVISIBILITY_MODULE_NAME),
203203
moduleName);
204204
propagatedSystemProperties.put(
205-
Strings.propertyNameToSystemPropertyName(CiVisibilityConfig.CIVISIBILITY_TEST_COMMAND),
205+
ConfigStrings.propertyNameToSystemPropertyName(
206+
CiVisibilityConfig.CIVISIBILITY_TEST_COMMAND),
206207
startCommand);
207208

208209
propagatedSystemProperties.put(
209-
Strings.propertyNameToSystemPropertyName(
210+
ConfigStrings.propertyNameToSystemPropertyName(
210211
CiVisibilityConfig.CIVISIBILITY_SIGNAL_SERVER_HOST),
211212
signalServerAddress != null ? signalServerAddress.getHostName() : null);
212213
propagatedSystemProperties.put(
213-
Strings.propertyNameToSystemPropertyName(
214+
ConfigStrings.propertyNameToSystemPropertyName(
214215
CiVisibilityConfig.CIVISIBILITY_SIGNAL_SERVER_PORT),
215216
String.valueOf(signalServerAddress != null ? signalServerAddress.getPort() : 0));
216217

217218
List<String> coverageIncludedPackages = sessionSettings.getCoverageIncludedPackages();
218219
propagatedSystemProperties.put(
219-
Strings.propertyNameToSystemPropertyName(
220+
ConfigStrings.propertyNameToSystemPropertyName(
220221
CiVisibilityConfig.CIVISIBILITY_CODE_COVERAGE_INCLUDES),
221222
String.join(":", coverageIncludedPackages));
222223

@@ -229,7 +230,7 @@ private Map<String, String> getPropertiesPropagatedToChildProcess(
229230
// This setting is only relevant if per-test code coverage is enabled,
230231
// otherwise it has no effect.
231232
propagatedSystemProperties.put(
232-
Strings.propertyNameToSystemPropertyName(
233+
ConfigStrings.propertyNameToSystemPropertyName(
233234
CiVisibilityConfig.CIVISIBILITY_CODE_COVERAGE_LINES_ENABLED),
234235
Boolean.toString(true));
235236
}

dd-java-agent/agent-ci-visibility/src/test/groovy/datadog/trace/civisibility/ci/CITagsProviderTest.groovy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import datadog.trace.civisibility.ci.env.CiEnvironmentImpl
88
import datadog.trace.civisibility.git.CILocalGitInfoBuilder
99
import datadog.trace.civisibility.git.CIProviderGitInfoBuilder
1010
import datadog.trace.civisibility.git.tree.GitClient
11-
import datadog.trace.util.Strings
11+
import datadog.trace.util.ConfigStrings
1212
import org.junit.Rule
1313
import org.junit.contrib.java.lang.system.EnvironmentVariables
1414
import org.junit.contrib.java.lang.system.RestoreSystemProperties
@@ -70,7 +70,7 @@ abstract class CITagsProviderTest extends Specification {
7070
environmentVariables.set(it.key, it.value)
7171
}
7272

73-
environmentVariables.set(Strings.propertyNameToEnvironmentVariableName(UserSuppliedGitInfoBuilder.DD_GIT_COMMIT_SHA), "1234567890123456789012345678901234567890")
73+
environmentVariables.set(ConfigStrings.propertyNameToEnvironmentVariableName(UserSuppliedGitInfoBuilder.DD_GIT_COMMIT_SHA), "1234567890123456789012345678901234567890")
7474

7575
when:
7676
CIProviderInfoFactory ciProviderInfoFactory = new CIProviderInfoFactory(Config.get(), GIT_FOLDER_FOR_TESTS, new CiEnvironmentImpl(System.getenv()))
@@ -89,7 +89,7 @@ abstract class CITagsProviderTest extends Specification {
8989
environmentVariables.set(it.key, it.value)
9090
}
9191

92-
environmentVariables.set(Strings.propertyNameToEnvironmentVariableName(UserSuppliedGitInfoBuilder.DD_GIT_REPOSITORY_URL), "local supplied repo url")
92+
environmentVariables.set(ConfigStrings.propertyNameToEnvironmentVariableName(UserSuppliedGitInfoBuilder.DD_GIT_REPOSITORY_URL), "local supplied repo url")
9393

9494
when:
9595
CIProviderInfoFactory ciProviderInfoFactory = new CIProviderInfoFactory(Config.get(), GIT_FOLDER_FOR_TESTS, new CiEnvironmentImpl(System.getenv()))

dd-java-agent/instrumentation/gradle-3.0/src/main/groovy/datadog/trace/instrumentation/gradle/legacy/GradleProjectConfigurator.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import datadog.trace.api.Config
44
import datadog.trace.api.civisibility.domain.BuildSessionSettings
55
import datadog.trace.api.config.CiVisibilityConfig
66
import datadog.trace.bootstrap.DatadogClassLoader
7+
import datadog.trace.util.ConfigStrings
78
import datadog.trace.util.Strings
89
import org.gradle.api.Project
910
import org.gradle.api.Task
@@ -73,7 +74,7 @@ class GradleProjectConfigurator {
7374
}
7475

7576
String taskPath = task.getPath()
76-
jvmArgs.add("-D" + Strings.propertyNameToSystemPropertyName(CiVisibilityConfig.CIVISIBILITY_MODULE_NAME) + '=' + taskPath)
77+
jvmArgs.add("-D" + ConfigStrings.propertyNameToSystemPropertyName(CiVisibilityConfig.CIVISIBILITY_MODULE_NAME) + '=' + taskPath)
7778

7879
jvmArgs.add("-javaagent:" + config.ciVisibilityAgentJarFile.toPath())
7980

dd-java-agent/instrumentation/gradle-8.3/src/main/groovy/datadog/trace/instrumentation/gradle/GradleDaemonInjectionUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package datadog.trace.instrumentation.gradle;
22

33
import static datadog.trace.api.config.CiVisibilityConfig.CIVISIBILITY_INJECTED_TRACER_VERSION;
4-
import static datadog.trace.util.Strings.propertyNameToSystemPropertyName;
4+
import static datadog.trace.util.ConfigStrings.propertyNameToSystemPropertyName;
55

66
import datadog.environment.SystemProperties;
77
import datadog.trace.api.Config;

dd-java-agent/testing/src/main/groovy/datadog/trace/agent/test/AgentTestRunner.groovy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ import datadog.trace.api.TraceConfig
3333
import datadog.trace.api.WellKnownTags
3434
import datadog.trace.api.config.GeneralConfig
3535
import datadog.trace.api.config.TracerConfig
36+
import datadog.trace.api.datastreams.AgentDataStreamsMonitoring
3637
import datadog.trace.api.gateway.RequestContext
3738
import datadog.trace.api.internal.TraceSegment
3839
import datadog.trace.api.sampling.SamplingRule
3940
import datadog.trace.api.time.SystemTimeSource
40-
import datadog.trace.api.datastreams.AgentDataStreamsMonitoring
4141
import datadog.trace.bootstrap.ActiveSubsystems
4242
import datadog.trace.bootstrap.CallDepthThreadLocalMap
4343
import datadog.trace.bootstrap.InstrumentationErrors
@@ -55,7 +55,7 @@ import datadog.trace.core.PendingTrace
5555
import datadog.trace.core.datastreams.DefaultDataStreamsMonitoring
5656
import datadog.trace.test.util.DDSpecification
5757
import datadog.trace.util.AgentTaskScheduler
58-
import datadog.trace.util.Strings
58+
import datadog.trace.util.ConfigStrings
5959
import de.thetaphi.forbiddenapis.SuppressForbidden
6060
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings
6161
import groovy.transform.stc.ClosureParams
@@ -121,7 +121,7 @@ abstract class AgentTestRunner extends DDSpecification implements AgentBuilder.L
121121
StringBuilder ddEnvVars = new StringBuilder()
122122
for (Map.Entry<Object, Object> entry : System.getProperties().entrySet()) {
123123
if (entry.getKey().toString().startsWith("dd.")) {
124-
ddEnvVars.append(Strings.systemPropertyNameToEnvironmentVariableName(entry.getKey().toString()))
124+
ddEnvVars.append(ConfigStrings.systemPropertyNameToEnvironmentVariableName(entry.getKey().toString()))
125125
.append("=").append(entry.getValue()).append(",")
126126
}
127127
}

dd-smoke-tests/gradle/src/test/groovy/datadog/smoketest/GradleDaemonSmokeTest.groovy

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import datadog.trace.api.Config
55
import datadog.trace.api.config.CiVisibilityConfig
66
import datadog.trace.api.config.GeneralConfig
77
import datadog.trace.api.config.TraceInstrumentationConfig
8-
import datadog.trace.util.Strings
8+
import datadog.trace.util.ConfigStrings
99
import org.gradle.testkit.runner.BuildResult
1010
import org.gradle.testkit.runner.GradleRunner
1111
import org.gradle.testkit.runner.TaskOutcome
@@ -168,15 +168,15 @@ class GradleDaemonSmokeTest extends AbstractGradleTest {
168168
(System.getenv("DD_CIVISIBILITY_SMOKETEST_DEBUG_PARENT") != null ? "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005 " : "") +
169169
"-javaagent:${agentShadowJar}=" +
170170
// for convenience when debugging locally
171-
(System.getenv("DD_CIVISIBILITY_SMOKETEST_DEBUG_CHILD") != null ? "${Strings.propertyNameToSystemPropertyName(CiVisibilityConfig.CIVISIBILITY_DEBUG_PORT)}=5055," : "") +
172-
"${Strings.propertyNameToSystemPropertyName(GeneralConfig.TRACE_DEBUG)}=true," +
173-
"${Strings.propertyNameToSystemPropertyName(GeneralConfig.ENV)}=${TEST_ENVIRONMENT_NAME}," +
174-
"${Strings.propertyNameToSystemPropertyName(GeneralConfig.SERVICE_NAME)}=${TEST_SERVICE_NAME}," +
175-
"${Strings.propertyNameToSystemPropertyName(GeneralConfig.API_KEY_FILE)}=${ddApiKeyPath.toAbsolutePath().toString()}," +
176-
"${Strings.propertyNameToSystemPropertyName(CiVisibilityConfig.CIVISIBILITY_ENABLED)}=true," +
177-
"${Strings.propertyNameToSystemPropertyName(CiVisibilityConfig.CIVISIBILITY_AGENTLESS_ENABLED)}=true," +
178-
"${Strings.propertyNameToSystemPropertyName(CiVisibilityConfig.CIVISIBILITY_GIT_UPLOAD_ENABLED)}=false," +
179-
"${Strings.propertyNameToSystemPropertyName(CiVisibilityConfig.CIVISIBILITY_CIPROVIDER_INTEGRATION_ENABLED)}=false," +
171+
(System.getenv("DD_CIVISIBILITY_SMOKETEST_DEBUG_CHILD") != null ? "${ConfigStrings.propertyNameToSystemPropertyName(CiVisibilityConfig.CIVISIBILITY_DEBUG_PORT)}=5055," : "") +
172+
"${ConfigStrings.propertyNameToSystemPropertyName(GeneralConfig.TRACE_DEBUG)}=true," +
173+
"${ConfigStrings.propertyNameToSystemPropertyName(GeneralConfig.ENV)}=${TEST_ENVIRONMENT_NAME}," +
174+
"${ConfigStrings.propertyNameToSystemPropertyName(GeneralConfig.SERVICE_NAME)}=${TEST_SERVICE_NAME}," +
175+
"${ConfigStrings.propertyNameToSystemPropertyName(GeneralConfig.API_KEY_FILE)}=${ddApiKeyPath.toAbsolutePath().toString()}," +
176+
"${ConfigStrings.propertyNameToSystemPropertyName(CiVisibilityConfig.CIVISIBILITY_ENABLED)}=true," +
177+
"${ConfigStrings.propertyNameToSystemPropertyName(CiVisibilityConfig.CIVISIBILITY_AGENTLESS_ENABLED)}=true," +
178+
"${ConfigStrings.propertyNameToSystemPropertyName(CiVisibilityConfig.CIVISIBILITY_GIT_UPLOAD_ENABLED)}=false," +
179+
"${ConfigStrings.propertyNameToSystemPropertyName(CiVisibilityConfig.CIVISIBILITY_CIPROVIDER_INTEGRATION_ENABLED)}=false," +
180180
/*
181181
* Some of the smoke tests (in particular the one with the Gradle plugin), are using Gradle Test Kit for their tests.
182182
* Gradle Test Kit needs to do a "chmod" when starting a Gradle Daemon.
@@ -186,9 +186,9 @@ class GradleDaemonSmokeTest extends AbstractGradleTest {
186186
* This causes the tests to fail because the number of reported traces is different.
187187
* To avoid this discrepancy between local and CI runs, we disable tracing instrumentations.
188188
*/
189-
"${Strings.propertyNameToSystemPropertyName(TraceInstrumentationConfig.TRACE_ENABLED)}=false," +
190-
"${Strings.propertyNameToSystemPropertyName(CiVisibilityConfig.CIVISIBILITY_JACOCO_PLUGIN_VERSION)}=$JACOCO_PLUGIN_VERSION," +
191-
"${Strings.propertyNameToSystemPropertyName(CiVisibilityConfig.CIVISIBILITY_AGENTLESS_URL)}=${mockBackend.intakeUrl}"
189+
"${ConfigStrings.propertyNameToSystemPropertyName(TraceInstrumentationConfig.TRACE_ENABLED)}=false," +
190+
"${ConfigStrings.propertyNameToSystemPropertyName(CiVisibilityConfig.CIVISIBILITY_JACOCO_PLUGIN_VERSION)}=$JACOCO_PLUGIN_VERSION," +
191+
"${ConfigStrings.propertyNameToSystemPropertyName(CiVisibilityConfig.CIVISIBILITY_AGENTLESS_URL)}=${mockBackend.intakeUrl}"
192192

193193
Files.write(testKitFolder.resolve("gradle.properties"), gradleProperties.getBytes())
194194
}

0 commit comments

Comments
 (0)