public class Transaction
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected static com.newrelic.agent.bridge.WebResponse |
DEFAULT_RESPONSE |
Modifier | Constructor and Description |
---|---|
protected |
Transaction() |
Modifier and Type | Method and Description |
---|---|
boolean |
acceptDistributedTracePayload(com.newrelic.api.agent.DistributedTracePayload payload) |
boolean |
acceptDistributedTracePayload(java.lang.String payload) |
void |
activityFailedOrIgnored(TransactionActivity activity,
int opcode)
The activity failed to complete normally, typically due to an internal error.
|
void |
activityFinished(TransactionActivity activity,
Tracer tracer,
int opcode) |
void |
addOutboundResponseHeaders()
Instruct the transaction to write the outbound response headers.
|
void |
addTotalCpuTimeForLegacy(long time) |
void |
checkExpire()
Check for any expired tokens or transaction activities.
|
static void |
clearTransaction()
Clear this thread's thread local reference to its transaction.
Caution: in order to meet the functional expectations of legacy code, this method also clears the TransactionActivity from its thread-local variable on the current thread. |
boolean |
conditionalSetPriorityTransactionName(TransactionNamingPolicy policy,
java.lang.String name,
java.lang.String category,
com.newrelic.agent.bridge.TransactionNamePriority priority) |
void |
convertToWebTransaction()
Turns the current transaction from a background transaction into a web transaction.
|
DistributedTracePayloadImpl |
createDistributedTracePayload(java.lang.String spanId) |
void |
expireAllTokensForCurrentTransaction() |
static boolean |
expireToken(TokenImpl token)
This should only ever be called by the token.
|
void |
finishSegment(Segment segment,
java.lang.Throwable throwable,
Tracer parent,
java.lang.String endThreadName)
Internal implementation of
TracedActivity.finish() and Segment.end() . |
void |
freezeStatus() |
void |
freezeTransactionName()
This has the side-effect of possibly ignoring the transaction as a result of applying server-side rules.
|
java.util.Map<java.lang.String,java.lang.Object> |
getAgentAttributes()
Custom parameters added by the Agent.
|
AgentConfig |
getAgentConfig()
Return the config for the current application name.
|
java.lang.String |
getApplicationName() |
BrowserTransactionState |
getBrowserTransactionState() |
CrossProcessConfig |
getCrossProcessConfig() |
com.newrelic.agent.bridge.CrossProcessState |
getCrossProcessState() |
CrossProcessTransactionState |
getCrossProcessTransactionState() |
DatabaseStatementParser |
getDatabaseStatementParser() |
Dispatcher |
getDispatcher()
Get the dispatcher for this transaction.
|
java.util.Map<java.lang.String,java.lang.Object> |
getErrorAttributes()
Custom attributes for an error added by this API call:
NewRelic.noticeError(String, Map) |
long |
getExternalTime() |
java.util.Set<TransactionActivity> |
getFinishedChildren() |
java.lang.String |
getGuid()
Return the GUID for this transaction.
|
InboundHeaderState |
getInboundHeaderState()
Get the inbound header state for this transaction, bringing it into existence if it does not already exist.
|
long |
getInitiatingThreadId() |
com.newrelic.api.agent.Insights |
getInsightsData() |
java.util.Map<java.lang.String,java.lang.Object> |
getInternalParameters()
Parameters used for internal agent processing.
|
java.util.Map<java.lang.String,java.lang.Object> |
getIntrinsicAttributes()
Custom parameters added by the Agent which cannot be turned off by the customer.
|
long |
getLargestTransportDurationInMillis() |
java.lang.Object |
getLock()
Get the lock on the object.
|
com.newrelic.api.agent.MetricAggregator |
getMetricAggregator() |
TransactionNamingScheme |
getNamingScheme() |
java.lang.String |
getNormalizedUri()
Deprecated.
|
protected static Transaction |
getOrCreateDummyTransaction() |
java.lang.String |
getOrCreateTraceId() |
TransactionStats |
getOverLimitTxStatsforTesting() |
java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> |
getPrefixedAgentAttributes()
The HTTP request parameters.
|
float |
getPriority() |
PriorityApplicationName |
getPriorityApplicationName() |
PriorityTransactionName |
getPriorityTransactionName() |
Tracer |
getRootTracer()
Returns the root tracer - the first tracer in the transaction
|
IRPMService |
getRPMService() |
long |
getRunningDurationInNanos() |
int |
getRunningTransactionActivityCount() |
SlowQueryListener |
getSlowQueryListener(boolean createIfNotExists) |
SpanProxy |
getSpanProxy() |
int |
getStatus() |
java.lang.String |
getStatusMessage() |
TransactionThrowable |
getThrowable() |
com.newrelic.agent.model.TimeoutCause |
getTimeoutCause() |
com.newrelic.agent.bridge.Token |
getToken()
This should be the only place that increments the counter.
|
java.util.List<Tracer> |
getTracers()
Get the completed tracers for this transaction.
In Agent versions through 3.10.x, this method could be called during a transaction in progress to get the current state of the tracer stack. |
static Transaction |
getTransaction()
Returns this thread's reference to the transaction.
|
static Transaction |
getTransaction(boolean createIfNotExists)
Get this thread's reference to a transaction, creating it if this thread has no Transaction reference and
creation is requested and allowable.
|
TransactionActivity |
getTransactionActivity()
Get this task's TransactionActivity
|
TransactionCache |
getTransactionCache()
Get a per-thread cache to store objects for the life of the transaction.
|
TransactionCounts |
getTransactionCounts() |
TransactionState |
getTransactionState() |
TransactionTimer |
getTransactionTimer() |
TransactionTracerConfig |
getTransactionTracerConfig() |
long |
getTransportDurationInMillis() |
com.newrelic.agent.bridge.TransportType |
getTransportType() |
java.util.Map<java.lang.String,java.lang.Object> |
getUserAttributes()
Custom parameters added by these API calls:
NewRelic.setAccountName(String) NewRelic.setProductName(String)
NewRelic.setUserName(String) NewRelic.addCustomParameter(String, Number)
NewRelic.addCustomParameter(String, String) |
long |
getWallClockStartTimeMs()
The start time of this transaction (wall clock time).
|
com.newrelic.agent.bridge.WebResponse |
getWebResponse()
Returns the web response associated with this transaction that tracks the response status code, message, etc.
|
void |
ignore() |
void |
ignoreApdex() |
void |
ignoreErrors() |
void |
ignoreSegmentIfUnfinished(Segment event)
Internal implementation of
TracedActivity.ignoreIfUnfinished() and Segment.ignore() . |
boolean |
isAutoAppNamingEnabled() |
static boolean |
isDummyRequest(com.newrelic.api.agent.Request request) |
boolean |
isErrorNotExpected()
This method should only be called at the END of a transaction, AFTER the application name is finalized.
|
boolean |
isErrorReportableAndNotIgnored()
This method should only be called at the END of a transaction, AFTER the application name is finalized.
|
boolean |
isFinished()
Return true if this transaction has been started and also finished.
|
boolean |
isIgnore() |
boolean |
isInProgress()
Return true if this transaction has been started and is not finished.
|
boolean |
isStarted()
Return true if the transaction has ever been started.
|
boolean |
isSynthetic()
Return true if this transaction is the result of a valid request from New Relic Synthetics.
|
boolean |
isTransactionNameSet()
Deprecated.
|
boolean |
isTransactionNamingEnabled() |
boolean |
isTransactionTraceEnabled() |
boolean |
isWebRequestSet() |
boolean |
isWebResponseSet() |
boolean |
isWebTransaction()
Returns true if in a web transaction.
|
static boolean |
linkTxOnThread(TokenImpl token) |
boolean |
markFirstByteOfResponse(long endTimeNs) |
boolean |
markLastByteOfResponse(long endTimeNs) |
void |
noticeTracerException(java.lang.Throwable throwable,
java.lang.String spanId)
Capture the first tracer that had this unhandled exception.
|
void |
onRemoval()
No matter how the token is removed from the cache, check if we need to finish the transaction.
|
void |
provideHeaders(com.newrelic.api.agent.InboundHeaders headers)
Although the Transaction infrastructure was originally constructed to instrument transactions originated by web
requests, the Java agent also supports transaction origination from JMS messages.
|
void |
provideRawHeaders(com.newrelic.api.agent.InboundHeaders headers) |
void |
recordFinalGCTime(TransactionStats stats) |
void |
refreshToken(TokenImpl token)
The token cache is expire after access, so the cache needs to be refreshed each time the token is used, which
only matters in the link case.
|
void |
requestDestroyed() |
void |
requestInitialized(com.newrelic.api.agent.Request request,
com.newrelic.api.agent.Response response) |
boolean |
sampled() |
void |
saveMessageParameters(java.util.Map<java.lang.String,java.lang.String> parameters) |
void |
setApplicationName(com.newrelic.api.agent.ApplicationNamePriority priority,
java.lang.String appName)
Set the application name using a first setter (of a given priority) wins policy.
|
void |
setDispatcher(Dispatcher dispatcher) |
void |
setIgnore(boolean ignore) |
void |
setNormalizedUri(java.lang.String normalizedUri)
Deprecated.
|
void |
setPriorityIfNotNull(java.lang.Float priority) |
boolean |
setPriorityTransactionName(PriorityTransactionName ptn)
Forcibly set the priority transaction name, subverting the usual priority policy.
|
void |
setRequestAndResponse(com.newrelic.api.agent.Request request,
com.newrelic.api.agent.Response response) |
void |
setThrowable(java.lang.Throwable throwable,
TransactionErrorPriority priority,
boolean expected)
Set the throwable with given priority.
|
void |
setTimeoutCause(com.newrelic.agent.model.TimeoutCause cause) |
static void |
setTransaction(Transaction tx)
Set this thread's thread local reference to the transaction.
Caution: in order to meet the functional expectations of legacy code, this method also sets the thread-local variable holding the TransactionActivity to the TransactionActivity instance originally created with this Transaction instance. |
boolean |
setTransactionName(com.newrelic.api.agent.TransactionNamePriority namePriority,
boolean override,
java.lang.String category,
java.lang.String... parts) |
boolean |
setTransactionName(com.newrelic.agent.bridge.TransactionNamePriority namePriority,
boolean override,
java.lang.String category,
java.lang.String... parts) |
void |
setTransactionState(TransactionState transactionState) |
void |
setTransportType(com.newrelic.agent.bridge.TransportType transportType) |
void |
setWebRequest(com.newrelic.api.agent.Request req)
Sets the request for the current transaction.
|
void |
setWebResponse(com.newrelic.api.agent.Response resp)
Sets the response for the current transaction.
|
boolean |
shouldGenerateTransactionSegment() |
void |
startFastAsyncWork(TransactionActivity txa,
Tracer tracer) |
Segment |
startSegment(java.lang.String category,
java.lang.String segmentName)
Internal implementation of
Transaction.createAndStartTracedActivity() . |
void |
startTransactionIfBeginning(Tracer tracer) |
protected static final com.newrelic.agent.bridge.WebResponse DEFAULT_RESPONSE
public void setTimeoutCause(com.newrelic.agent.model.TimeoutCause cause)
public com.newrelic.agent.model.TimeoutCause getTimeoutCause()
public long getTransportDurationInMillis()
public DistributedTracePayloadImpl createDistributedTracePayload(java.lang.String spanId)
public boolean acceptDistributedTracePayload(java.lang.String payload)
public boolean acceptDistributedTracePayload(com.newrelic.api.agent.DistributedTracePayload payload)
public com.newrelic.agent.bridge.TransportType getTransportType()
public long getLargestTransportDurationInMillis()
public SpanProxy getSpanProxy()
public java.lang.String getOrCreateTraceId()
public com.newrelic.api.agent.MetricAggregator getMetricAggregator()
public long getInitiatingThreadId()
public java.lang.Object getLock()
public java.lang.String getGuid()
public AgentConfig getAgentConfig()
public long getWallClockStartTimeMs()
public java.util.Map<java.lang.String,java.lang.Object> getInternalParameters()
public boolean markFirstByteOfResponse(long endTimeNs)
public boolean markLastByteOfResponse(long endTimeNs)
public java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> getPrefixedAgentAttributes()
public java.util.Map<java.lang.String,java.lang.Object> getUserAttributes()
NewRelic.setAccountName(String)
NewRelic.setProductName(String)
NewRelic.setUserName(String)
NewRelic.addCustomParameter(String, Number)
NewRelic.addCustomParameter(String, String)
public java.util.Map<java.lang.String,java.lang.Object> getAgentAttributes()
public java.util.Map<java.lang.String,java.lang.Object> getIntrinsicAttributes()
public java.util.Map<java.lang.String,java.lang.Object> getErrorAttributes()
NewRelic.noticeError(String, Map)
public com.newrelic.api.agent.Insights getInsightsData()
public TransactionTracerConfig getTransactionTracerConfig()
public CrossProcessConfig getCrossProcessConfig()
public boolean setTransactionName(com.newrelic.api.agent.TransactionNamePriority namePriority, boolean override, java.lang.String category, java.lang.String... parts)
public boolean setTransactionName(com.newrelic.agent.bridge.TransactionNamePriority namePriority, boolean override, java.lang.String category, java.lang.String... parts)
@Deprecated public boolean isTransactionNameSet()
public PriorityTransactionName getPriorityTransactionName()
public void freezeTransactionName()
public boolean conditionalSetPriorityTransactionName(TransactionNamingPolicy policy, java.lang.String name, java.lang.String category, com.newrelic.agent.bridge.TransactionNamePriority priority)
public boolean setPriorityTransactionName(PriorityTransactionName ptn)
setPriorityTransactionNameLocked(com.newrelic.agent.transaction.PriorityTransactionName)
directly.ptn
- the new namepublic SlowQueryListener getSlowQueryListener(boolean createIfNotExists)
public TransactionCache getTransactionCache()
public boolean isStarted()
public boolean isFinished()
public boolean isInProgress()
public Dispatcher getDispatcher()
public long getExternalTime()
public Tracer getRootTracer()
public java.util.List<Tracer> getTracers()
public TransactionStats getOverLimitTxStatsforTesting()
public TransactionActivity getTransactionActivity()
public void startTransactionIfBeginning(Tracer tracer)
public void setDispatcher(Dispatcher dispatcher)
public void setTransportType(com.newrelic.agent.bridge.TransportType transportType)
public TransactionTimer getTransactionTimer()
public void addTotalCpuTimeForLegacy(long time)
public void recordFinalGCTime(TransactionStats stats)
public boolean isTransactionTraceEnabled()
public boolean isAutoAppNamingEnabled()
public boolean isTransactionNamingEnabled()
public TransactionNamingScheme getNamingScheme()
public boolean isSynthetic()
public void provideHeaders(com.newrelic.api.agent.InboundHeaders headers)
headers
- the proposed request headerspublic void provideRawHeaders(com.newrelic.api.agent.InboundHeaders headers)
headers
- deobfuscated request headers.public InboundHeaderState getInboundHeaderState()
public IRPMService getRPMService()
public static void clearTransaction()
public static void setTransaction(Transaction tx)
public static Transaction getTransaction()
public void refreshToken(TokenImpl token)
public static boolean linkTxOnThread(TokenImpl token)
public void startFastAsyncWork(TransactionActivity txa, Tracer tracer)
public static Transaction getTransaction(boolean createIfNotExists)
createIfNotExists
- true to request creation of the objectprotected static Transaction getOrCreateDummyTransaction()
@Deprecated public void setNormalizedUri(java.lang.String normalizedUri)
@Deprecated public java.lang.String getNormalizedUri()
public TransactionThrowable getThrowable()
public boolean isErrorReportableAndNotIgnored()
public boolean isErrorNotExpected()
public int getStatus()
public java.lang.String getStatusMessage()
public void freezeStatus()
public void setThrowable(java.lang.Throwable throwable, TransactionErrorPriority priority, boolean expected)
throwable
- the throwable that should be reportedpriority
- the priority of the throwable. If set to TransactionErrorPriority.TRACER
and not reportedexpected
- public void noticeTracerException(java.lang.Throwable throwable, java.lang.String spanId)
throwable
- The unhandled exception from the tracerspanId
- The Tracer GUIDpublic boolean isIgnore()
public void ignore()
public void setIgnore(boolean ignore)
public void ignoreApdex()
public void ignoreErrors()
public TransactionCounts getTransactionCounts()
public boolean shouldGenerateTransactionSegment()
public DatabaseStatementParser getDatabaseStatementParser()
public BrowserTransactionState getBrowserTransactionState()
public com.newrelic.agent.bridge.CrossProcessState getCrossProcessState()
public CrossProcessTransactionState getCrossProcessTransactionState()
public TransactionState getTransactionState()
public void setTransactionState(TransactionState transactionState)
public void addOutboundResponseHeaders()
setWebRequest(Request)
} and setWebResponse(Response)
.public com.newrelic.agent.bridge.WebResponse getWebResponse()
public boolean isWebTransaction()
public void convertToWebTransaction()
public void setRequestAndResponse(com.newrelic.api.agent.Request request, com.newrelic.api.agent.Response response)
public boolean isWebRequestSet()
public boolean isWebResponseSet()
public void setWebRequest(com.newrelic.api.agent.Request req)
req
- The current transaction's request.public void setWebResponse(com.newrelic.api.agent.Response resp)
resp
- The current transaction's response.public void requestInitialized(com.newrelic.api.agent.Request request, com.newrelic.api.agent.Response response)
public void requestDestroyed()
public static boolean isDummyRequest(com.newrelic.api.agent.Request request)
public java.lang.String getApplicationName()
public PriorityApplicationName getPriorityApplicationName()
public void setApplicationName(com.newrelic.api.agent.ApplicationNamePriority priority, java.lang.String appName)
priority
- the priorityappName
- the name to set if the argument priority is higher than that existing priority.public long getRunningDurationInNanos()
public void saveMessageParameters(java.util.Map<java.lang.String,java.lang.String> parameters)
public com.newrelic.agent.bridge.Token getToken()
public static boolean expireToken(TokenImpl token)
token
- The token to expire.public void expireAllTokensForCurrentTransaction()
public void onRemoval()
public void checkExpire()
public Segment startSegment(java.lang.String category, java.lang.String segmentName)
Transaction.createAndStartTracedActivity()
. This
has to happen inside the transaction class because it requires updates to an async map (runningChildren)public void ignoreSegmentIfUnfinished(Segment event)
TracedActivity.ignoreIfUnfinished()
and Segment.ignore()
.event
- The unfinished activity to ignore.public void finishSegment(Segment segment, java.lang.Throwable throwable, Tracer parent, java.lang.String endThreadName)
TracedActivity.finish()
and Segment.end()
.
This has to happen inside the transaction class because it requires updates to finishedChildrensegment
- The Segment to finish.throwable
- A throwable to finish the activity tracer with. May be null.public int getRunningTransactionActivityCount()
public void activityFailedOrIgnored(TransactionActivity activity, int opcode)
activity
- the activity that failedopcode
- public void activityFinished(TransactionActivity activity, Tracer tracer, int opcode)
public java.util.Set<TransactionActivity> getFinishedChildren()
public float getPriority()
public void setPriorityIfNotNull(java.lang.Float priority)
public boolean sampled()