Skip to content

Commit 0fb73ae

Browse files
committed
fix: Also track the stderr when verifying integrations
Multi-version integrations issues could be misreported as valid. InstrumenterIndex.buildModule() logs ERROR and returns null when a module fails to load, while the process exits 0. For integrations with multiple versioned modules sharing one name (akka-http, vertx, servlet...), if any of a versionned integration fails it's invisible. This commit changes that. In a clean run stderr is empty; any output indicates a module load failure and fails the task immediately.
1 parent f5d3e58 commit 0fb73ae

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

dd-java-agent/build.gradle

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,10 +594,21 @@ tasks.register('verifyAgentJarIntegrations', JavaExec) {
594594
classpath = objects.fileCollection().from(jarProvider)
595595
args = ['--list-integrations']
596596

597+
// Capture both stdout and stderr: InstrumenterIndex.buildModule() logs ERROR and returns null when a module
598+
// fails to load, while the process exits with status 0.
597599
def capturedOutput = new ByteArrayOutputStream()
600+
def capturedError = new ByteArrayOutputStream()
598601
standardOutput = capturedOutput
602+
errorOutput = capturedError
599603

600604
doLast {
605+
def stderr = capturedError.toString()
606+
if (!stderr.isBlank()) {
607+
throw new GradleException(
608+
"--list-integrations produced unexpected stderr output " +
609+
"(likely a module load failure; see InstrumenterIndex.buildModule):\n${stderr}")
610+
}
611+
601612
if (!integrationsGoldenFile.exists()) {
602613
throw new GradleException(
603614
"${integrationsGoldenFile.name} not found. " +
@@ -623,7 +634,7 @@ tasks.register('verifyAgentJarIntegrations', JavaExec) {
623634
}
624635
}
625636

626-
// Run after adding/removing integrations to update expected-integrations.txt, then commit the diff.
637+
// Manual run after adding/removing integrations to update expected-integrations.txt, then add with the new integration.
627638
tasks.register('updateAgentJarIntegrationsGolden', JavaExec) {
628639
group = LifecycleBasePlugin.VERIFICATION_GROUP
629640
description = 'Regenerate expected-integrations.txt from the current agent jar'

0 commit comments

Comments
 (0)