use of com.newrelic.agent.model.LogEvent in project newrelic-java-agent by newrelic.
the class LoggingEvent_InstrumentationTest method testLogEventsOffLevel.
@Test
public void testLogEventsOffLevel() {
final Logger logger = (Logger) LoggerFactory.getLogger(LoggingEvent_InstrumentationTest.class);
// Logging is OFF at all levels
logger.setLevel(Level.OFF);
int expectedTotalEventsCapturedAtError = 0;
logger.error(NOT_CAPTURED);
int expectedTotalEventsCapturedAtWarn = 0;
logger.warn(NOT_CAPTURED);
int expectedTotalEventsCapturedAtInfo = 0;
logger.info(NOT_CAPTURED);
int expectedTotalEventsCapturedAtDebug = 0;
logger.debug(NOT_CAPTURED);
int expectedTotalEventsCapturedAtTrace = 0;
logger.trace(NOT_CAPTURED);
int expectedTotalEventsCaptured = 0;
Collection<LogEvent> logEvents = introspector.getLogEvents();
assertEquals(expectedTotalEventsCaptured, logEvents.size());
List<LogEvent> errorLevelLogEvents = getErrorLevelLogEvents(logEvents);
List<LogEvent> warnLevelLogEvents = getWarnLevelLogEvents(logEvents);
List<LogEvent> infoLevelLogEvents = getInfoLevelLogEvents(logEvents);
List<LogEvent> debugLevelLogEvents = getDebugLevelLogEvents(logEvents);
List<LogEvent> traceLevelLogEvents = getTraceLevelLogEvents(logEvents);
assertEquals(expectedTotalEventsCapturedAtError, errorLevelLogEvents.size());
assertEquals(expectedTotalEventsCapturedAtWarn, warnLevelLogEvents.size());
assertEquals(expectedTotalEventsCapturedAtInfo, infoLevelLogEvents.size());
assertEquals(expectedTotalEventsCapturedAtDebug, debugLevelLogEvents.size());
assertEquals(expectedTotalEventsCapturedAtTrace, traceLevelLogEvents.size());
}
use of com.newrelic.agent.model.LogEvent in project newrelic-java-agent by newrelic.
the class LoggingEvent_InstrumentationTest method testLogEventsAllLevel.
@Test
public void testLogEventsAllLevel() {
final Logger logger = (Logger) LoggerFactory.getLogger(LoggingEvent_InstrumentationTest.class);
// Log at ALL level
logger.setLevel(Level.ALL);
int expectedTotalEventsCapturedAtError = 1;
logger.error(CAPTURED);
int expectedTotalEventsCapturedAtWarn = 2;
logger.warn(CAPTURED);
logger.warn(CAPTURED);
int expectedTotalEventsCapturedAtInfo = 3;
logger.info(CAPTURED);
logger.info(CAPTURED);
logger.info(CAPTURED);
int expectedTotalEventsCapturedAtDebug = 4;
logger.debug(CAPTURED);
logger.debug(CAPTURED);
logger.debug(CAPTURED);
logger.debug(CAPTURED);
int expectedTotalEventsCapturedAtTrace = 5;
logger.trace(CAPTURED);
logger.trace(CAPTURED);
logger.trace(CAPTURED);
logger.trace(CAPTURED);
logger.trace(CAPTURED);
int expectedTotalEventsCaptured = expectedTotalEventsCapturedAtError + expectedTotalEventsCapturedAtWarn + expectedTotalEventsCapturedAtInfo + expectedTotalEventsCapturedAtDebug + expectedTotalEventsCapturedAtTrace;
Collection<LogEvent> logEvents = introspector.getLogEvents();
assertEquals(expectedTotalEventsCaptured, logEvents.size());
List<LogEvent> errorLevelLogEvents = getErrorLevelLogEvents(logEvents);
List<LogEvent> warnLevelLogEvents = getWarnLevelLogEvents(logEvents);
List<LogEvent> infoLevelLogEvents = getInfoLevelLogEvents(logEvents);
List<LogEvent> debugLevelLogEvents = getDebugLevelLogEvents(logEvents);
List<LogEvent> traceLevelLogEvents = getTraceLevelLogEvents(logEvents);
assertEquals(expectedTotalEventsCapturedAtError, errorLevelLogEvents.size());
assertEquals(expectedTotalEventsCapturedAtWarn, warnLevelLogEvents.size());
assertEquals(expectedTotalEventsCapturedAtInfo, infoLevelLogEvents.size());
assertEquals(expectedTotalEventsCapturedAtDebug, debugLevelLogEvents.size());
assertEquals(expectedTotalEventsCapturedAtTrace, traceLevelLogEvents.size());
}
use of com.newrelic.agent.model.LogEvent in project newrelic-java-agent by newrelic.
the class LoggingEvent_InstrumentationTest method testLogEventsWarnLevel.
@Test
public void testLogEventsWarnLevel() {
final Logger logger = (Logger) LoggerFactory.getLogger(LoggingEvent_InstrumentationTest.class);
// Log at WARN level
logger.setLevel(Level.WARN);
int expectedTotalEventsCapturedAtError = 1;
logger.error(CAPTURED);
int expectedTotalEventsCapturedAtWarn = 1;
logger.warn(CAPTURED);
int expectedTotalEventsCapturedAtInfo = 0;
logger.info(NOT_CAPTURED);
int expectedTotalEventsCapturedAtDebug = 0;
logger.debug(NOT_CAPTURED);
int expectedTotalEventsCapturedAtTrace = 0;
logger.trace(NOT_CAPTURED);
int expectedTotalEventsCaptured = expectedTotalEventsCapturedAtError + expectedTotalEventsCapturedAtWarn + expectedTotalEventsCapturedAtInfo + expectedTotalEventsCapturedAtDebug + expectedTotalEventsCapturedAtTrace;
Collection<LogEvent> logEvents = introspector.getLogEvents();
assertEquals(expectedTotalEventsCaptured, logEvents.size());
List<LogEvent> errorLevelLogEvents = getErrorLevelLogEvents(logEvents);
List<LogEvent> warnLevelLogEvents = getWarnLevelLogEvents(logEvents);
List<LogEvent> infoLevelLogEvents = getInfoLevelLogEvents(logEvents);
List<LogEvent> debugLevelLogEvents = getDebugLevelLogEvents(logEvents);
List<LogEvent> traceLevelLogEvents = getTraceLevelLogEvents(logEvents);
assertEquals(expectedTotalEventsCapturedAtError, errorLevelLogEvents.size());
assertEquals(expectedTotalEventsCapturedAtWarn, warnLevelLogEvents.size());
assertEquals(expectedTotalEventsCapturedAtInfo, infoLevelLogEvents.size());
assertEquals(expectedTotalEventsCapturedAtDebug, debugLevelLogEvents.size());
assertEquals(expectedTotalEventsCapturedAtTrace, traceLevelLogEvents.size());
}
use of com.newrelic.agent.model.LogEvent in project newrelic-java-agent by newrelic.
the class LoggingEvent_InstrumentationTest method testLogEventsTraceLevel.
@Test
public void testLogEventsTraceLevel() {
final Logger logger = (Logger) LoggerFactory.getLogger(LoggingEvent_InstrumentationTest.class);
// Log at TRACE level
logger.setLevel(Level.TRACE);
int expectedTotalEventsCapturedAtError = 1;
logger.error(CAPTURED);
int expectedTotalEventsCapturedAtWarn = 1;
logger.warn(CAPTURED);
int expectedTotalEventsCapturedAtInfo = 1;
logger.info(CAPTURED);
int expectedTotalEventsCapturedAtDebug = 1;
logger.debug(CAPTURED);
int expectedTotalEventsCapturedAtTrace = 1;
logger.trace(CAPTURED);
int expectedTotalEventsCaptured = expectedTotalEventsCapturedAtError + expectedTotalEventsCapturedAtWarn + expectedTotalEventsCapturedAtInfo + expectedTotalEventsCapturedAtDebug + expectedTotalEventsCapturedAtTrace;
Collection<LogEvent> logEvents = introspector.getLogEvents();
assertEquals(expectedTotalEventsCaptured, logEvents.size());
List<LogEvent> errorLevelLogEvents = getErrorLevelLogEvents(logEvents);
List<LogEvent> warnLevelLogEvents = getWarnLevelLogEvents(logEvents);
List<LogEvent> infoLevelLogEvents = getInfoLevelLogEvents(logEvents);
List<LogEvent> debugLevelLogEvents = getDebugLevelLogEvents(logEvents);
List<LogEvent> traceLevelLogEvents = getTraceLevelLogEvents(logEvents);
assertEquals(expectedTotalEventsCapturedAtError, errorLevelLogEvents.size());
assertEquals(expectedTotalEventsCapturedAtWarn, warnLevelLogEvents.size());
assertEquals(expectedTotalEventsCapturedAtInfo, infoLevelLogEvents.size());
assertEquals(expectedTotalEventsCapturedAtDebug, debugLevelLogEvents.size());
assertEquals(expectedTotalEventsCapturedAtTrace, traceLevelLogEvents.size());
}
use of com.newrelic.agent.model.LogEvent in project newrelic-java-agent by newrelic.
the class RPMServiceTest method doSendLogEvent.
private void doSendLogEvent() throws Exception {
MockDataSenderFactory dataSenderFactory = new MockDataSenderFactory();
DataSenderFactory.setDataSenderFactory(dataSenderFactory);
List<String> appNames = singletonList("Send Log Events Test App");
RPMService svc = new RPMService(appNames, null, null, Collections.<AgentConnectionEstablishedListener>emptyList());
svc.launch();
LogEvent logEvent1 = new LogEvent(null, 1);
LogEvent logEvent2 = new LogEvent(null, 2);
List<LogEvent> logEvents = new ArrayList<>();
logEvents.add(logEvent1);
logEvents.add(logEvent2);
svc.sendLogEvents(logEvents);
List<LogEvent> seen = dataSenderFactory.getLastDataSender().getLogEvents();
assertEquals("No log events sent currently", logEvents.size(), seen.size());
}
Aggregations