public interface Transaction
Trace
annotation and
set Trace.dispatcher()
to true.
Example:
Server A | Server B |
---|---|
String requestMetadata = NewRelic.getAgent().getTransaction().getRequestMetadata();
// send request containing requestMetadata to Server B. |
|
// read request metadata sent by Server A.
NewRelic.getAgent().getTransaction().processRequestMetadata(requestMetadata); |
|
// right before responding to Server A's request: |
|
// read response metadata sent by Server B.
NewRelic.getAgent().getTransaction().processResponseMetadata(responseMetadata) |
Note: not all transports support a response. In these cases, responses are optional.
Agent.getTransaction()
,
Trace.dispatcher()
Modifier and Type | Method and Description |
---|---|
TracedMethod |
getLastTracer()
Deprecated.
use
getTracedMethod() . |
java.lang.String |
getRequestMetadata()
Get transaction metadata to include in an outbound call.
|
java.lang.String |
getResponseMetadata()
Get transaction metadata to include in an outbound response.
|
TracedMethod |
getTracedMethod()
Returns the
TracedMethod enclosing the caller. |
void |
ignore()
Ignore this transaction so that none of its data is reported to the New Relic service.
|
void |
ignoreApdex()
Ignore the current transaction for calculating Apdex score.
|
boolean |
isTransactionNameSet()
Returns true if the transaction name has been set.
|
void |
processRequestMetadata(java.lang.String requestMetadata)
Provide the metadata string from a remote transaction's call to
getRequestMetadata() to the current
transaction. |
void |
processResponseMetadata(java.lang.String responseMetadata)
Provide the metadata string from a remote transaction's call to
getResponseMetadata() to the current
transaction. |
boolean |
setTransactionName(TransactionNamePriority namePriority,
boolean override,
java.lang.String category,
java.lang.String... parts)
Sets the current transaction's name using the given priority.
|
boolean setTransactionName(TransactionNamePriority namePriority, boolean override, java.lang.String category, java.lang.String... parts)
namePriority
- The priority of the new transaction name.override
- Overrides the current transaction name if it has the same priority level (or lower).category
- The type of transaction. This is the second segment of the full transaction metric name.parts
- The category and all of the parts are concatenated together with / characters to create the full
name.boolean isTransactionNameSet()
@Deprecated TracedMethod getLastTracer()
getTracedMethod()
.TracedMethod getTracedMethod()
TracedMethod
enclosing the caller.TracedMethod
enclosing the caller. The return value is null
if the caller is not
within a transaction.void ignore()
void ignoreApdex()
java.lang.String getRequestMetadata()
Server A
String requestMetadata = NewRelic.getAgent().getTransaction().getRequestMetadata();
...send requestMetadata to Server B as part of an outbound call.
void processRequestMetadata(java.lang.String requestMetadata)
getRequestMetadata()
to the current
transaction.
Server B
... get requestMetadata from request.
NewRelic.getAgent().getTransaction().processRequestMetadata(requestMetadata);
requestMetadata
- metadata string received from an inbound request.java.lang.String getResponseMetadata()
This call is time sensitive and should be made as close as possible to the code that writes the response.
Server B
String responseMetadata = NewRelic.getAgent().getTransaction.getResponseMetadata();
... send response containing responseMetadata to server A.
void processResponseMetadata(java.lang.String responseMetadata)
getResponseMetadata()
to the current
transaction. This should only be called on the originating transaction as a response to a remote call.
Server A
... get response containing responseMetadata from call to server B.
NewRelic.getAgent().getTransaction().processResponseMetadata(responseMetadata);
responseMetadata
- metadata string from a remote transaction (generated by getResponseMetadata()
).