Package com.newrelic.agent.bridge
Interface Instrumentation
-
- All Known Implementing Classes:
NoOpInstrumentation
public interface Instrumentation
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description intaddToObjectCache(java.lang.Object object)ExitTracercreateScalaTxnTracer()ExitTracercreateSqlTracer(java.lang.Object invocationTarget, int signatureId, java.lang.String metricName, int flags)Create a sql tracer.ExitTracercreateTracer(java.lang.Object invocationTarget, int signatureId, boolean dispatcher, java.lang.String metricName, java.lang.String tracerFactoryName, java.lang.Object[] args)Create a tracer.ExitTracercreateTracer(java.lang.Object invocationTarget, int signatureId, java.lang.String metricName, int flags)Create a tracer.java.lang.ObjectgetCachedObject(int id)TransactiongetTransaction()Deprecated.UseNewRelic.getAgent().TransactiongetTransactionOrNull()Returns the current transaction.voidinstrument()Trace with transaction activity enabled (async=true) the first non-New Relic stack element on the current stack.voidinstrument(java.lang.reflect.Method methodToInstrument, java.lang.String metricPrefix)Add instrumentation for a given method of a given class only if no @InstrumentedMethod annotation is present.voidinstrument(java.lang.String className, java.lang.String metricPrefix)Adds instrumentation for all methods of a given class, but does not call retransform.java.lang.Class<?>loadClass(java.lang.ClassLoader classLoader, java.lang.Class<?> theClass)voidnoticeInstrumentationError(java.lang.Throwable throwable, java.lang.String libraryName)Log an instrumentation error.voidregisterCloseable(java.lang.String instrumentationName, java.io.Closeable closeable)voidretransformUninstrumentedClass(java.lang.Class<?> classToRetransform)Re-transform a class if it hasn't already been instrumented (Annotated with @InstrumentedClass).
-
-
-
Method Detail
-
createTracer
ExitTracer createTracer(java.lang.Object invocationTarget, int signatureId, java.lang.String metricName, int flags)
Create a tracer. A call to this method is injected into methods that are traced with weaved implementations, trace annotations and custom xml.- Parameters:
invocationTarget- The instance of the object owning the method being invoked, or null for a static method.signatureId- The index of the ClassMethodSignature in the ClassMethodSignatures cache.metricName-flags-- Returns:
- the Tracer on which to call finish()
-
createTracer
ExitTracer createTracer(java.lang.Object invocationTarget, int signatureId, boolean dispatcher, java.lang.String metricName, java.lang.String tracerFactoryName, java.lang.Object[] args)
Create a tracer. A call to this method is injected into methods that are traced because of yaml configuration.- Parameters:
invocationTarget- The instance of the object owning the method being invoked, or null for a static method.signatureId- The index of the ClassMethodSignature in the ClassMethodSignatures cache.dispatcher- If true, this should be treated as the start of a transaction if a transaction is not already in progress.metricName-tracerFactory-args- The arguments passed in the method invocation.- Returns:
- the Tracer on which to call finish()
-
createSqlTracer
ExitTracer createSqlTracer(java.lang.Object invocationTarget, int signatureId, java.lang.String metricName, int flags)
Create a sql tracer. A call to this method is injected into methods that are traced with weaved implementations, trace annotations and custom xml where thecom.newrelic.agent.bridge.datastore.DatastoreMetrics#noticeSql(ConnectionFactory, String, Object[])method is used. The sql tracer properly handles queueing up and managing explain plans for slow sql.- Parameters:
invocationTarget- The instance of the object owning the method being invoked, or null for a static method.signatureId- The index of the ClassMethodSignature in the ClassMethodSignatures cache.metricName-flags-- Returns:
- the Tracer on which to call finish()
-
createScalaTxnTracer
ExitTracer createScalaTxnTracer()
-
getTransaction
@Deprecated Transaction getTransaction()
Deprecated.Returns the current transaction. This should not be called directly - instead useAgent.getTransaction().- Returns:
- Tx on thread or created Tx
-
getTransactionOrNull
Transaction getTransactionOrNull()
Returns the current transaction. This should not be called directly- Returns:
- Tx on thread, or null.
-
noticeInstrumentationError
void noticeInstrumentationError(java.lang.Throwable throwable, java.lang.String libraryName)Log an instrumentation error.- Parameters:
throwable-libraryName-
-
instrument
void instrument(java.lang.String className, java.lang.String metricPrefix)Adds instrumentation for all methods of a given class, but does not call retransform.- Parameters:
className- - exact class name to instrument all methods.metricPrefix-
-
instrument
void instrument(java.lang.reflect.Method methodToInstrument, java.lang.String metricPrefix)Add instrumentation for a given method of a given class only if no @InstrumentedMethod annotation is present. Does not instrument native, abstract, or interface methods. Calls retransform if necessary.- Parameters:
methodToInstrument- - exact method name along with its associated declared class to instrument.metricPrefix-
-
instrument
void instrument()
Trace with transaction activity enabled (async=true) the first non-New Relic stack element on the current stack. Often customers will call APIs likeToken.link(), which need to be called within a transaction, without having instrumented code to start a transaction. We can detect that case and instrument the calling method. This will be rate limited to reduce the overhead, controlled by the config class_transformer:auto_async_link_rate_limit
-
retransformUninstrumentedClass
void retransformUninstrumentedClass(java.lang.Class<?> classToRetransform)
Re-transform a class if it hasn't already been instrumented (Annotated with @InstrumentedClass). Classes that have instrumentation added or removed will not be affected.- Parameters:
classToRetransform-
-
loadClass
java.lang.Class<?> loadClass(java.lang.ClassLoader classLoader, java.lang.Class<?> theClass) throws java.lang.ClassNotFoundException- Throws:
java.lang.ClassNotFoundException
-
addToObjectCache
int addToObjectCache(java.lang.Object object)
-
getCachedObject
java.lang.Object getCachedObject(int id)
-
registerCloseable
void registerCloseable(java.lang.String instrumentationName, java.io.Closeable closeable)
-
-