Skip to content

Commit

Permalink
Merge pull request #476 from newrelic/fix-mongo-instrumentation
Browse files Browse the repository at this point in the history
Prevent mongodb instrumentation from applying to async/reactive clients
  • Loading branch information
jasonjkeller authored Oct 7, 2021
2 parents 1d9f49a + da8cb95 commit 41dfc24
Show file tree
Hide file tree
Showing 12 changed files with 114 additions and 4 deletions.
7 changes: 7 additions & 0 deletions instrumentation/mongodb-3.0/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ dependencies {

verifyInstrumentation {
passesOnly 'org.mongodb:mongo-java-driver:[3.0.0,3.1.0-rc0)'
// This instrumentation module shouldn't apply to the mongo async/reactive drivers
fails('org.mongodb:mongodb-driver-async:[3.0.0-rc0,)') {
compile("org.mongodb:mongo-java-driver:3.0.0")
}
fails('org.mongodb:mongodb-driver-reactivestreams:[1.0.0-rc0,)') {
compile("org.mongodb:mongo-java-driver:3.0.0")
}
}

site {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
*
* * Copyright 2021 New Relic Corporation. All rights reserved.
* * SPDX-License-Identifier: Apache-2.0
*
*/

package com.mongodb.async.client;

import com.newrelic.api.agent.weaver.SkipIfPresent;

// This instrumentation will cause Segment timeouts and incorrect metrics if it applies to the async driver
@SkipIfPresent
final class MongoClients {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
*
* * Copyright 2021 New Relic Corporation. All rights reserved.
* * SPDX-License-Identifier: Apache-2.0
*
*/

package com.mongodb.reactivestreams.client;

import com.newrelic.api.agent.weaver.SkipIfPresent;

// This instrumentation will cause Segment timeouts and incorrect metrics if it applies to the reactive driver
@SkipIfPresent
final class MongoClients {}
9 changes: 8 additions & 1 deletion instrumentation/mongodb-3.1/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@ dependencies {
}

verifyInstrumentation {
passesOnly 'org.mongodb:mongo-java-driver:[3.1.0-rc0,)'
passesOnly 'org.mongodb:mongo-java-driver:[3.1.0-rc0,3.7.0-rc0)'
// This instrumentation module shouldn't apply to the mongo async/reactive drivers
fails('org.mongodb:mongodb-driver-async:[3.0.0-rc0,)') {
compile("org.mongodb:mongo-java-driver:3.1.0")
}
fails('org.mongodb:mongodb-driver-reactivestreams:[1.0.0-rc0,)') {
compile("org.mongodb:mongo-java-driver:3.1.0")
}
}

site {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.mongodb;

import com.newrelic.api.agent.weaver.SkipIfPresent;

// Prevent this instrumentation module from applying when the mongodb-3.7 module does.
@SkipIfPresent
public final class MongoClientSettings {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
*
* * Copyright 2021 New Relic Corporation. All rights reserved.
* * SPDX-License-Identifier: Apache-2.0
*
*/

package com.mongodb.async.client;

import com.newrelic.api.agent.weaver.SkipIfPresent;

// This instrumentation will cause Segment timeouts and incorrect metrics if it applies to the async driver
@SkipIfPresent
final class MongoClients {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
*
* * Copyright 2020 New Relic Corporation. All rights reserved.
* * SPDX-License-Identifier: Apache-2.0
*
*/

package com.mongodb.async.client;

import com.newrelic.api.agent.weaver.SkipIfPresent;

// This instrumentation will cause Segment timeouts and incorrect metrics if it applies to the async driver
@SkipIfPresent
final class NettyMongoClients {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
*
* * Copyright 2021 New Relic Corporation. All rights reserved.
* * SPDX-License-Identifier: Apache-2.0
*
*/

package com.mongodb.reactivestreams.client;

import com.newrelic.api.agent.weaver.SkipIfPresent;

// This instrumentation will cause Segment timeouts and incorrect metrics if it applies to the reactive driver
@SkipIfPresent
final class MongoClients {}
6 changes: 5 additions & 1 deletion instrumentation/mongodb-3.7/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ dependencies {

verifyInstrumentation {
passesOnly 'org.mongodb:mongo-java-driver:[3.7.0-rc0,)'
fails('org.mongodb:mongodb-driver-async:[3.7.0-rc0,)') {
// This instrumentation module shouldn't apply to the mongo async/reactive drivers
fails('org.mongodb:mongodb-driver-async:[3.0.0-rc0,)') {
compile("org.mongodb:mongo-java-driver:3.7.0")
}
fails('org.mongodb:mongodb-driver-reactivestreams:[1.0.0-rc0,)') {
compile("org.mongodb:mongo-java-driver:3.7.0")
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
*
* * Copyright 2021 New Relic Corporation. All rights reserved.
* * SPDX-License-Identifier: Apache-2.0
*
*/

package com.mongodb.async.client;

import com.newrelic.api.agent.weaver.SkipIfPresent;

// This instrumentation will cause Segment timeouts and incorrect metrics if it applies to the async driver
@SkipIfPresent
final class MongoClients {}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@

import com.newrelic.api.agent.weaver.SkipIfPresent;

// This instrumentation will cause Segment timeouts if it applies to the async driver
// This instrumentation will cause Segment timeouts and incorrect metrics if it applies to the async driver
@SkipIfPresent
final class NettyMongoClients {}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@

import com.newrelic.api.agent.weaver.SkipIfPresent;

// This instrumentation will cause Segment timeouts if it applies to the reactive driver
// This instrumentation will cause Segment timeouts and incorrect metrics if it applies to the reactive driver
@SkipIfPresent
final class MongoClients {}

0 comments on commit 41dfc24

Please sign in to comment.