-
Notifications
You must be signed in to change notification settings - Fork 543
Configuration
MyPerf4J provides the following Attribute by default to control the behavior of MyPerf4J:
Attribute | Type | Required | Default Value | Description |
---|---|---|---|---|
AppName | String | Yes | Configure application name | |
MethodMetricsProcessor | Class | No | cn.myperf4j.base.metric.processor.impl.StdoutMethodMetricProcessor | Configure Method Metrics Processor |
ClassMetricsProcessor | Class | No | cn.myperf4j.base.metric.processor.impl.DiscardJvmClassMetricsProcessor | Configure Class Metrics Processor |
GCMetricsProcessor | Class | No | cn.myperf4j.base.metric.processor.impl.DiscardJvmGCMetricsProcessor | Configure GC Metrics Processor |
MemMetricsProcessor | Class | No | cn.myperf4j.base.metric.processor.impl.DiscardJvmMemoryMetricsProcessor | Configure Memory Metrics Processor |
ThreadMetricsProcessor | Class | No | cn.myperf4j.base.metric.processor.impl.DiscardJvmThreadMetricsProcessor | Configure Thread Metrics Processor |
RecorderMode | String | No | rough | Configure RecordMode,accurate/rough |
MillTimeSlice | int | No | 30000 | Configure TimeSlice, time unit: ms, min:1s, max:600s |
BackupRecordersCount | Int | No | 1 | Configure BackupRecordersCount, min:1s, max:8. When you need to count a large number of method performance data in a smaller MillTimeSlice, you can configure a larger number |
IncludePackages | String | Yes | Configure packages to injects,separated with ';' | |
ExcludePackages | String | No | Configure packages not to injects,separated with ';' | |
Debug.PrintDebugLog | boolean | No | false | Configure print debug, true/false |
ExcludeMethods | String | No | Configure methods not to injects, separated with ';' | |
ExcludePrivateMethod | boolean | No | true | Configure injects private method or not |
ExcludeClassLoaders | String | No | Configure ClassLoader not to injects,separated with ';' | |
ProfilingParamsFile | String | No | The configuration file performs memory usage tuning by specifying certain method execution time thresholds, such as /your/path/to/myPerf4J.profilingParams
|
|
ProfilingTimeThreshold | int | No | 1000 | General method execution time threshold in ms |
ProfilingOutThresholdCount | int | No | 16 | The number of times the method execution time threshold is exceeded in a time slice, valid only when RecorderMode=accurate |
PerfStatsProcessor is a processor for processing the performance data counted by MyPerf4J and is extended by SPI. MyPerf4J currently provides five MetricsProcessor: MethodMetricsProcessor, JvmClassMetricsProcessor, JvmGCMetricsProcessor, JvmMemoryMetricsProcessor and JvmThreadMetricsProcessor.
-
Specify in the
MyPerf4JPropFile
configuration file:MethodMetricsProcessor=cn.myperf4j.ext.metric.processor.influxdb.InfluxDBMethodMetricsProcessor
-
Configure the dependency of the log framework such as
Logback
/Log4j
. Let's configure it withLogback
as an example.-
Add
Logback
dependency to pom.xml<dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> <version>${logback-classic-version}</version> </dependency>
-
Configuring logback.xml
<?xml version="1.0" encoding="UTF-8"?> <configuration scan="true" scanPeriod="30 seconds"> <appender name="metrics" class="ch.qos.logback.core.rolling.RollingFileAppender"> <Append>true</Append> <file>/data/logs/MyPerf4J/metrics.log</file> <encoder> <pattern>%msg%n</pattern> <charset>UTF-8</charset> </encoder> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <FileNamePattern>/data/logs/MyPerf4J/metrics.log.%d{yyyy-MM-dd}</FileNamePattern> <MaxHistory>7</MaxHistory> </rollingPolicy> </appender> <appender name="metrics-async" class="ch.qos.logback.classic.AsyncAppender"> <queueSize>1024</queueSize> <appender-ref ref="metrics"/> </appender> <logger name="cn.myperf4j.ext.metric.processor.influxdb" additivity="false"> <level value="INFO"/> <appender-ref ref="metrics-async"/> </logger> <root> <level value="ERROR"/> </root> </configuration>
-
Similar to InfluxDBLoggerProcessor, just modify
MethodMetricsProcessor=cn.myperf4j.ext.metric.processor.logger.LoggerMethodMetricsProcessor
andlogger's name
.
No configuration is required, MyPerf4J uses the processor by default, but it is not recommended to use the processor in a production environment.
MyPerf4J currently provides four JvmClassMetricsProcessor: InfluxDBJvmClassMetricsProcessor, LoggerJvmClassMetricsProcessor, StdoutJvmClassMetricsProcessor and DiscardJvmClassMetricsProcessor.
MyPerf4J currently provides four JvmGCMetricsProcessor: InfluxDBJvmGCMetricsProcessor,LoggerJvmGCMetricsProcessor,StdoutJvmGCMetricsProcessor和DiscardJvmGCMetricsProcessor
MyPerf4J currently provides four JvmMemoryMetricsProcessor: InfluxDBJvmMemoryMetricsProcessor,LoggerJvmMemoryMetricsProcessor,StdoutJvmMemoryMetricsProcessor和DiscardJvmMemoryMetricsProcessor
MyPerf4J currently provides four JvmThreadMetricsProcessor: InfluxDBJvmThreadMetricsProcessor,LoggerJvmThreadMetricsProcessor,StdoutJvmThreadMetricsProcessor和DiscardJvmThreadMetricsProcessor
- Rough Mode
- The accuracy is slightly worse.
- It saves more memory, and only uses array to record response time.
- The speed is a little faster.
- Default mode.
-
Accurate Mode
- High accuracy, records all response times.
- It consumes relatively memory and uses array & Map to record response time.
- The speed is slightly slower.
- Need to add property RecorderMode=accurate in
/your/path/to/myPerf4J.properties
.
-
Suggestions
- For memory-sensitive or precision applications that are not particularly demanding, Rough Mode is recommended.
- The Accurate Mode is recommended for applications that are insensitive to memory and require high accuracy.
ProfilingParamsFile is used to specify the response time threshold for each specific method and the number of times the threshold is exceeded, allowing MyPerf4J to count more methods with less memory.
-
Specify
ProfilingParamsFile=/your/path/to/myPerf4J.profilingParams
in/your/path/to/myPerf4J.properties
-
The configuration in
/your/path/to/myPerf4J.profilingParams
is as follows:#Format is: #fullClassName.methodName=threshold(ms):exceededNumber cn.perf4j.demo.DemoServiceImpl.getId1=1000:10 cn.perf4j.demo.DemoServiceImpl.getId2=2000:20
* Home
- Chinese-Doc
-
English Doc
- MyPerf4J
- Time Series Database
- Log Collector
- Visualization Platform