forked from pinpoint-apm/pinpoint
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[pinpoint-apm#8762] apply throttled logger, add collector properties …
…tests, add throttled logger tests
- Loading branch information
1 parent
876d852
commit ab9a874
Showing
14 changed files
with
122 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
...ler/src/test/java/com/navercorp/pinpoint/common/profiler/logging/ThrottledLoggerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.navercorp.pinpoint.common.profiler.logging; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static org.junit.Assert.*; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
public class ThrottledLoggerTest { | ||
|
||
@Test | ||
public void LoggerTest() { | ||
final Logger logger = LogManager.getLogger(this.getClass()); | ||
|
||
final ThrottledLogger throttledLogger = ThrottledLogger.getLogger(logger, 1); | ||
|
||
throttledLogger.info("test logger info: logger"); | ||
throttledLogger.debug("test logger debug: logger"); | ||
throttledLogger.warn("test logger warn: logger"); | ||
} | ||
|
||
@Test | ||
public void throttledLoggerTest() { | ||
final Logger logger = LogManager.getLogger(this.getClass()); | ||
final ThrottledLogger throttledLogger = ThrottledLogger.getLogger(logger, 2); | ||
|
||
//only odd number logs should be shown | ||
throttledLogger.debug("test tlogger debug1: throttled"); | ||
throttledLogger.debug("test tLogger debug2: throttled ERROR"); | ||
throttledLogger.debug("test tlogger debug3: throttled"); | ||
throttledLogger.debug("test tLogger debug4: throttled ERROR"); | ||
} | ||
|
||
@Test | ||
public void throttledLoggerZeroRatioTest() { | ||
final Logger logger = LogManager.getLogger(this.getClass()); | ||
final ThrottledLogger throttledLogger = ThrottledLogger.getLogger(logger, 0); | ||
|
||
throttledLogger.info("test tLogger info: zero ratio"); | ||
throttledLogger.debug("test tLogger debug: zero ratio"); | ||
throttledLogger.warn("test tLogger warn: zero ratio"); | ||
} | ||
|
||
@Test | ||
public void throttledLoggerNegativeRatioTest() { | ||
final Logger logger = LogManager.getLogger(this.getClass()); | ||
final ThrottledLogger throttledLogger = ThrottledLogger.getLogger(logger, -1); | ||
|
||
throttledLogger.info("test tLogger info: negative ratio"); | ||
throttledLogger.debug("test tLogger debug: negative ratio"); | ||
throttledLogger.warn("test tLogger warn: negative ratio"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Configuration status="INFO"> | ||
<Properties> | ||
<Property name="console_message_pattern">%d{MM-dd HH:mm:ss.sss} [%15.15t] %clr{%-5level} %clr{%-40.40logger{1.}}{cyan}:%3L -- %msg{nolookups}%n</Property> | ||
<Property name="file_message_pattern">%d{MM-dd HH:mm:ss.sss} [%15.15t] %-5level %-40.40logger{1.}:%3L -- %msg{nolookups}%n</Property> | ||
</Properties> | ||
|
||
<Appenders> | ||
<Console name="console" target="system_out"> | ||
<PatternLayout pattern="${file_message_pattern}"/> | ||
</Console> | ||
</Appenders> | ||
|
||
<Loggers> | ||
<Logger name="com.navercorp.pinpoint" level="DEBUG" additivity="false"> | ||
<AppenderRef ref="console"/> | ||
</Logger> | ||
<Root level="DEBUG"> | ||
<AppenderRef ref="console"/> | ||
</Root> | ||
</Loggers> | ||
</Configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters