Skip to content

Commit cef9649

Browse files
authored
add support and test for mongodb 5.x (#4139)
* reuse 4.x instrumentation for 5.x * extend test for mongo driver versions * update supported technologies & changelog
1 parent d636a05 commit cef9649

File tree

5 files changed

+24
-6
lines changed

5 files changed

+24
-6
lines changed

CHANGELOG.next-release.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ This file contains all changes which are not released yet.
1010
# Fixes
1111
<!--FIXES-START-->
1212
* Prevent potential memory pressure by limiting OpenTelemetry metrics bridge attribute cache sizes - [#4123](https://github.com/elastic/apm-agent-java/pull/4123)
13-
* Fix `NoSuchMethodError` for Kafka 4136clients - [#4136](https://github.com/elastic/apm-agent-java/pull/4136)
13+
* Fix `NoSuchMethodError` for Kafka clients - [#4136](https://github.com/elastic/apm-agent-java/pull/4136)
1414
<!--FIXES-END-->
1515
# Features and enhancements
1616
<!--ENHANCEMENTS-START-->
17+
* Add support for Mongodb 5.x instrumentation - [#4139](https://github.com/elastic/apm-agent-java/pull/4139)
1718

1819
<!--ENHANCEMENTS-END-->
1920
# Deprecations

apm-agent-plugins/apm-mongodb/apm-mongodb-common/src/test/java/co/elastic/apm/agent/mongodb/AbstractMongoClientInstrumentationIT.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@
4343

4444
public abstract class AbstractMongoClientInstrumentationIT extends AbstractInstrumentationTest {
4545

46+
// needs to be updated from time to time as support for older versions is being removed in drivers:
47+
// - 3.6 support has been dropped in 5.2.0
48+
// - 4.0 support has been dropped in 5.5.0
49+
// see https://github.com/mongodb/mongo-java-driver/releases for updates on such changes
50+
private static final String MONGO_IMAGE = "mongo:4.4";
51+
4652
protected static GenericContainer<?> container;
4753
protected static final String DB_NAME = "testdb";
4854
protected static final String COLLECTION_NAME = "testcollection";
@@ -52,7 +58,7 @@ public abstract class AbstractMongoClientInstrumentationIT extends AbstractInstr
5258

5359
@BeforeClass
5460
public static void startContainer() {
55-
container = new GenericContainer<>("mongo:3.4")
61+
container = new GenericContainer<>(MONGO_IMAGE)
5662
.withExposedPorts(PORT)
5763
.withCreateContainerCmdModifier(TestContainersUtils.withMemoryLimit(2048));
5864
container.start();

apm-agent-plugins/apm-mongodb/apm-mongodb4-plugin/src/main/java/co/elastic/apm/agent/mongodb/v4/Mongo4Instrumentation.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ public abstract class Mongo4Instrumentation extends ElasticApmInstrumentation {
3232

3333
@Override
3434
public ElementMatcher.Junction<ProtectionDomain> getProtectionDomainPostFilter() {
35-
// only use this instrumentation for 4.x
36-
return implementationVersionGte("4").and(not(implementationVersionGte("5")));
35+
// only use this instrumentation for 4.x and 5.x
36+
return implementationVersionGte("4");
3737
}
3838

3939
@Override

apm-agent-plugins/apm-mongodb/apm-mongodb4-plugin/src/test/java/co/elastic/apm/agent/mongodb/v4/Mongo4VersionIT.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public Mongo4VersionIT(String version, boolean legacyDriver) throws Exception {
4444
"org.mongodb:mongodb-driver-core:" + version,
4545
"org.mongodb:bson:" + version));
4646

47-
if(legacyDriver){
47+
if (legacyDriver) {
4848
dependencies.add("org.mongodb:mongodb-driver-legacy:" + version);
4949
}
5050

@@ -63,6 +63,17 @@ public static Iterable<Object[]> data() {
6363
// driver are also explicitly included, over time the driver has moved to single monolithic jar to having more
6464
// and more dependencies instead of embedding them.
6565
List<String> versions = Arrays.asList(
66+
"5.5.0",
67+
"5.4.0",
68+
"5.3.0",
69+
"5.2.0",
70+
"5.1.0",
71+
"5.0.0",
72+
"4.11.0",
73+
"4.10.0",
74+
"4.9.0",
75+
"4.8.0",
76+
"4.7.0",
6677
"4.6.0",
6778
"4.5.0",
6879
"4.4.0",

docs/reference/supported-technologies.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ The Elastic APM Java agent has generic support for the Servlet API 3+. However,
114114
| Redis Lettuce | 3.4+ | The agent creates spans for interactions with the Lettuce client. | 1.13.0 |
115115
| Redis Redisson | 2.1.5+ | The agent creates spans for interactions with the Redisson client. | 1.15.0 |
116116
| MongoDB driver | 3.x | The agent creates spans for interactions with the MongoDB driver. At the moment, only the synchronous driver (mongo-java-driver) is supported. The asynchronous and reactive drivers are currently not supported.<br> The name of the span is `<db>.<collection>.<command>`. The actual query will not be recorded. | 1.12.0 |
117-
| MongoDB Sync Driver | 4.x | The agent creates spans for interactions with the MongoDB 4.x sync driver.This provides support for `org.mongodb:mongodb-driver-sync` | 1.34.0 |
117+
| MongoDB Sync Driver | 4.x, 5.x | The agent creates spans for interactions with the MongoDB 4.x and 5.x sync driver. This provides support for `org.mongodb:mongodb-driver-sync` | 1.34.0 |
118118
| Cassandra | 2.x+ | The agent creates spans for interactions with the Cassandra Datastax drivers.This provides support for `com.datastax.cassandra:cassandra-driver-core` and`com.datastax.oss:java-driver-core` | 1.23.0 |
119119
| AWS DynamoDB | 1.x, 2.x | The agent creates spans for interactions with the AWS DynamoDb service through the AWS Java SDK. | 1.31.0, 2.21+ since 1.44.0 |
120120
| AWS S3 | 1.x, 2.x | The agent creates spans for interactions with the AWS S3 service through the AWS Java SDK. | 1.31.0, 2.21+ since 1.44.0 |

0 commit comments

Comments
 (0)