-
Notifications
You must be signed in to change notification settings - Fork 291
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6405 from DataDog/ban/patch-6358
[🍒 6358] MongoDB 4.10-11 instrumentation fix
- Loading branch information
Showing
14 changed files
with
170 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
apply from: "$rootDir/gradle/java.gradle" | ||
|
||
dependencies { | ||
testImplementation group: 'de.flapdoodle.embed', name: 'de.flapdoodle.embed.mongo', version: '4.5.1' | ||
testImplementation group: 'commons-io', name: 'commons-io', version: '2.11.0' | ||
testImplementation "org.testcontainers:mongodb:${versions.testcontainers}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
...tation/mongo/driver-4.0/src/main/java/datadog/trace/instrumentation/mongo/Arg2Advice.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package datadog.trace.instrumentation.mongo; | ||
|
||
import com.mongodb.internal.async.SingleResultCallback; | ||
import net.bytebuddy.asm.Advice; | ||
|
||
public class Arg2Advice { | ||
@Advice.OnMethodEnter(suppress = Throwable.class) | ||
public static void wrap( | ||
@Advice.Argument(value = 2, readOnly = false) SingleResultCallback<Object> callback) { | ||
callback = CallbackWrapper.wrapIfRequired(callback); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...-4.0/src/main/java/datadog/trace/instrumentation/mongo/BaseClusterInstrumentation410.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package datadog.trace.instrumentation.mongo; | ||
|
||
import static datadog.trace.agent.tooling.bytebuddy.matcher.NameMatchers.named; | ||
import static net.bytebuddy.matcher.ElementMatchers.isMethod; | ||
import static net.bytebuddy.matcher.ElementMatchers.takesArgument; | ||
|
||
import com.google.auto.service.AutoService; | ||
import datadog.trace.agent.tooling.Instrumenter; | ||
|
||
@AutoService(Instrumenter.class) | ||
public class BaseClusterInstrumentation410 extends Instrumenter.Tracing | ||
implements Instrumenter.ForSingleType { | ||
public BaseClusterInstrumentation410() { | ||
super("mongo", "mongo-reactivestreams"); | ||
} | ||
|
||
@Override | ||
public String instrumentedType() { | ||
return "com.mongodb.internal.connection.BaseCluster"; | ||
} | ||
|
||
@Override | ||
public String[] helperClassNames() { | ||
return new String[] {packageName + ".CallbackWrapper"}; | ||
} | ||
|
||
@Override | ||
public void adviceTransformations(AdviceTransformation transformation) { | ||
transformation.applyAdvice( | ||
isMethod() | ||
.and(named("selectServerAsync")) | ||
.and(takesArgument(2, named("com.mongodb.internal.async.SingleResultCallback"))), | ||
packageName + ".Arg2Advice"); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...ain/java/datadog/trace/instrumentation/mongo/DefaultConnectionPoolInstrumentation410.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package datadog.trace.instrumentation.mongo; | ||
|
||
import static datadog.trace.agent.tooling.bytebuddy.matcher.NameMatchers.named; | ||
import static net.bytebuddy.matcher.ElementMatchers.isMethod; | ||
import static net.bytebuddy.matcher.ElementMatchers.takesArgument; | ||
|
||
import com.google.auto.service.AutoService; | ||
import datadog.trace.agent.tooling.Instrumenter; | ||
|
||
@AutoService(Instrumenter.class) | ||
public class DefaultConnectionPoolInstrumentation410 extends Instrumenter.Tracing | ||
implements Instrumenter.ForSingleType { | ||
public DefaultConnectionPoolInstrumentation410() { | ||
super("mongo", "mongo-reactivestreams"); | ||
} | ||
|
||
@Override | ||
public String instrumentedType() { | ||
return "com.mongodb.internal.connection.DefaultConnectionPool"; | ||
} | ||
|
||
@Override | ||
public String[] helperClassNames() { | ||
return new String[] {packageName + ".CallbackWrapper"}; | ||
} | ||
|
||
@Override | ||
public void adviceTransformations(AdviceTransformation transformation) { | ||
transformation.applyAdvice( | ||
isMethod() | ||
.and(named("getAsync")) | ||
.and(takesArgument(1, named("com.mongodb.internal.async.SingleResultCallback"))), | ||
packageName + ".Arg1Advice"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.