Skip to content

Commit a20edf0

Browse files
authored
Merge branch 'mhlidd/migrate_config-utils_tests' into mhlidd/config_inversion_base
2 parents 89ee457 + 57483a2 commit a20edf0

File tree

152 files changed

+2624
-1691
lines changed

Some content is hidden

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

152 files changed

+2624
-1691
lines changed

.github/CODEOWNERS

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@
2828
/internal-api/src/test/groovy/datadog/trace/api/sampling @DataDog/apm-sdk-api-java
2929

3030
# @DataDog/apm-serverless
31-
/dd-trace-core/src/main/java/datadog/trace/lambda/ @DataDog/apm-serverless
32-
/dd-trace-core/src/test/groovy/datadog/trace/lambda/ @DataDog/apm-serverless
31+
/dd-trace-core/src/main/java/datadog/trace/lambda/ @DataDog/apm-serverless
32+
/dd-trace-core/src/test/groovy/datadog/trace/lambda/ @DataDog/apm-serverless
33+
**/InferredProxy*.java @DataDog/apm-serverless
34+
**/InferredProxy*.groovy @DataDog/apm-serverless
3335

3436
# @DataDog/apm-lang-platform-java
3537
/.circleci/ @DataDog/apm-lang-platform-java

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
GH_ADD_ARGS=""
4949
COUNT=0
5050
BRANCH_HEAD=$(git rev-parse HEAD)
51-
for lockfile in $(git status --porcelain=v1 | awk '{ print $NF }'); do
51+
for lockfile in $(git status --porcelain=v1 -- ':(glob)**/gradle.lockfile' | awk '{ print $NF }'); do
5252
echo "Found lockfile: $lockfile"
5353
GH_ADD_ARGS="$GH_ADD_ARGS --add $lockfile"
5454
COUNT=$((COUNT+1))

.gitlab/macrobenchmarks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,4 @@ notify-slo-breaches:
142142
when: never
143143
- when: always
144144
variables:
145-
CHANNEL: "apm-release-platform"
145+
CHANNEL: "apm-java"

boolean-conversion-proposal.md

Lines changed: 0 additions & 139 deletions
This file was deleted.

