public interface Transaction
Trace
annotation and
set Trace.dispatcher()
to true.Agent.getTransaction()
,
Trace.dispatcher()
Modifier and Type | Method and Description |
---|---|
void |
acceptDistributedTraceHeaders(TransportType transportType,
Headers headers)
Accept the distributed trace headers.
|
void |
acceptDistributedTracePayload(DistributedTracePayload payload)
Deprecated.
Instead, use the Distributed Tracing API
insertDistributedTraceHeaders(Headers) to create a
distributed tracing payload and acceptDistributedTraceHeaders(TransportType, Headers) to link the services
together. |
void |
acceptDistributedTracePayload(java.lang.String payload)
Deprecated.
Instead, use the Distributed Tracing API
insertDistributedTraceHeaders(Headers) to create a
distributed tracing payload and acceptDistributedTraceHeaders(TransportType, Headers) to link the services
together. |
void |
addOutboundResponseHeaders()
Adds headers to the external response so that the response can be recognized on the receiving end.
|
void |
convertToWebTransaction()
Turns the current transaction from a background transaction into a web transaction.
|
DistributedTracePayload |
createDistributedTracePayload()
Deprecated.
Instead, use the Distributed Tracing API
insertDistributedTraceHeaders(Headers) to create a
distributed tracing payload and acceptDistributedTraceHeaders(TransportType, Headers) to link the services
together. |
TracedMethod |
getLastTracer()
Deprecated.
use
getTracedMethod() . |
java.lang.String |
getRequestMetadata()
Deprecated.
Instead, use the Distributed Tracing API
insertDistributedTraceHeaders(Headers) to create a
distributed tracing payload and acceptDistributedTraceHeaders(TransportType, Headers) to link the services
together. |
java.lang.String |
getResponseMetadata()
Deprecated.
Instead, use the Distributed Tracing API. There is no equivalent of this method in Distributed Tracing.
|
Token |
getToken()
Creates a
Token for linking asynchronous work to the current Transaction . |
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.
|
void |
ignoreErrors()
Ignore throwable and http status code errors resulting from this transaction.
|
void |
insertDistributedTraceHeaders(Headers headers)
Generate distributed trace headers and insert them into the
Headers . |
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)
Deprecated.
Instead, use the Distributed Tracing API
insertDistributedTraceHeaders(Headers) to create a
distributed tracing payload and acceptDistributedTraceHeaders(TransportType, Headers) to link the services
together. |
void |
processResponseMetadata(java.lang.String responseMetadata)
Deprecated.
Instead, use the Distributed Tracing API. There is no equivalent of this method in Distributed Tracing.
|
void |
processResponseMetadata(java.lang.String responseMetadata,
java.net.URI uri)
Deprecated.
Instead, use the Distributed Tracing API. There is no equivalent of this method in Distributed Tracing.
|
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)
Sets the request for the current transaction.
|
void |
setWebResponse(Response response)
Sets the response for the current transaction.
|
Segment |
startSegment(java.lang.String segmentName)
Starts and returns a
Segment . |
Segment |
startSegment(java.lang.String category,
java.lang.String segmentName)
Starts and returns a
Segment . |
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()
@Deprecated java.lang.String getRequestMetadata()
insertDistributedTraceHeaders(Headers)
to create a
distributed tracing payload and acceptDistributedTraceHeaders(TransportType, Headers)
to link the services
together.Server A
String requestMetadata = NewRelic.getAgent().getTransaction().getRequestMetadata();
...send requestMetadata to Server B as part of an outbound call.
@Deprecated void processRequestMetadata(java.lang.String requestMetadata)
insertDistributedTraceHeaders(Headers)
to create a
distributed tracing payload and acceptDistributedTraceHeaders(TransportType, Headers)
to link the services
together.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.@Deprecated 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.
@Deprecated 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()
).@Deprecated 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)
setWebResponse(com.newrelic.api.agent.Response)
in order to capture information like the response code for this Transaction.request
- The current transaction's request.void setWebResponse(Response response)
setWebRequest(com.newrelic.api.agent.ExtendedRequest)
in order to name the Transaction properly.response
- The current transaction's response.boolean markResponseSent()
boolean isWebTransaction()
void ignoreErrors()
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.Token getToken()
Token
for linking asynchronous work to the current Transaction
. Subsequent calls to
getToken() will return a new Token.
A single Token
can be passed between multiple threads of work that should be linked to the transaction.
A transaction will remain open until all tokens are expired or timed out.
If getToken() is called outside of a Transaction
a NoOpToken will be returned which will always return
false when calling a method on the Token
object.Segment startSegment(java.lang.String segmentName)
Segment
. This Segment
will show up in the Transaction Breakdown
table, as well as the Transaction Trace page. This Segment
will be reported in the "Custom/" metric
category by default. If you want to specify a custom category use startSegment(String, String)
instead.Segment startSegment(java.lang.String category, java.lang.String segmentName)
Segment
. This Segment
will show up in the Transaction Breakdown
table, as well as the Transaction Trace page.category
- Metric category that will be used for this segment. If null or an empty String, the agent will
report this Segment under the "Custom/" category.segmentName
- Name of the Segment
segment in APM.
This name will show up in the Transaction Breakdown table, as well as the Transaction Trace page.
if null or an empty String, the agent will report "Unnamed Segment".Segment
.@Deprecated DistributedTracePayload createDistributedTracePayload()
insertDistributedTraceHeaders(Headers)
to create a
distributed tracing payload and acceptDistributedTraceHeaders(TransportType, Headers)
to link the services
together.DistributedTracePayload
should be sent from one service to another
when you want to follow a trace throughout a distributed system. A DistributedTracePayload
must be created
within an active New Relic Transaction
.DistributedTracePayload
@Deprecated void acceptDistributedTracePayload(java.lang.String payload)
insertDistributedTraceHeaders(Headers)
to create a
distributed tracing payload and acceptDistributedTraceHeaders(TransportType, Headers)
to link the services
together.DistributedTracePayload
sent from one service to another
in a distributed system will result in those services being linked together in a trace of the system. A
DistributedTracePayload
must be accepted within an active New Relic Transaction
.payload
- a String representation of the DistributedTracePayload
to accept@Deprecated void acceptDistributedTracePayload(DistributedTracePayload payload)
insertDistributedTraceHeaders(Headers)
to create a
distributed tracing payload and acceptDistributedTraceHeaders(TransportType, Headers)
to link the services
together.DistributedTracePayload
sent from one service to another
in a distributed system will result in those services being linked together in a trace of the system.
DistributedTracePayload
must be accepted within an active New Relic Transaction
.payload
- a DistributedTracePayload
instance to acceptvoid insertDistributedTraceHeaders(Headers headers)
Headers
. The header names inserted will depend
on the Headers.getHeaderType()
.headers
- The headers to be updated with distributed trace header names and values.void acceptDistributedTraceHeaders(TransportType transportType, Headers headers)
Transaction
. The header names accepted will depend on
the Headers.getHeaderType()
.transportType
- The transport type of headers being accepted.headers
- The headers to be accepted.