Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ public final class Constants {
*/
public static final String[] BOOTSTRAP_PACKAGE_PREFIXES = {
"datadog.slf4j",
"datadog.context",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a curiosity: are those in probability of match order? Otherwise we might tend to have them just ordered alphabetically. (It's not necessary to change)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually iterate over the array and use startWith() with the elements.
So order will matter yes. But is it currently the best order? I'm unsure.
@mcculls might be able to provide more context here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe this can be refactored as a trie (unsure what we have today handles package names) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the tries idea to the feedback collection stored in the JIRA card 👍

"datadog.environment",
"datadog.json",
"datadog.yaml",
"datadog.context",
"datadog.cli",
"datadog.appsec.api",
"datadog.trace.api",
Expand Down
4 changes: 3 additions & 1 deletion dd-java-agent/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,8 @@ tasks.withType(GenerateMavenPom).configureEach { task ->

dependencies {
implementation project(path: ':components:json')
implementation project(path: ':components:cli')
// Depend on the bootstrap-specific shadow configuration to avoid having the same component reused by both bootstrap and agent
implementation project(path: ':components:environment', configuration: 'shadow')
modules {
module("com.squareup.okio:okio") {
replacedBy("com.datadoghq.okio:okio") // embed our patched fork
Expand All @@ -270,6 +271,7 @@ dependencies {
testImplementation group: 'io.opentracing', name: 'opentracing-util', version: '0.31.0'

// Includes for the top level shadow jar
shadowInclude project(path: ':components:environment', configuration: 'shadow')
shadowInclude project(path: ':dd-java-agent:agent-bootstrap')
shadowInclude project(path: ':dd-java-agent:agent-debugger:debugger-bootstrap')
shadowInclude project(path: ':dd-java-agent:agent-otel:otel-bootstrap', configuration: 'shadow')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package datadog.trace.bootstrap;

import static datadog.trace.bootstrap.SystemUtils.getPropertyOrEnvVar;
import static java.nio.charset.StandardCharsets.UTF_8;

import datadog.cli.CLIHelper;
import datadog.trace.bootstrap.environment.EnvironmentVariables;
import datadog.trace.bootstrap.environment.JavaVirtualMachine;
import datadog.trace.bootstrap.environment.SystemProperties;
import de.thetaphi.forbiddenapis.SuppressForbidden;
import java.io.BufferedReader;
import java.io.File;
Expand Down Expand Up @@ -90,7 +91,7 @@ public static void agentmain(final String agentArgs, final Instrumentation inst)
}

private static BootstrapInitializationTelemetry createInitializationTelemetry() {
String forwarderPath = SystemUtils.tryGetEnv("DD_TELEMETRY_FORWARDER_PATH");
String forwarderPath = EnvironmentVariables.get("DD_TELEMETRY_FORWARDER_PATH");
if (forwarderPath == null) {
return BootstrapInitializationTelemetry.noOpInstance();
}
Expand All @@ -100,7 +101,7 @@ private static BootstrapInitializationTelemetry createInitializationTelemetry()
initTelemetry.initMetaInfo("runtime_name", "jvm");
initTelemetry.initMetaInfo("language_name", "jvm");

String javaVersion = SystemUtils.tryGetProperty("java.version");
String javaVersion = SystemProperties.get("java.version");
if (javaVersion != null) {
initTelemetry.initMetaInfo("runtime_version", javaVersion);
initTelemetry.initMetaInfo("language_version", javaVersion);
Expand Down Expand Up @@ -163,7 +164,12 @@ static boolean getConfig(String configName) {
return System.getenv(LIB_INJECTION_ENABLED_ENV_VAR) != null;
case LIB_INJECTION_FORCE_SYS_PROP:
{
String injectionForceFlag = getPropertyOrEnvVar(LIB_INJECTION_FORCE_SYS_PROP);
String envVarName =
LIB_INJECTION_FORCE_SYS_PROP.replace('.', '_').replace('-', '_').toUpperCase();
String injectionForceFlag = EnvironmentVariables.get(envVarName);
if (injectionForceFlag == null) {
injectionForceFlag = SystemProperties.get(LIB_INJECTION_FORCE_SYS_PROP);
}
return "true".equalsIgnoreCase(injectionForceFlag) || "1".equals(injectionForceFlag);
}
default:
Expand All @@ -172,7 +178,7 @@ static boolean getConfig(String configName) {
}

private static void recordInstrumentationSource(String source) {
SystemUtils.trySetProperty(LIB_INSTRUMENTATION_SOURCE_SYS_PROP, source);
SystemProperties.set(LIB_INSTRUMENTATION_SOURCE_SYS_PROP, source);
}

static boolean exceptionCauseChainContains(Throwable ex, String exClassName) {
Expand Down Expand Up @@ -200,7 +206,7 @@ private static boolean alreadyInitialized() {
}

private static boolean isJdkTool() {
String moduleMain = SystemUtils.tryGetProperty("jdk.module.main");
String moduleMain = SystemProperties.get("jdk.module.main");
if (null != moduleMain && !moduleMain.isEmpty() && moduleMain.charAt(0) == 'j') {
switch (moduleMain) {
case "java.base": // keytool
Expand Down Expand Up @@ -352,7 +358,7 @@ private static List<File> getAgentFilesFromVMArguments() {
// - On IBM-based JDKs since at least 1.7
// This prevents custom log managers from working correctly
// Use reflection to bypass the loading of the class~
for (final String argument : CLIHelper.getVmArgs()) {
for (final String argument : JavaVirtualMachine.getVmOptions()) {
if (argument.startsWith(JAVA_AGENT_ARGUMENT)) {
int index = argument.indexOf('=', JAVA_AGENT_ARGUMENT.length());
String agentPathname =
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ public class SpockRunner extends JUnitPlatform {
*/
public static final String[] BOOTSTRAP_PACKAGE_PREFIXES_COPY = {
"datadog.slf4j",
"datadog.context",
"datadog.environment",
"datadog.json",
"datadog.yaml",
"datadog.context",
"datadog.cli",
"datadog.appsec.api",
"datadog.trace.api",
Expand Down
1 change: 0 additions & 1 deletion gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ final class CachedData {
exclude(project(':components:environment'))
exclude(project(':components:json'))
exclude(project(':components:yaml'))
exclude(project(':components:cli'))
exclude(project(':remote-config:remote-config-api'))
exclude(project(':remote-config:remote-config-core'))
exclude(project(':telemetry'))
Expand Down