use of com.newrelic.agent.errors.ErrorAnalyzerImpl in project newrelic-java-agent by newrelic.
the class Transaction method isErrorNotExpected.
/**
* This method should only be called at the END of a transaction, AFTER the application name is finalized.
*/
public boolean isErrorNotExpected() {
int responseStatus = getStatus();
ErrorAnalyzer errorAnalyzer = new ErrorAnalyzerImpl(getAgentConfig().getErrorCollectorConfig());
return !errorAnalyzer.isExpectedError(responseStatus, getThrowable());
}
use of com.newrelic.agent.errors.ErrorAnalyzerImpl in project newrelic-java-agent by newrelic.
the class Transaction method isErrorReportableAndNotIgnored.
/**
* This method should only be called at the END of a transaction, AFTER the application name is finalized.
*/
public boolean isErrorReportableAndNotIgnored() {
ErrorAnalyzer errorAnalyzer = new ErrorAnalyzerImpl(getAgentConfig().getErrorCollectorConfig());
int responseStatus = getStatus();
boolean isReportable = errorAnalyzer.isReportable(responseStatus, getThrowable());
return isReportable && !ignoreErrors && !errorAnalyzer.isIgnoredError(responseStatus, getThrowable() == null ? null : getThrowable().throwable);
}
use of com.newrelic.agent.errors.ErrorAnalyzerImpl in project newrelic-java-agent by newrelic.
the class IntrospectorSpanEventService method buildTracerToSpanEvent.
private static TracerToSpanEvent buildTracerToSpanEvent(AgentConfig agentConfig, EnvironmentService environmentService, TransactionDataToDistributedTraceIntrinsics transactionDataToDistributedTraceIntrinsics) {
Map<String, SpanErrorBuilder> map = new HashMap<>();
SpanErrorBuilder spanErrorBuilder = new SpanErrorBuilder(new ErrorAnalyzerImpl(agentConfig.getErrorCollectorConfig()), new ErrorMessageReplacer(agentConfig.getStripExceptionConfig()));
map.put(agentConfig.getApplicationName(), spanErrorBuilder);
return new TracerToSpanEvent(map, environmentService, transactionDataToDistributedTraceIntrinsics, spanErrorBuilder);
}
use of com.newrelic.agent.errors.ErrorAnalyzerImpl in project newrelic-java-agent by newrelic.
the class SpanEventsServiceTest method before.
@Before
public void before() throws Exception {
MockitoAnnotations.initMocks(this);
serviceManager = new MockServiceManager();
Map<String, Object> localSettings = new HashMap<>();
localSettings.put(AgentConfigImpl.APP_NAME, APP_NAME);
localSettings.put("distributed_tracing", Collections.singletonMap("enabled", true));
localSettings.put("span_events", Collections.singletonMap("collect_span_events", true));
when(spanEventCreationDecider.shouldCreateSpans(any(TransactionData.class))).thenReturn(true);
AgentConfig agentConfig = AgentHelper.createAgentConfig(true, localSettings, new HashMap<String, Object>());
ConfigService configService = ConfigServiceFactory.createConfigService(agentConfig, localSettings);
serviceManager.setConfigService(configService);
ServiceFactory.setServiceManager(serviceManager);
serviceManager.setTransactionService(new TransactionService());
serviceManager.setThreadService(new ThreadService());
final MockSpanEventReservoirManager reservoirManager = new MockSpanEventReservoirManager(configService);
Consumer<SpanEvent> backendConsumer = spanEvent -> reservoirManager.getOrCreateReservoir(APP_NAME).add(spanEvent);
SpanErrorBuilder defaultSpanErrorBuilder = new SpanErrorBuilder(new ErrorAnalyzerImpl(agentConfig.getErrorCollectorConfig()), new ErrorMessageReplacer(agentConfig.getStripExceptionConfig()));
Map<String, SpanErrorBuilder> map = new HashMap<>();
map.put(agentConfig.getApplicationName(), defaultSpanErrorBuilder);
EnvironmentService environmentService = mock(EnvironmentService.class, RETURNS_DEEP_STUBS);
TransactionDataToDistributedTraceIntrinsics transactionDataToDistributedTraceIntrinsics = mock(TransactionDataToDistributedTraceIntrinsics.class);
when(transactionDataToDistributedTraceIntrinsics.buildDistributedTracingIntrinsics(any(TransactionData.class), anyBoolean())).thenReturn(Collections.<String, Object>emptyMap());
TracerToSpanEvent tracerToSpanEvent = new TracerToSpanEvent(map, environmentService, transactionDataToDistributedTraceIntrinsics, defaultSpanErrorBuilder);
SpanEventsServiceImpl spanEventsService = SpanEventsServiceImpl.builder().agentConfig(agentConfig).reservoirManager(reservoirManager).collectorSender(mock(CollectorSpanEventSender.class)).eventBackendStorage(backendConsumer).spanEventCreationDecider(spanEventCreationDecider).tracerToSpanEvent(tracerToSpanEvent).build();
serviceManager.setSpansEventService(spanEventsService);
serviceManager.setAttributesService(new AttributesService());
}
Aggregations