Skip to content

Commit 5adc301

Browse files
authored
Merge branch 'master' into jb/ni_profiler
2 parents 2829587 + 78be799 commit 5adc301

114 files changed

Lines changed: 1189 additions & 615 deletions

File tree

Some content is hidden

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

.github/workflows/add-release-to-cloudfoundry.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: Checkout "cloudfoundry" branch
13-
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # 6.0.1
13+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
1414
with:
1515
ref: cloudfoundry
1616
- name: Get release version

.github/workflows/analyze-changes.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616

1717
steps:
1818
- name: Checkout repository
19-
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # 6.0.1
19+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
2020
with:
2121
submodules: 'recursive'
2222
- name: Cache Gradle dependencies
@@ -30,7 +30,7 @@ jobs:
3030
${{ runner.os }}-gradle-
3131
3232
- name: Initialize CodeQL
33-
uses: github/codeql-action/init@cdefb33c0f6224e58673d9004f47f7cb3e328b89 # v4.31.10
33+
uses: github/codeql-action/init@b20883b0cd1f46c72ae0ba6d1090936928f9fa30 # v4.32.0
3434
with:
3535
languages: 'java'
3636
build-mode: 'manual'
@@ -49,7 +49,7 @@ jobs:
4949
--build-cache --parallel --stacktrace --no-daemon --max-workers=4
5050
5151
- name: Perform CodeQL Analysis and upload results to GitHub Security tab
52-
uses: github/codeql-action/analyze@cdefb33c0f6224e58673d9004f47f7cb3e328b89 # v4.31.10
52+
uses: github/codeql-action/analyze@b20883b0cd1f46c72ae0ba6d1090936928f9fa30 # v4.32.0
5353

5454
trivy:
5555
name: Analyze changes with Trivy
@@ -61,7 +61,7 @@ jobs:
6161

6262
steps:
6363
- name: Checkout repository
64-
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # 6.0.1
64+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
6565
with:
6666
submodules: 'recursive'
6767

@@ -114,7 +114,7 @@ jobs:
114114
TRIVY_JAVA_DB_REPOSITORY: ghcr.io/aquasecurity/trivy-java-db,public.ecr.aws/aquasecurity/trivy-java-db
115115

116116
- name: Upload Trivy scan results to GitHub Security tab
117-
uses: github/codeql-action/upload-sarif@cdefb33c0f6224e58673d9004f47f7cb3e328b89 # v4.31.10
117+
uses: github/codeql-action/upload-sarif@b20883b0cd1f46c72ae0ba6d1090936928f9fa30 # v4.32.0
118118
if: always()
119119
with:
120120
sarif_file: 'trivy-results.sarif'

.github/workflows/create-release-branch.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
echo "branch=release/${TAG%.0}.x" >> "$GITHUB_OUTPUT"
3939
4040
- name: Checkout dd-trace-java at tag
41-
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # 6.0.1
41+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
4242
with:
4343
ref: ${{ steps.determine-tag.outputs.tag }}
4444

.github/workflows/pin-system-tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
echo "base_branch=${BASE_BRANCH}" >> $GITHUB_OUTPUT
4646
4747
- name: Checkout the repository
48-
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
48+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
4949
with:
5050
ref: ${{ steps.define-base-branch.outputs.base_branch }}
5151

.github/workflows/run-system-tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
group: APM Larger Runners
2424
steps:
2525
- name: Checkout repository
26-
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # 6.0.1
26+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
2727
with:
2828
submodules: 'recursive'
2929
fetch-depth: 0

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
policy: self.update-docker-build-image.create-pr
2626

2727
- name: Checkout the repository
28-
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
28+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2929
- name: Define the Docker build image tag to use
3030
id: define-tag
3131
run: |

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
policy: self.update-gradle-dependencies.create-pr
2020

2121
- name: Checkout repository
22-
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # 6.0.1
22+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
2323
with:
2424
submodules: "recursive"
2525
- name: Update Gradle dependencies

.github/workflows/update-jmxfetch-submodule.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
policy: self.update-jmxfetch-submodule.create-pr
2020

2121
- name: Checkout repository
22-
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # 6.0.1
22+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
2323

2424
- name: Update Submodule
2525
run: |

