Skip to content

Commit 9deb033

Browse files
Merge branch 'master' into alexeyk/debug-ci-timeout
2 parents d58d75b + 15176df commit 9deb033

File tree

38 files changed

+189
-99
lines changed

38 files changed

+189
-99
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
issuer: https://token.actions.githubusercontent.com
2+
3+
subject: repo:DataDog/dd-trace-java:ref:refs/heads/master
4+
5+
claim_pattern:
6+
event_name: (schedule|workflow_dispatch)
7+
ref: refs/heads/master
8+
ref_protected: "true"
9+
job_workflow_ref: DataDog/dd-trace-java/\.github/workflows/update-docker-build-image\.yaml@refs/heads/master
10+
11+
permissions:
12+
contents: write
13+
pull_requests: write
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
issuer: https://token.actions.githubusercontent.com
2+
3+
subject: repo:DataDog/dd-trace-java:ref:refs/heads/master
4+
5+
claim_pattern:
6+
event_name: (schedule|workflow_dispatch)
7+
ref: refs/heads/master
8+
ref_protected: "true"
9+
job_workflow_ref: DataDog/dd-trace-java/\.github/workflows/update-gradle-dependencies\.yaml@refs/heads/master
10+
11+
permissions:
12+
contents: write
13+
pull_requests: write

.github/workflows/update-docker-build-image.yaml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,27 @@ name: Update Docker Build Image
33
on:
44
schedule:
55
# A day after creating the tag from https://github.com/DataDog/dd-trace-java-docker-build/blob/master/.github/workflows/docker-tag.yml
6-
- cron: '0 0 1 2,5,8,11 *'
6+
- cron: "0 0 1 2,5,8,11 *"
77
workflow_dispatch:
88
inputs:
99
tag:
10-
description: 'The tag to use for the Docker build image'
10+
description: "The tag to use for the Docker build image"
1111
required: true
12-
default: 'vYY.MM'
13-
12+
default: "vYY.MM"
13+
1414
jobs:
1515
update-docker-build-image:
1616
runs-on: ubuntu-latest
1717
permissions:
18-
contents: write # Required to commit and push changes to a new branch
19-
pull-requests: write # Required to create a pull request
18+
contents: write # Required to create and push branch
19+
id-token: write # Required for OIDC token federation
2020
steps:
21+
- uses: DataDog/dd-octo-sts-action@acaa02eee7e3bb0839e4272dacb37b8f3b58ba80 # v1.0.3
22+
id: octo-sts
23+
with:
24+
scope: DataDog/dd-trace-java
25+
policy: self.update-docker-build-image.create-pr
26+
2127
- name: Checkout the repository
2228
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2329
- name: Download ghcommit CLI
@@ -55,12 +61,12 @@ jobs:
5561
sed -i '' -E 's|(BUILDER_IMAGE_VERSION_PREFIX:)[^#]*([#].*)|\1 "${{ steps.define-tag.outputs.tag }}-" \2|' .gitlab-ci.yml
5662
- name: Commit and push changes
5763
env:
58-
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
64+
GITHUB_TOKEN: ${{ steps.octo-sts.outputs.token }}
5965
run: |
6066
ghcommit --repository ${{ github.repository }} --branch ${{ steps.define-branch.outputs.branch }} --add .gitlab-ci.yml --message "feat(ci): Update Docker build image"
6167
- name: Create pull request
6268
env:
63-
GH_TOKEN: ${{ github.token }}
69+
GH_TOKEN: ${{ steps.octo-sts.outputs.token }}
6470
run: |
6571
gh pr create --title "Update Docker build image" \
6672
--base master \

.github/workflows/update-gradle-dependencies.yaml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
11
name: Update Gradle dependencies
22
on:
33
schedule:
4-
- cron: '0 4 * * 0'
4+
- cron: "0 4 * * 0"
55
workflow_dispatch:
66

