Search in sources :

Example 1 with NRCallbackWrapper

use of com.nr.agent.mongo.NRCallbackWrapper 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 2 with NRCallbackWrapper

use of com.nr.agent.mongo.NRCallbackWrapper 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)

Example 3 with NRCallbackWrapper

use of com.nr.agent.mongo.NRCallbackWrapper in project newrelic-java-agent by newrelic.

the class MongoCollectionImpl_Instrumentation method instrument.

private <T> SingleResultCallback<T> instrument(SingleResultCallback<T> callback, String operationName) {
    if (callback instanceof NRCallbackWrapper) {
        return callback;
    }
    NRCallbackWrapper<T> wrapper = new NRCallbackWrapper<T>(callback);
    DatastoreParameters params = DatastoreParameters.product(DatastoreVendor.MongoDB.name()).collection(getNamespace().getCollectionName()).operation(operationName).instance(address.getHost(), address.getPort()).databaseName(getNamespace().getDatabaseName()).build();
    wrapper.params = params;
    wrapper.token = NewRelic.getAgent().getTransaction().getToken();
    wrapper.segment = NewRelic.getAgent().getTransaction().startSegment(operationName);
    return wrapper;
}
Also used : DatastoreParameters(com.newrelic.api.agent.DatastoreParameters) NRCallbackWrapper(com.nr.agent.mongo.NRCallbackWrapper)

Aggregations

DatastoreParameters (com.newrelic.api.agent.DatastoreParameters)3 NRCallbackWrapper (com.nr.agent.mongo.NRCallbackWrapper)3 Trace (com.newrelic.api.agent.Trace)2