Search in sources :

Example 6 with DatastoreParameters

use of com.newrelic.api.agent.DatastoreParameters in project newrelic-java-agent by newrelic.

the class DB_Weave method instrument.

private void instrument(TracedMethod method, String operation, String collection, String serverUsed, int serverPortUsed) {
    DatastoreParameters params = DatastoreParameters.product(DatastoreVendor.MongoDB.name()).collection(collection).operation(operation).instance(serverUsed, serverPortUsed).databaseName(getName()).build();
    method.reportAsExternal(params);
}
Also used : DatastoreParameters(com.newrelic.api.agent.DatastoreParameters)

Example 7 with DatastoreParameters

use of com.newrelic.api.agent.DatastoreParameters in project newrelic-java-agent by newrelic.

the class DBCollection_Weave method instrument.

private void instrument(TracedMethod method, String operationName) {
    ServerAddress serverAddress = getDB().getMongo().getAddress();
    DatastoreParameters params = DatastoreParameters.product(DatastoreVendor.MongoDB.name()).collection(getNamespace().getCollectionName()).operation(operationName).instance(serverAddress.getHost(), serverAddress.getPort()).databaseName(getDB().getName()).build();
    NewRelic.getAgent().getTracedMethod().reportAsExternal(params);
}
Also used : DatastoreParameters(com.newrelic.api.agent.DatastoreParameters)

Example 8 with DatastoreParameters

use of com.newrelic.api.agent.DatastoreParameters in project newrelic-java-agent by newrelic.

the class MongoIterableImpl_Instrumentation method first.

@Trace
public void first(SingleResultCallback<TResult> callback) {
    if (!(callback instanceof NRCallbackWrapper)) {
        NRCallbackWrapper<TResult> wrapper = new NRCallbackWrapper<TResult>(callback);
        wrapper.token = NewRelic.getAgent().getTransaction().getToken();
        DatastoreParameters datastoreParameters;
        if (databaseName != null) {
            datastoreParameters = DatastoreParameters.product(DatastoreVendor.MongoDB.name()).collection(collectionName).operation(operationName).noInstance().databaseName(databaseName).build();
        } else {
            datastoreParameters = DatastoreParameters.product(DatastoreVendor.MongoDB.name()).collection(collectionName).operation(operationName).build();
        }
        wrapper.params = datastoreParameters;
        wrapper.segment = NewRelic.getAgent().getTransaction().startSegment(operationName);
        callback = wrapper;
    }
    Weaver.callOriginal();
}
Also used : DatastoreParameters(com.newrelic.api.agent.DatastoreParameters) NRCallbackWrapper(com.nr.agent.mongo.NRCallbackWrapper) Trace(com.newrelic.api.agent.Trace)

Example 9 with DatastoreParameters

use of com.newrelic.api.agent.DatastoreParameters in project newrelic-java-agent by newrelic.

the class Connection_Instrumentation method getMore.

@Trace(leaf = true)
public <T> QueryResult<T> getMore(MongoNamespace namespace, long cursorId, int numberToReturn, Decoder<T> resultDecoder) {
    DatastoreParameters params = DatastoreParameters.product(DatastoreVendor.MongoDB.name()).collection(namespace.getCollectionName()).operation(MongoUtil.OP_GET_MORE).instance(getDescription().getServerAddress().getHost(), getDescription().getServerAddress().getPort()).databaseName(namespace.getDatabaseName()).build();
    NewRelic.getAgent().getTracedMethod().reportAsExternal(params);
    return Weaver.callOriginal();
}
Also used : DatastoreParameters(com.newrelic.api.agent.DatastoreParameters) Trace(com.newrelic.api.agent.Trace)

Example 10 with DatastoreParameters

use of com.newrelic.api.agent.DatastoreParameters in project newrelic-java-agent by newrelic.

the class AsyncMongoIterableImpl_Instrumentation method first.

@Trace
public void first(SingleResultCallback<TResult> callback) {
    if (!(callback instanceof NRCallbackWrapper)) {
        NRCallbackWrapper<TResult> wrapper = new NRCallbackWrapper<>(callback);
        wrapper.token = NewRelic.getAgent().getTransaction().getToken();
        DatastoreParameters datastoreParameters;
        if (databaseName != null) {
            datastoreParameters = DatastoreParameters.product(DatastoreVendor.MongoDB.name()).collection(collectionName).operation(operationName).noInstance().databaseName(databaseName).build();
        } else {
            datastoreParameters = DatastoreParameters.product(DatastoreVendor.MongoDB.name()).collection(collectionName).operation(operationName).build();
        }
        wrapper.params = datastoreParameters;
        wrapper.segment = NewRelic.getAgent().getTransaction().startSegment(operationName);
        callback = wrapper;
    }
    Weaver.callOriginal();
}
Also used : DatastoreParameters(com.newrelic.api.agent.DatastoreParameters) NRCallbackWrapper(com.nr.agent.mongo.NRCallbackWrapper) Trace(com.newrelic.api.agent.Trace)

Aggregations

DatastoreParameters (com.newrelic.api.agent.DatastoreParameters)31 Trace (com.newrelic.api.agent.Trace)10 SlowQueryDatastoreParameters (com.newrelic.api.agent.SlowQueryDatastoreParameters)9 Test (org.junit.Test)9 AgentConfig (com.newrelic.agent.config.AgentConfig)8 TokenNullCheckClassVisitor (com.newrelic.agent.instrumentation.weaver.preprocessors.AgentPreprocessors.TokenNullCheckClassVisitor)8 ExternalParameters (com.newrelic.api.agent.ExternalParameters)8 SlowQueryWithInputDatastoreParameters (com.newrelic.api.agent.SlowQueryWithInputDatastoreParameters)8 HashMap (java.util.HashMap)8 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)8 ClassVisitor (org.objectweb.asm.ClassVisitor)8 ClassNode (org.objectweb.asm.tree.ClassNode)8 CheckClassAdapter (org.objectweb.asm.util.CheckClassAdapter)8 Segment (com.newrelic.api.agent.Segment)3 NRCallbackWrapper (com.nr.agent.mongo.NRCallbackWrapper)3 ProtocolKeyword (io.lettuce.core.protocol.ProtocolKeyword)3 NRErrorConsumer (com.nr.lettuce6.instrumentation.NRErrorConsumer)2 NRHolder (com.nr.lettuce6.instrumentation.NRHolder)2 NRSignalTypeConsumer (com.nr.lettuce6.instrumentation.NRSignalTypeConsumer)2 NRSubscribeConsumer (com.nr.lettuce6.instrumentation.NRSubscribeConsumer)2