Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mongo async/reactivestreams client instrumentation #609

Merged
merged 12 commits into from
Jan 7, 2022
25 changes: 25 additions & 0 deletions instrumentation/mongodb-async-3.10/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
jar {
manifest {
attributes 'Implementation-Title': 'com.newrelic.instrumentation.mongodb-async-3.10'
}
}

dependencies {
implementation 'org.mongodb:mongodb-driver-async:3.10.0'
implementation(project(":agent-bridge"))
implementation(project(":agent-bridge-datastore"))
implementation(project(":newrelic-api"))
implementation(project(":newrelic-weaver-api"))
testImplementation("de.flapdoodle.embed:de.flapdoodle.embed.mongo:3.2.2")

}

verifyInstrumentation {
passesOnly 'org.mongodb:mongodb-driver-async:[3.10.0,3.11.0)'
excludeRegex 'org.mongodb:mongodb-driver-async:.*(alpha|beta|rc|SNAPSHOT).*'
}

site {
title 'MongoDB'
type 'Datastore'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
*
* * Copyright 2021 New Relic Corporation. All rights reserved.
* * SPDX-License-Identifier: Apache-2.0
*
*/

package com.mongodb.async.client;

import com.mongodb.ReadConcern;
import com.mongodb.ReadPreference;
import com.mongodb.WriteConcern;
import com.mongodb.client.model.AggregationLevel;
import com.mongodb.lang.Nullable;
import com.newrelic.api.agent.weaver.MatchType;
import com.newrelic.api.agent.weaver.Weave;
import com.nr.agent.mongo.MongoUtil;
import org.bson.codecs.configuration.CodecRegistry;
import org.bson.conversions.Bson;

import java.util.List;

@Weave(type = MatchType.ExactClass, originalName = "com/mongodb/async/client/AggregateIterableImpl")
abstract class AggregateIterableImpl_Instrumentation<TDocument, TResult> extends MongoIterableImpl_Instrumentation<TResult> {

AggregateIterableImpl_Instrumentation(@Nullable final ClientSession clientSession, final String databaseName, final Class<TDocument> documentClass,
final Class<TResult> resultClass, final CodecRegistry codecRegistry, final ReadPreference readPreference,
final ReadConcern readConcern, final WriteConcern writeConcern, final OperationExecutor executor,
final List<? extends Bson> pipeline, final AggregationLevel aggregationLevel) {
super(clientSession, executor, readConcern, readPreference);
super.collectionName = "";
super.databaseName = databaseName;
super.operationName = MongoUtil.OP_AGGREGATE;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
*
* * Copyright 2021 New Relic Corporation. All rights reserved.
* * SPDX-License-Identifier: Apache-2.0
*
*/

package com.mongodb.async.client;

import com.mongodb.MongoNamespace;
import com.mongodb.ReadConcern;
import com.mongodb.ReadPreference;
import com.mongodb.lang.Nullable;
import com.newrelic.api.agent.weaver.MatchType;
import com.newrelic.api.agent.weaver.Weave;
import com.nr.agent.mongo.MongoUtil;
import org.bson.codecs.configuration.CodecRegistry;
import org.bson.conversions.Bson;

@Weave(type = MatchType.ExactClass, originalName = "com/mongodb/async/client/DistinctIterableImpl")
abstract class DistinctIterableImpl_Instrumentation<TDocument, TResult> extends MongoIterableImpl_Instrumentation<TResult> {

DistinctIterableImpl_Instrumentation(@Nullable final ClientSession clientSession, final MongoNamespace namespace, final Class<TDocument> documentClass,
final Class<TResult> resultClass, final CodecRegistry codecRegistry, final ReadPreference readPreference,
final ReadConcern readConcern, final OperationExecutor executor, final String fieldName, final Bson filter) {
super(clientSession, executor, readConcern, readPreference);
super.collectionName = namespace.getCollectionName() + "-" + fieldName;
super.databaseName = namespace.getDatabaseName();
super.operationName = MongoUtil.OP_DISTINCT;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
*
* * 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.MatchType;
import org.bson.codecs.configuration.CodecRegistry;
import org.bson.conversions.Bson;

import com.mongodb.MongoNamespace;
import com.mongodb.ReadConcern;
import com.mongodb.ReadPreference;
import com.mongodb.lang.Nullable;
import com.newrelic.api.agent.weaver.Weave;
import com.nr.agent.mongo.MongoUtil;

@Weave(type = MatchType.ExactClass, originalName = "com/mongodb/async/client/FindIterableImpl")
abstract class FindIterableImpl_Instrumentation<TDocument, TResult> extends MongoIterableImpl_Instrumentation<TResult> {

FindIterableImpl_Instrumentation(@Nullable final ClientSession clientSession, final MongoNamespace namespace, final Class<TDocument> documentClass,
final Class<TResult> resultClass, final CodecRegistry codecRegistry, final ReadPreference readPreference,
final ReadConcern readConcern, final OperationExecutor executor, final Bson filter) {
super(clientSession, executor, readConcern, readPreference);
super.operationName = MongoUtil.OP_FIND;
super.collectionName = namespace.getCollectionName();
super.databaseName = namespace.getDatabaseName();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
*
* * Copyright 2021 New Relic Corporation. All rights reserved.
* * SPDX-License-Identifier: Apache-2.0
*
*/

package com.mongodb.async.client;

import com.mongodb.ReadConcern;
import com.mongodb.ReadPreference;
import com.mongodb.lang.Nullable;
import com.newrelic.api.agent.weaver.MatchType;
import com.newrelic.api.agent.weaver.Weave;
import com.nr.agent.mongo.MongoUtil;
import org.bson.codecs.configuration.CodecRegistry;

@Weave(type = MatchType.ExactClass, originalName = "com/mongodb/async/client/ListCollectionsIterableImpl")
abstract class ListCollectionsIterableImpl_Instrumentation<TResult> extends MongoIterableImpl_Instrumentation<TResult> {

ListCollectionsIterableImpl_Instrumentation(@Nullable final ClientSession clientSession, final String databaseName, final boolean collectionNamesOnly,
final Class<TResult> resultClass, final CodecRegistry codecRegistry, final ReadPreference readPreference,
final OperationExecutor executor) {
super(clientSession, executor, ReadConcern.DEFAULT, readPreference);
super.operationName = MongoUtil.OP_LIST_COLLECTIONS;
super.collectionName = "allCollections";
super.databaseName = databaseName;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
*
* * Copyright 2021 New Relic Corporation. All rights reserved.
* * SPDX-License-Identifier: Apache-2.0
*
*/

package com.mongodb.async.client;

import com.mongodb.ReadConcern;
import com.mongodb.ReadPreference;
import com.mongodb.lang.Nullable;
import com.newrelic.api.agent.weaver.MatchType;
import com.newrelic.api.agent.weaver.Weave;
import com.nr.agent.mongo.MongoUtil;
import org.bson.codecs.configuration.CodecRegistry;

@Weave(type = MatchType.ExactClass, originalName = "com/mongodb/async/client/ListDatabasesIterableImpl")
abstract class ListDatabasesIterableImpl_Instrumentation<TResult> extends MongoIterableImpl_Instrumentation<TResult> {

ListDatabasesIterableImpl_Instrumentation(@Nullable final ClientSession clientSession, final Class<TResult> resultClass,
final CodecRegistry codecRegistry, final ReadPreference readPreference,
final OperationExecutor executor) {
super(clientSession, executor, ReadConcern.DEFAULT, readPreference);
super.collectionName = "allDatabases";
super.databaseName = null;
super.operationName = MongoUtil.OP_LIST_DATABASES;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
*
* * Copyright 2021 New Relic Corporation. All rights reserved.
* * SPDX-License-Identifier: Apache-2.0
*
*/

package com.mongodb.async.client;

import com.mongodb.MongoNamespace;
import com.mongodb.ReadConcern;
import com.mongodb.ReadPreference;
import com.mongodb.lang.Nullable;
import com.newrelic.api.agent.weaver.MatchType;
import com.newrelic.api.agent.weaver.Weave;
import com.nr.agent.mongo.MongoUtil;
import org.bson.codecs.configuration.CodecRegistry;

@Weave(type = MatchType.ExactClass, originalName = "com/mongodb/async/client/ListIndexesIterableImpl")
abstract class ListIndexesIterableImpl_Instrumentation<TResult> extends MongoIterableImpl_Instrumentation<TResult> {

ListIndexesIterableImpl_Instrumentation(@Nullable final ClientSession clientSession, final MongoNamespace namespace, final Class<TResult> resultClass,
final CodecRegistry codecRegistry, final ReadPreference readPreference, final OperationExecutor executor) {
super(clientSession, executor, ReadConcern.DEFAULT, readPreference);
super.operationName = MongoUtil.OP_LIST_INDEXES;
super.collectionName = namespace.getCollectionName();
super.databaseName = namespace.getDatabaseName();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
*
* * Copyright 2021 New Relic Corporation. All rights reserved.
* * SPDX-License-Identifier: Apache-2.0
*
*/

package com.mongodb.async.client;

import com.mongodb.MongoNamespace;
import com.mongodb.ReadConcern;
import com.mongodb.ReadPreference;
import com.mongodb.WriteConcern;
import com.mongodb.lang.Nullable;
import com.newrelic.api.agent.weaver.MatchType;
import com.newrelic.api.agent.weaver.Weave;
import com.nr.agent.mongo.MongoUtil;
import org.bson.codecs.configuration.CodecRegistry;

@Weave(type = MatchType.ExactClass, originalName = "com/mongodb/async/client/MapReduceIterableImpl")
abstract class MapReduceIterableImpl_Instrumentation<TDocument, TResult> extends MongoIterableImpl_Instrumentation<TResult> {

MapReduceIterableImpl_Instrumentation(@Nullable final ClientSession clientSession, final MongoNamespace namespace, final Class<TDocument> documentClass,
final Class<TResult> resultClass, final CodecRegistry codecRegistry, final ReadPreference readPreference,
final ReadConcern readConcern, final WriteConcern writeConcern, final OperationExecutor executor,
final String mapFunction, final String reduceFunction) {
super(clientSession, executor, readConcern, readPreference);
super.collectionName = namespace.getCollectionName();
super.databaseName = namespace.getDatabaseName();
super.operationName = MongoUtil.OP_MAP_REDUCE;
}

}
Loading