77
jobs:
88
update-gradle-dependencies:
99
runs-on: ubuntu-latest
1010
name: Update Gradle dependencies
1111
permissions:
12-
contents: write # Required to commit and push changes to a new branch
13-
pull-requests: write # Required to create a pull request
12+
contents: write # Required to create new branch
13+
id-token: write # Required for OIDC token federation
1414
steps:
15+
- uses: DataDog/dd-octo-sts-action@acaa02eee7e3bb0839e4272dacb37b8f3b58ba80 # v1.0.3
16+
id: octo-sts
17+
with:
18+
scope: DataDog/dd-trace-java
19+
policy: self.update-gradle-dependencies.create-pr
20+
1521
- name: Checkout repository
1622
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
1723
with:
18-
submodules: 'recursive'
24+
submodules: "recursive"
1925
- name: Download ghcommit CLI
2026
run: |
2127
curl https://github.com/planetscale/ghcommit/releases/download/v0.1.48/ghcommit_linux_amd64 -o /usr/local/bin/ghcommit -L
@@ -37,7 +43,7 @@ jobs:
3743
./gradlew resolveAndLockAll --write-locks --parallel --stacktrace --no-daemon --max-workers=4
3844
- name: Commit changes
3945
env:
40-
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
46+
GITHUB_TOKEN: ${{ steps.octo-sts.outputs.token }}
4147
run: |
4248
GH_ADD_ARGS=""
4349
COUNT=0
@@ -69,7 +75,7 @@ jobs:
6975
fi
7076
- name: Create pull request
7177
env:
72-
GH_TOKEN: ${{ github.token }}
78+
GH_TOKEN: ${{ steps.octo-sts.outputs.token }}
7379
run: |
7480
# use echo to set a multiline body for the PR
7581
echo -e "This PR updates the Gradle dependencies. ⚠️ Don't forget to squash commits before merging. ⚠️\n\n- [ ] Update PR title if a code change is needed to support one of those new dependencies" | \

