use of com.newrelic.api.agent.Token in project newrelic-java-agent by newrelic.
the class LambdaMonoSubscriber_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 LambdaSubscriber_Instrumentation method onComplete.
public final void onComplete() {
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 ab2d by CMSgov.
the class ContractProcessorImpl method queuePatientClaimsRequest.
/**
* Create a {@link PatientClaimsRequest} and queue the request into a round robin queue used by the eob thread pool.
* <p>
* The queue maintains multiple distinct queues, one for each job running, and offers guarantees that jobs
* are served equally.
* <p>
* On using new-relic tokens with async calls
* See https://docs.newrelic.com/docs/agents/java-agent/async-instrumentation/java-agent-api-asynchronous-applications
*
* @param patient - the patient to process
* @return a pointer to the queued request which will complete or be cancelled at some point.
*/
private Future<ProgressTrackerUpdate> queuePatientClaimsRequest(List<CoverageSummary> patient, ContractData contractData) {
final Token token = NewRelic.getAgent().getTransaction().getToken();
Job job = contractData.getJob();
// Using a ThreadLocal to communicate contract number to RoundRobinBlockingQueue
// could be viewed as a hack by many; but on the other hand it saves us from writing
// tons of extra code.
var jobUuid = job.getJobUuid();
RoundRobinBlockingQueue.CATEGORY_HOLDER.set(jobUuid);
try {
var patientClaimsRequest = new PatientClaimsRequest(patient, contractData.getContract().getAttestedOn(), job.getSince(), job.getOrganization(), jobUuid, job.getContractNumber(), contractData.getContract().getContractType(), token, job.getFhirVersion(), searchConfig.getEfsMount());
return patientClaimsProcessor.process(patientClaimsRequest);
} finally {
RoundRobinBlockingQueue.CATEGORY_HOLDER.remove();
}
}
use of com.newrelic.api.agent.Token in project ab2d by CMSgov.
the class AggregatorJobTest method testWriteBunch.
@Test
void testWriteBunch() throws ParseException, IOException, InterruptedException {
String job = "123";
String contractNo = "ABCD";
String org = "org1";
final Token token = NewRelic.getAgent().getTransaction().getToken();
when(bfdClient.requestEOBFromServer(eq(STU3), eq(1L), any())).thenReturn(BundleUtils.createBundle(createBundleEntry(1)));
when(bfdClient.requestEOBFromServer(eq(STU3), eq(2L), any())).thenReturn(BundleUtils.createBundle(createBundleEntry(2)));
when(bfdClient.requestEOBFromServer(eq(STU3), eq(3L), any())).thenReturn(BundleUtils.createBundle(createBundleEntry(3)));
when(bfdClient.requestEOBFromServer(eq(STU3), eq(4L), any())).thenReturn(BundleUtils.createBundle(createBundleEntry(4)));
when(bfdClient.requestEOBFromServer(eq(STU3), eq(5L), any())).thenReturn(BundleUtils.createBundle(createBundleEntry(5)));
when(bfdClient.requestEOBFromServer(eq(STU3), eq(6L), any())).thenReturn(BundleUtils.createBundle(createBundleEntry(6)));
when(bfdClient.requestEOBFromServer(eq(STU3), eq(7L), any())).thenReturn(BundleUtils.createBundle(createBundleEntry(7)));
when(bfdClient.requestEOBFromServer(eq(STU3), eq(8L), any())).thenReturn(BundleUtils.createBundle(createBundleEntry(8)));
when(bfdClient.requestEOBFromServer(eq(STU3), eq(9L), any())).thenReturn(BundleUtils.createBundle(createBundleEntry(9)));
when(bfdClient.requestEOBFromServer(eq(STU3), eq(10L), any())).thenReturn(BundleUtils.createBundle(createBundleEntry(10)));
ContractForCoverageDTO contract = createContract(contractNo);
PatientClaimsRequest request = new PatientClaimsRequest(createCoverageSummaries(10, contract), OffsetDateTime.of(2020, 1, 1, 0, 0, 0, 9, ZoneOffset.UTC), OffsetDateTime.of(2020, 1, 1, 0, 0, 0, 9, ZoneOffset.UTC), org, job, contract.getContractNumber(), Contract.ContractType.NORMAL, token, FhirVersion.STU3, tempDir.getAbsolutePath());
ReflectionTestUtils.setField(processor, "earliestDataDate", "01/01/2020");
Future<ProgressTrackerUpdate> future = processor.process(request);
while (!future.isDone()) {
Thread.sleep(500);
}
File[] files = (new File(tempDir + "/" + job + "/" + FINISHED)).listFiles();
assertNotNull(files);
assertEquals(1, files.length);
List<String> allLines = Files.readAllLines(Path.of(files[0].getAbsolutePath()));
assertEquals(10, allLines.size());
assertTrue(allLines.get(0).contains("Patient/1"));
assertTrue(allLines.get(1).contains("Patient/2"));
assertTrue(allLines.get(9).contains("Patient/10"));
}
Aggregations