use of com.newrelic.api.agent.Token in project ab2d by CMSgov.
the class PatientClaimsProcessorImpl method process.
/**
* Process the retrieval of patient explanation of benefit objects and return the result
* for further post-processing
*/
@Async("patientProcessorThreadPool")
public Future<ProgressTrackerUpdate> process(PatientClaimsRequest request) {
ProgressTrackerUpdate update = new ProgressTrackerUpdate();
final Token token = request.getToken();
token.link();
FhirVersion fhirVersion = request.getVersion();
try {
String anyErrors = writeOutData(request, fhirVersion, update);
if (anyErrors != null && anyErrors.length() > 0) {
writeOutErrors(anyErrors, request);
}
} catch (Exception ex) {
return AsyncResult.forExecutionException(ex);
} finally {
token.expire();
}
return AsyncResult.forValue(update);
}
use of com.newrelic.api.agent.Token in project newrelic-java-agent by newrelic.
the class MuleUtils method handleException.
/**
* If a flow terminates due to an exception, check if there was a listener or an async token associated with it and
* clean them up. If a listener was registered, it might not receive the processing complete notification, so we
* have to loop through every one and check if its one of our custom listeners, pull out its mule event, and check
* its event id to see if it matches the event id of the event that caused the exception.
*/
public static void handleException(MuleEvent muleEvent) {
if (muleEvent != null) {
FlowKey key = new FlowKey(muleEvent.getFlowConstruct().getName(), muleEvent.getId());
Token token = MuleUtils.removeToken(key);
if (token != null) {
token.expire();
Set<ListenerSubscriptionPair> listeners = muleEvent.getMuleContext().getNotificationManager().getListeners();
Set<ServerNotificationListener> removals = new HashSet<>();
for (ListenerSubscriptionPair lsp : listeners) {
if (lsp.getListener() instanceof NRPipelineMessageNotificationListener) {
NRPipelineMessageNotificationListener nrlistener = (NRPipelineMessageNotificationListener) lsp.getListener();
if (nrlistener.getMuleEvent().getId() == muleEvent.getId()) {
NewRelic.getAgent().getLogger().log(Level.FINEST, "MuleUtils#handleException unregistering listener = {0} due to exception", lsp);
removals.add(lsp.getListener());
}
}
}
muleEvent.getMuleContext().getNotificationManager().removeAllListeners(removals);
}
}
}
use of com.newrelic.api.agent.Token in project newrelic-java-agent by newrelic.
the class ChannelOperations_Instrumentation method applyHandler.
/**
* Currently misses the majority of the work inside applyHandler because it only does:
* Mono.fromDirect(handler.apply((INBOUND) this, (OUTBOUND) this)).subscribe(this);
*
* And we aren't instrumenting Mono
*/
@Trace(async = true)
protected final void applyHandler() {
// not an interface method
Token token = channel.pipeline().reactiveLayerToken;
if (token != null) {
token.linkAndExpire();
channel.pipeline().reactiveLayerToken = null;
}
Weaver.callOriginal();
}
use of com.newrelic.api.agent.Token in project newrelic-java-agent by newrelic.
the class LambdaSubscriber_Instrumentation method onError.
public final void onError(Throwable t) {
Token token = this.currentContext().getOrDefault("newrelic-token", null);
if (token != null) {
token.expire();
this.nrContext = null;
}
Weaver.callOriginal();
}
use of com.newrelic.api.agent.Token in project newrelic-java-agent by newrelic.
the class HttpClientRequestBase_Instrumentation method handleResponse.
@Trace(async = true)
void handleResponse(HttpClientResponse resp) {
if (segment != null) {
reportExternal(resp, segment);
final Token token = segment.getTransaction().getToken();
segment.end();
token.linkAndExpire();
}
Weaver.callOriginal();
}
Aggregations