dd-java-agent/agent-builder/src/main/java/datadog/trace/agent/tooling/AgentInstaller.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,8 @@ public static ClassFileTransformer installBytebuddyAgent(
182182
InstrumenterState.initialize(instrumenterIndex.instrumentationCount());
183183

184184
// combine known modules indexed at build-time with extensions contributed at run-time
185-
Iterable<InstrumenterModule> instrumenterModules = withExtensions(instrumenterIndex.modules());
185+
Iterable<InstrumenterModule> instrumenterModules =
186+
withExtensions(instrumenterIndex.modules(enabledSystems));
186187

187188
// This needs to be a separate loop through all instrumentations before we start adding
188189
// advice so that we can exclude field injection, since that will try to check exclusion
@@ -200,7 +201,7 @@ public static ClassFileTransformer installBytebuddyAgent(
200201
}
201202

202203
CombiningTransformerBuilder transformerBuilder =
203-
new CombiningTransformerBuilder(agentBuilder, instrumenterIndex);
204+
new CombiningTransformerBuilder(agentBuilder, instrumenterIndex, enabledSystems);
204205

205206
int installedCount = 0;
206207
for (InstrumenterModule module : instrumenterModules) {
@@ -295,7 +296,7 @@ public InstrumenterModule next() {
295296

296297
public static Set<InstrumenterModule.TargetSystem> getEnabledSystems() {
297298
EnumSet<InstrumenterModule.TargetSystem> enabledSystems =
298-
EnumSet.noneOf(InstrumenterModule.TargetSystem.class);
299+
EnumSet.of(InstrumenterModule.TargetSystem.CONTEXT_TRACKING);
299300
InstrumenterConfig cfg = InstrumenterConfig.get();
300301
if (cfg.isTraceEnabled()) {
301302
enabledSystems.add(InstrumenterModule.TargetSystem.TRACING);
@@ -309,6 +310,9 @@ public static Set<InstrumenterModule.TargetSystem> getEnabledSystems() {
309310
if (cfg.getIastActivation() != ProductActivation.FULLY_DISABLED) {
310311
enabledSystems.add(InstrumenterModule.TargetSystem.IAST);
311312
}
313+
if (cfg.isRaspEnabled()) {
314+
enabledSystems.add(InstrumenterModule.TargetSystem.RASP);
315+
}
312316
if (cfg.isCiVisibilityEnabled()) {
313317
enabledSystems.add(InstrumenterModule.TargetSystem.CIVISIBILITY);
314318
}

dd-java-agent/agent-builder/src/main/java/datadog/trace/agent/tooling/CombiningTransformerBuilder.java

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import java.util.HashMap;
2626
import java.util.List;
2727
import java.util.Map;
28+
import java.util.Set;
2829
import net.bytebuddy.agent.builder.AgentBuilder;
2930
import net.bytebuddy.asm.Advice;
3031
import net.bytebuddy.asm.AsmVisitorWrapper;
@@ -33,6 +34,8 @@
3334
import net.bytebuddy.dynamic.DynamicType;
3435
import net.bytebuddy.matcher.ElementMatcher;
3536
import net.bytebuddy.utility.JavaModule;
37+
import org.slf4j.Logger;
38+
import org.slf4j.LoggerFactory;
3639

3740
/**
3841
* Builds {@link InstrumenterModule}s into a single combining-matcher and splitting-transformer.
@@ -43,6 +46,8 @@
4346
public final class CombiningTransformerBuilder
4447
implements Instrumenter.TypeTransformer, Instrumenter.MethodTransformer {
4548

49+
private static final Logger log = LoggerFactory.getLogger(CombiningTransformerBuilder.class);
50+
4651
// Added here instead of byte-buddy's ignores because it's relatively
4752
// expensive. https://github.com/DataDog/dd-trace-java/pull/1045
4853
private static final ElementMatcher.Junction<TypeDescription> NOT_DECORATOR_MATCHER =
@@ -57,6 +62,7 @@ public final class CombiningTransformerBuilder
5762
private final AgentBuilder agentBuilder;
5863
private final InstrumenterIndex instrumenterIndex;
5964
private final int knownTransformationCount;
65+
private final Set<InstrumenterModule.TargetSystem> enabledSystems;
6066

6167
private final List<MatchRecorder> matchers = new ArrayList<>();
6268
private final BitSet knownTypesMask;
@@ -80,7 +86,9 @@ public final class CombiningTransformerBuilder
8086
private final List<AgentBuilder.Transformer> advice = new ArrayList<>();
8187

8288
public CombiningTransformerBuilder(
83-
AgentBuilder agentBuilder, InstrumenterIndex instrumenterIndex) {
89+
AgentBuilder agentBuilder,
90+
InstrumenterIndex instrumenterIndex,
91+
Set<InstrumenterModule.TargetSystem> enabledSystems) {
8492
this.agentBuilder = agentBuilder;
8593
this.instrumenterIndex = instrumenterIndex;
8694
int knownInstrumentationCount = instrumenterIndex.instrumentationCount();
@@ -89,6 +97,7 @@ public CombiningTransformerBuilder(
8997
this.transformers = new AdviceStack[knownTransformationCount];
9098
this.nextRuntimeInstrumentationId = knownInstrumentationCount;
9199
this.nextRuntimeTransformationId = knownTransformationCount;
100+
this.enabledSystems = enabledSystems;
92101
}
93102

94103
/** Builds matchers and transformers for an instrumentation module and its members. */
@@ -239,7 +248,26 @@ public void applyAdvice(Instrumenter.TransformingAdvice typeAdvice) {
239248
}
240249

241250
@Override
242-
public void applyAdvice(ElementMatcher<? super MethodDescription> matcher, String adviceClass) {
251+
public void applyAdvices(
252+
ElementMatcher<? super MethodDescription> matcher,
253+
String adviceClass,
254+
String... additionalAdviceClasses) {
255+
addAdviceIfEnabled(matcher, adviceClass);
256+
257+
if (additionalAdviceClasses != null) {
258+
for (String adviceClassName : additionalAdviceClasses) {
259+
addAdviceIfEnabled(matcher, adviceClassName);
260+
}
261+
}
262+
}
263+
264+
private void addAdviceIfEnabled(
265+
ElementMatcher<? super MethodDescription> matcher, String adviceClass) {
266+
if (!instrumenterIndex.isAdviceEnabled(adviceClass, enabledSystems)) {
267+
log.debug("Skipping advice class {} as it is not enabled", adviceClass);
268+
return;
269+
}
270+
log.debug("Installing advice class {}", adviceClass);
243271
Advice.WithCustomMapping customMapping = Advice.withCustomMapping();
244272
if (postProcessor != null) {
245273
customMapping = customMapping.with(postProcessor);

0 commit comments

Comments
 (0)