communication/src/main/java/datadog/communication/http/OkHttpUtils.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import datadog.common.container.ContainerInfo;
88
import datadog.common.socket.NamedPipeSocketFactory;
99
import datadog.common.socket.UnixDomainSocketFactory;
10+
import datadog.environment.SystemProperties;
1011
import datadog.trace.api.Config;
1112
import datadog.trace.util.AgentProxySelector;
1213
import java.io.File;
@@ -49,9 +50,12 @@ public final class OkHttpUtils {
4950

5051
private static final String DD_API_KEY = "DD-API-KEY";
5152

52-
private static final String JAVA_VERSION = System.getProperty("java.version", "unknown");
53-
private static final String JAVA_VM_NAME = System.getProperty("java.vm.name", "unknown");
54-
private static final String JAVA_VM_VENDOR = System.getProperty("java.vm.vendor", "unknown");
53+
private static final String JAVA_VERSION =
54+
SystemProperties.getOrDefault("java.version", "unknown");
55+
private static final String JAVA_VM_NAME =
56+
SystemProperties.getOrDefault("java.vm.name", "unknown");
57+
private static final String JAVA_VM_VENDOR =
58+
SystemProperties.getOrDefault("java.vm.vendor", "unknown");
5559

5660
public static OkHttpClient buildHttpClient(final HttpUrl url, final long timeoutMillis) {
5761
return buildHttpClient(url, null, null, timeoutMillis);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,17 +144,17 @@ private static GitClient.Factory buildGitClientFactory(
144144

145145
@Nonnull
146146
private static CiEnvironment buildCiEnvironment(Config config, SharedCommunicationObjects sco) {
147+
CiEnvironment localEnvironment = CiEnvironmentImpl.local();
147148
String remoteEnvVarsProviderUrl = config.getCiVisibilityRemoteEnvVarsProviderUrl();
148149
if (remoteEnvVarsProviderUrl != null) {
149150
String remoteEnvVarsProviderKey = config.getCiVisibilityRemoteEnvVarsProviderKey();
150151
CiEnvironment remoteEnvironment =
151152
new CiEnvironmentImpl(
152153
getRemoteEnvironment(
153154
remoteEnvVarsProviderUrl, remoteEnvVarsProviderKey, sco.okHttpClient));
154-
CiEnvironment localEnvironment = new CiEnvironmentImpl(System.getenv());
155155
return new CompositeCiEnvironment(remoteEnvironment, localEnvironment);
156156
} else {
157-
return new CiEnvironmentImpl(System.getenv());
157+
return localEnvironment;
158158
}
159159
}
160160

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

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package datadog.trace.civisibility;
22

3+
import static datadog.trace.api.config.CiVisibilityConfig.CIVISIBILITY_SIGNAL_SERVER_HOST;
4+
import static datadog.trace.api.config.CiVisibilityConfig.CIVISIBILITY_SIGNAL_SERVER_PORT;
35
import static datadog.trace.bootstrap.instrumentation.api.AgentPropagation.extractContextAndGetSpanContext;
6+
import static datadog.trace.util.Strings.propertyNameToSystemPropertyName;
47

5-
import datadog.trace.api.config.CiVisibilityConfig;
8+
import datadog.environment.SystemProperties;
69
import datadog.trace.bootstrap.instrumentation.api.AgentPropagation;
710
import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext;
8-
import datadog.trace.util.Strings;
911
import java.net.InetSocketAddress;
1012
import java.util.Properties;
1113
import javax.annotation.Nullable;
@@ -69,8 +71,8 @@ private boolean isWrapper() {
6971
}
7072

7173
private boolean isMavenParent() {
72-
return System.getProperty("maven.home") != null
73-
&& System.getProperty("classworlds.conf") != null
74+
return SystemProperties.get("maven.home") != null
75+
&& SystemProperties.get("classworlds.conf") != null
7476
// when using Maven Wrapper
7577
|| ClassLoader.getSystemClassLoader()
7678
.getResource("org/apache/maven/wrapper/WrapperExecutor.class")
@@ -82,7 +84,7 @@ private boolean isGradleDaemon() {
8284
.getResource("org/gradle/launcher/daemon/bootstrap/GradleDaemon.class")
8385
!= null
8486
// double-check this is not a Gradle Worker
85-
&& System.getProperties().getProperty("org.gradle.internal.worker.tmpdir") == null;
87+
&& SystemProperties.get("org.gradle.internal.worker.tmpdir") == null;
8688
}
8789

8890
private boolean isGradleLauncher() {
@@ -93,16 +95,12 @@ private boolean isGradleLauncher() {
9395

9496
@Nullable
9597
public InetSocketAddress getSignalServerAddress() {
96-
// System.getProperty is used rather than Config,
98+
// System properties are used rather than Config,
9799
// because system variables can be set after config was initialized
98100
String host =
99-
System.getProperty(
100-
Strings.propertyNameToSystemPropertyName(
101-
CiVisibilityConfig.CIVISIBILITY_SIGNAL_SERVER_HOST));
101+
SystemProperties.get(propertyNameToSystemPropertyName(CIVISIBILITY_SIGNAL_SERVER_HOST));
102102
String port =
103-
System.getProperty(
104-
Strings.propertyNameToSystemPropertyName(
105-
CiVisibilityConfig.CIVISIBILITY_SIGNAL_SERVER_PORT));
103+
SystemProperties.get(propertyNameToSystemPropertyName(CIVISIBILITY_SIGNAL_SERVER_PORT));
106104
if (host != null && port != null) {
107105
return new InetSocketAddress(host, Integer.parseInt(port));
108106
} else {

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package datadog.trace.civisibility.ci.env;
22

3+
import java.util.Collections;
34
import java.util.Map;
45

56
public class CiEnvironmentImpl implements CiEnvironment {
@@ -10,6 +11,16 @@ public CiEnvironmentImpl(Map<String, String> env) {
1011
this.env = env;
1112
}
1213

14+
public static CiEnvironment local() {
15+
Map<String, String> env;
16+
try {
17+
env = System.getenv();
18+
} catch (SecurityException e) {
19+
env = Collections.emptyMap();
20+
}
21+
return new CiEnvironmentImpl(env);
22+
}
23+
1324
@Override
1425
public String get(String name) {
1526
return env.get(name);

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,18 @@ private Map<String, String> getPropertiesPropagatedToChildProcess(
138138
ExecutionSettings executionSettings,
139139
BuildSessionSettings sessionSettings) {
140140
Map<String, String> propagatedSystemProperties = new HashMap<>();
141-
Properties systemProperties = System.getProperties();
142-
for (Map.Entry<Object, Object> e : systemProperties.entrySet()) {
143-
String propertyName = (String) e.getKey();
144-
Object propertyValue = e.getValue();
145-
if ((propertyName.startsWith(Config.PREFIX)
146-
|| propertyName.startsWith("datadog.slf4j.simpleLogger.defaultLogLevel"))
147-
&& propertyValue != null) {
148-
propagatedSystemProperties.put(propertyName, propertyValue.toString());
141+
try {
142+
Properties systemProperties = System.getProperties();
143+
for (Map.Entry<Object, Object> e : systemProperties.entrySet()) {
144+
String propertyName = (String) e.getKey();
145+
Object propertyValue = e.getValue();
146+
if ((propertyName.startsWith(Config.PREFIX)
147+
|| propertyName.startsWith("datadog.slf4j.simpleLogger.defaultLogLevel"))
148+
&& propertyValue != null) {
149+
propagatedSystemProperties.put(propertyName, propertyValue.toString());
150+
}
149151
}
152+
} catch (SecurityException ignored) {
150153
}
151154

152155
propagatedSystemProperties.put(

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package datadog.trace.civisibility.utils;
22

3+
import datadog.environment.SystemProperties;
34
import de.thetaphi.forbiddenapis.SuppressForbidden;
45
import java.io.IOException;
56
import java.nio.file.FileVisitResult;
@@ -77,7 +78,7 @@ public static String expandTilde(final String path) {
7778
return path;
7879
}
7980

80-
return path.replaceFirst("^~", System.getProperty("user.home"));
81+
return path.replaceFirst("^~", SystemProperties.getOrDefault("user.home", ""));
8182
}
8283

8384
public static String toRealPath(String path) {

0 commit comments

Comments
 (0)