Search in sources :

Example 1 with ErrorAnalyzerImpl

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());
}
Also used : ErrorAnalyzer(com.newrelic.agent.errors.ErrorAnalyzer) ErrorAnalyzerImpl(com.newrelic.agent.errors.ErrorAnalyzerImpl)

Example 2 with ErrorAnalyzerImpl

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);
}
Also used : ErrorAnalyzer(com.newrelic.agent.errors.ErrorAnalyzer) ErrorAnalyzerImpl(com.newrelic.agent.errors.ErrorAnalyzerImpl)

Example 3 with ErrorAnalyzerImpl

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);
}
Also used : HashMap(java.util.HashMap) SpanErrorBuilder(com.newrelic.agent.service.analytics.SpanErrorBuilder) TracerToSpanEvent(com.newrelic.agent.service.analytics.TracerToSpanEvent) ErrorMessageReplacer(com.newrelic.agent.errors.ErrorMessageReplacer) ErrorAnalyzerImpl(com.newrelic.agent.errors.ErrorAnalyzerImpl)

Example 4 with ErrorAnalyzerImpl

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());
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Mock(org.mockito.Mock) AttributesService(com.newrelic.agent.attributes.AttributesService) TransactionStats(com.newrelic.agent.stats.TransactionStats) HashMap(java.util.HashMap) ArgumentMatchers.anyBoolean(org.mockito.ArgumentMatchers.anyBoolean) EnvironmentService(com.newrelic.agent.environment.EnvironmentService) MockitoAnnotations(org.mockito.MockitoAnnotations) After(org.junit.After) Map(java.util.Map) Before(org.junit.Before) ErrorMessageReplacer(com.newrelic.agent.errors.ErrorMessageReplacer) Tracer(com.newrelic.agent.tracers.Tracer) Test(org.junit.Test) SpanEvent(com.newrelic.agent.model.SpanEvent) com.newrelic.agent.config(com.newrelic.agent.config) com.newrelic.agent(com.newrelic.agent) Mockito(org.mockito.Mockito) ErrorAnalyzerImpl(com.newrelic.agent.errors.ErrorAnalyzerImpl) SERVER_SPAN_HARVEST_CONFIG(com.newrelic.agent.config.SpanEventsConfig.SERVER_SPAN_HARVEST_CONFIG) SamplingPriorityQueue(com.newrelic.agent.interfaces.SamplingPriorityQueue) Consumer(com.newrelic.agent.interfaces.backport.Consumer) SpanCategory(com.newrelic.agent.model.SpanCategory) Collections(java.util.Collections) ServiceFactory(com.newrelic.agent.service.ServiceFactory) Assert.assertEquals(org.junit.Assert.assertEquals) HashMap(java.util.HashMap) ErrorAnalyzerImpl(com.newrelic.agent.errors.ErrorAnalyzerImpl) AttributesService(com.newrelic.agent.attributes.AttributesService) SpanEvent(com.newrelic.agent.model.SpanEvent) EnvironmentService(com.newrelic.agent.environment.EnvironmentService) ErrorMessageReplacer(com.newrelic.agent.errors.ErrorMessageReplacer) Before(org.junit.Before)

Aggregations

ErrorAnalyzerImpl (com.newrelic.agent.errors.ErrorAnalyzerImpl)4 ErrorAnalyzer (com.newrelic.agent.errors.ErrorAnalyzer)2 ErrorMessageReplacer (com.newrelic.agent.errors.ErrorMessageReplacer)2 HashMap (java.util.HashMap)2 com.newrelic.agent (com.newrelic.agent)1 AttributesService (com.newrelic.agent.attributes.AttributesService)1 com.newrelic.agent.config (com.newrelic.agent.config)1 SERVER_SPAN_HARVEST_CONFIG (com.newrelic.agent.config.SpanEventsConfig.SERVER_SPAN_HARVEST_CONFIG)1 EnvironmentService (com.newrelic.agent.environment.EnvironmentService)1 SamplingPriorityQueue (com.newrelic.agent.interfaces.SamplingPriorityQueue)1 Consumer (com.newrelic.agent.interfaces.backport.Consumer)1 SpanCategory (com.newrelic.agent.model.SpanCategory)1 SpanEvent (com.newrelic.agent.model.SpanEvent)1 ServiceFactory (com.newrelic.agent.service.ServiceFactory)1 SpanErrorBuilder (com.newrelic.agent.service.analytics.SpanErrorBuilder)1 TracerToSpanEvent (com.newrelic.agent.service.analytics.TracerToSpanEvent)1 TransactionStats (com.newrelic.agent.stats.TransactionStats)1 Tracer (com.newrelic.agent.tracers.Tracer)1 Collections (java.util.Collections)1 Map (java.util.Map)1