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 |
|---|---|
void |
addOutboundResponseHeaders()
Instruct the transaction to write the outbound response headers.
|
void |
convertToWebTransaction()
Turns the current transaction from a background transaction into a web transaction.
|
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.
|
boolean |
isWebTransaction()
Returns true if in a web transaction.
|
boolean |
markResponseSent()
Marks the time when the last byte of the response left the server as the current timestamp.
|
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. |
void |
processResponseMetadata(java.lang.String responseMetadata,
java.net.URI uri)
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.
|
void |
setWebRequest(ExtendedRequest request)
Web Frameworks API ********************************
/**
Sets the request for the current transaction.
|
void |
setWebResponse(Response response)
Sets the response for the current transaction.
|
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. Use this method when implementing cross application tracing support for a transport not supported
by New Relic, such as a proprietary RPC transport.
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 when processing response to a remote call.
Use this method when implementing cross application tracing support for a transport not supported by New
Relic, such as a proprietary RPC transport.
Server A
... get response containing responseMetadata from call to server B.
NewRelic.getAgent().getTransaction().processResponseMetadata(responseMetadata);
If a URI is available, please use processResponseMetadata(String, URI).
responseMetadata - metadata string from a remote transaction (generated by getResponseMetadata()).void processResponseMetadata(java.lang.String responseMetadata,
java.net.URI uri)
getResponseMetadata() to the current
transaction. This should only be called on the originating transaction when processing response to a remote call.
Use this method when implementing cross application tracing support for a transport not supported by New
Relic, such as a proprietary RPC transport.
Server A
... get response containing responseMetadata from call to server B.
NewRelic.getAgent().getTransaction().processResponseMetadata(responseMetadata, uri); Note that the URI parameter should include a valid scheme, host, and port.
responseMetadata - metadata string from a remote transaction (generated by getResponseMetadata()).uri - The external URI for the call.void setWebRequest(ExtendedRequest request)
request - The current transaction's request.void setWebResponse(Response response)
response - The current transaction's response.boolean markResponseSent()
boolean isWebTransaction()
void convertToWebTransaction()
void addOutboundResponseHeaders()
setWebRequest(ExtendedRequest) and setWebResponse(Response), which
together provide the Agent with the inbound request headers and a place to record the outbound headers.