Search in sources :

Example 31 with DatastoreParameters

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

the class SpanEventFactory method setExternalParameterAttributes.

public SpanEventFactory setExternalParameterAttributes(ExternalParameters parameters) {
    if (parameters instanceof HttpParameters) {
        HttpParameters httpParameters = (HttpParameters) parameters;
        setCategory(SpanCategory.http);
        setUri(httpParameters.getUri());
        setHttpMethod(httpParameters.getProcedure());
        setHttpStatusCode(httpParameters.getStatusCode());
        setHttpStatusText(httpParameters.getStatusText());
        setHttpComponent((httpParameters).getLibrary());
        setKindFromUserAttributes();
    } else if (parameters instanceof DatastoreParameters) {
        DatastoreParameters datastoreParameters = (DatastoreParameters) parameters;
        setCategory(SpanCategory.datastore);
        setDatastoreComponent(datastoreParameters.getProduct());
        setDatabaseName(datastoreParameters.getDatabaseName());
        setDatabaseCollection(datastoreParameters.getCollection());
        setHostName(datastoreParameters.getHost());
        setKindFromUserAttributes();
        if (datastoreParameters instanceof SlowQueryDatastoreParameters) {
            SlowQueryDatastoreParameters<?> queryDatastoreParameters = (SlowQueryDatastoreParameters<?>) datastoreParameters;
            setDatabaseStatement(determineObfuscationLevel(queryDatastoreParameters));
        }
        if (datastoreParameters.getPort() != null) {
            setAddress(datastoreParameters.getHost(), String.valueOf(datastoreParameters.getPort()));
        } else {
            setAddress(datastoreParameters.getHost(), datastoreParameters.getPathOrId());
        }
    } else {
        setCategory(SpanCategory.generic);
    }
    return this;
}
Also used : HttpParameters(com.newrelic.api.agent.HttpParameters) SlowQueryDatastoreParameters(com.newrelic.api.agent.SlowQueryDatastoreParameters) DatastoreParameters(com.newrelic.api.agent.DatastoreParameters) SlowQueryDatastoreParameters(com.newrelic.api.agent.SlowQueryDatastoreParameters)

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