use of com.newrelic.agent.errors.ErrorMessageReplacer 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.ErrorMessageReplacer 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