buildSrc/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ testing {
8989
val integTest by registering(JvmTestSuite::class) {
9090
dependencies {
9191
implementation(gradleTestKit())
92-
implementation("org.assertj:assertj-core:3.25.3")
9392
}
9493
// Makes the gradle plugin publish its declared plugins to this source set
9594
gradlePlugin.testSourceSet(sources)

buildSrc/src/integTest/kotlin/datadog/gradle/plugin/version/TracerVersionIntegrationTest.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
package datadog.gradle.plugin.version
22

3-
import org.assertj.core.api.Assertions.assertThat
43
import org.gradle.testkit.runner.GradleRunner
5-
import org.junit.jupiter.api.Disabled
4+
import org.junit.jupiter.api.Assertions.assertEquals
65
import org.junit.jupiter.api.Test
7-
import org.junit.jupiter.api.io.CleanupMode
86
import org.junit.jupiter.api.io.TempDir
97
import java.io.File
108
import java.io.IOException
@@ -289,7 +287,7 @@ class TracerVersionIntegrationTest {
289287
// .withDebug(true)
290288
.build()
291289

292-
assertThat(buildResult.output).isEqualToIgnoringNewLines(expectedVersion)
290+
assertEquals(expectedVersion, buildResult.output.lines().first())
293291
}
294292

295293
private fun exec(workingDirectory: File, vararg args: String) {

communication/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ dependencies {
2323

2424
testImplementation(project(":utils:test-utils"))
2525
testImplementation(libs.bundles.junit5)
26-
testImplementation(libs.truth)
2726
testImplementation(libs.bytebuddy)
2827
testImplementation("org.msgpack:msgpack-core:0.8.20")
2928
testImplementation("org.msgpack:jackson-dataformat-msgpack:0.8.20")

communication/gradle.lockfile

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,8 @@ com.github.spotbugs:spotbugs-annotations:4.2.0=compileClasspath,testCompileClass
3232
com.github.spotbugs:spotbugs-annotations:4.7.3=spotbugs
3333
com.github.spotbugs:spotbugs:4.7.3=spotbugs
3434
com.github.stefanbirkner:system-rules:1.19.0=testCompileClasspath,testRuntimeClasspath
35-
com.google.auto.value:auto-value-annotations:1.8.1=testCompileClasspath,testRuntimeClasspath
3635
com.google.code.findbugs:jsr305:3.0.2=compileClasspath,spotbugs,testCompileClasspath,testRuntimeClasspath
3736
com.google.code.gson:gson:2.9.1=spotbugs
38-
com.google.errorprone:error_prone_annotations:2.7.1=testCompileClasspath,testRuntimeClasspath
39-
com.google.guava:failureaccess:1.0.1=testCompileClasspath,testRuntimeClasspath
40-
com.google.guava:guava:30.1.1-android=testCompileClasspath,testRuntimeClasspath
41-
com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=testCompileClasspath,testRuntimeClasspath
42-
com.google.j2objc:j2objc-annotations:1.3=testCompileClasspath,testRuntimeClasspath
43-
com.google.truth:truth:1.1.3=testCompileClasspath,testRuntimeClasspath
4437
com.squareup.moshi:moshi:1.11.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
4538
com.squareup.okhttp3:mockwebserver:3.12.12=testCompileClasspath,testRuntimeClasspath
4639
com.squareup.okhttp3:okhttp:3.12.12=testCompileClasspath,testRuntimeClasspath
@@ -75,8 +68,6 @@ org.apache.httpcomponents.core5:httpcore5:5.1.3=spotbugs
7568
org.apache.logging.log4j:log4j-api:2.19.0=spotbugs
7669
org.apache.logging.log4j:log4j-core:2.19.0=spotbugs
7770
org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath
78-
org.checkerframework:checker-compat-qual:2.5.5=testCompileClasspath,testRuntimeClasspath
79-
org.checkerframework:checker-qual:3.13.0=testCompileClasspath,testRuntimeClasspath
8071
org.codehaus.groovy:groovy-all:3.0.24=testCompileClasspath,testRuntimeClasspath
8172
org.codehaus.groovy:groovy-ant:3.0.23=codenarc
8273
org.codehaus.groovy:groovy-ant:3.0.24=testCompileClasspath,testRuntimeClasspath
@@ -144,8 +135,7 @@ org.ow2.asm:asm-tree:9.8=jacocoAnt
144135
org.ow2.asm:asm-util:7.1=compileClasspath,testCompileClasspath
145136
org.ow2.asm:asm-util:9.2=runtimeClasspath,testRuntimeClasspath
146137
org.ow2.asm:asm-util:9.4=spotbugs
147-
org.ow2.asm:asm:7.1=compileClasspath
148-
org.ow2.asm:asm:9.1=testCompileClasspath
138+
org.ow2.asm:asm:7.1=compileClasspath,testCompileClasspath
149139
org.ow2.asm:asm:9.2=runtimeClasspath,testRuntimeClasspath
150140
org.ow2.asm:asm:9.4=spotbugs
151141
org.ow2.asm:asm:9.8=jacocoAnt
Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,34 @@
11
package datadog.communication.http
22

3-
import com.google.common.truth.Truth
43
import okhttp3.Request
5-
import org.junit.jupiter.api.Assertions
64
import org.junit.jupiter.api.Test
75

6+
import static org.junit.jupiter.api.Assertions.assertFalse
7+
import static org.junit.jupiter.api.Assertions.assertThrows
8+
import static org.junit.jupiter.api.Assertions.assertTrue
9+
810
class SafeRequestBuilderTest {
911
Request.Builder testBuilder = new Request.Builder()
1012

1113
@Test
1214
void "test adding bad header"() {
1315
def name = 'bad'
1416
def password = 'very-secret-password'
15-
IllegalArgumentException ex = Assertions.assertThrows(IllegalArgumentException, {
17+
IllegalArgumentException ex = assertThrows(IllegalArgumentException, {
1618
testBuilder.url("http:localhost").addHeader(name, "$password\n")
1719
})
18-
Truth.assertThat(ex).hasMessageThat().contains(name)
19-
Truth.assertThat(ex).hasMessageThat().doesNotContain(password)
20+
assertTrue(ex.getMessage().contains(name))
21+
assertFalse(ex.getMessage().contains(password))
2022
}
23+
2124
@Test
2225
void "test adding bad header2"(){
2326
def name = '\u0019'
2427
def password = 'very-secret-password'
25-
IllegalArgumentException ex = Assertions.assertThrows(IllegalArgumentException, {
28+
IllegalArgumentException ex = assertThrows(IllegalArgumentException, {
2629
testBuilder.url("http:localhost").addHeader(name, "\u0080$password")
2730
})
28-
Truth.assertThat(ex).hasMessageThat().contains(name)
29-
Truth.assertThat(ex).hasMessageThat().doesNotContain(password)
31+
assertTrue(ex.getMessage().contains(name))
32+
assertFalse(ex.getMessage().contains(password))
3033
}
3134
}

dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/decorator/HttpServerDecorator.java

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import datadog.trace.api.gateway.Flow;
2121
import datadog.trace.api.gateway.Flow.Action.RequestBlockingAction;
2222
import datadog.trace.api.gateway.IGSpanInfo;
23+
import datadog.trace.api.gateway.InferredProxySpan;
2324
import datadog.trace.api.gateway.RequestContext;
2425
import datadog.trace.api.gateway.RequestContextSlot;
2526
import datadog.trace.api.naming.SpanNaming;
@@ -147,21 +148,32 @@ public Context startSpan(REQUEST_CARRIER carrier, Context parentContext) {
147148
instrumentationNames != null && instrumentationNames.length > 0
148149
? instrumentationNames[0]
149150
: DEFAULT_INSTRUMENTATION_NAME;
150-
AgentSpanContext.Extracted extracted =
151-
callIGCallbackStart(getExtractedSpanContext(parentContext));
151+
AgentSpanContext extracted = getExtractedSpanContext(parentContext);
152+
// Call IG callbacks
153+
extracted = callIGCallbackStart(extracted);
154+
// Create gateway inferred span if needed
155+
extracted = startInferredProxySpan(parentContext, extracted);
152156
AgentSpan span =
153157
tracer().startSpan(instrumentationName, spanName(), extracted).setMeasured(true);
158+
// Apply RequestBlockingAction if any
154159
Flow<Void> flow = callIGCallbackRequestHeaders(span, carrier);
155160
if (flow.getAction() instanceof RequestBlockingAction) {
156161
span.setRequestBlockingAction((RequestBlockingAction) flow.getAction());
157162
}
158-
AgentPropagation.ContextVisitor<REQUEST_CARRIER> getter = getter();
159-
if (null != carrier && null != getter) {
160-
tracer().getDataStreamsMonitoring().setCheckpoint(span, forHttpServer());
161-
}
163+
// DSM Checkpoint
164+
tracer().getDataStreamsMonitoring().setCheckpoint(span, forHttpServer());
162165
return parentContext.with(span);
163166
}
164167

168+
protected AgentSpanContext startInferredProxySpan(Context context, AgentSpanContext extracted) {
169+
InferredProxySpan span;
170+
if (!Config.get().isInferredProxyPropagationEnabled()
171+
|| (span = InferredProxySpan.fromContext(context)) == null) {
172+
return extracted;
173+
}
174+
return span.start(extracted);
175+
}
176+
165177
public AgentSpan onRequest(
166178
final AgentSpan span,
167179
final CONNECTION connection,
@@ -390,8 +402,7 @@ public AgentSpan onResponse(final AgentSpan span, final RESPONSE response) {
390402
return span;
391403
}
392404

393-
private AgentSpanContext.Extracted callIGCallbackStart(
394-
@Nullable final AgentSpanContext.Extracted extracted) {
405+
private AgentSpanContext callIGCallbackStart(@Nullable final AgentSpanContext extracted) {
395406
AgentTracer.TracerAPI tracer = tracer();
396407
Supplier<Flow<Object>> startedCbAppSec =
397408
tracer.getCallbackProvider(RequestContextSlot.APPSEC).getCallback(EVENTS.requestStarted());
@@ -527,10 +538,20 @@ private Flow<Void> callIGCallbackURI(
527538

528539
@Override
529540
public AgentSpan beforeFinish(AgentSpan span) {
541+
// TODO Migrate beforeFinish to Context API
530542
onRequestEndForInstrumentationGateway(span);
543+
// Close Serverless Gateway Inferred Span if any
544+
// finishInferredProxySpan(context);
531545
return super.beforeFinish(span);
532546
}
533547

548+
protected void finishInferredProxySpan(Context context) {
549+
InferredProxySpan span;
550+
if ((span = InferredProxySpan.fromContext(context)) != null) {
551+
span.finish();
552+
}
553+
}
554+
534555
private void onRequestEndForInstrumentationGateway(@Nonnull final AgentSpan span) {
535556
if (span.getLocalRootSpan() != span) {
536557
return;

0 commit comments

Comments
 (0)