Skip to content

3.x Configuration

LinShunKang edited this page Jan 4, 2021 · 5 revisions

MyPerf4J 默认提供了以下几个参数,用于控制 MyPerf4J 的行为:

属性 类型 必填 默认值 说明
app_name String Yes Configure application name
debug boolean No false Configure debug mode, true/false
http.server.port int No 2048,2000,2040 Configure Http server port,format:preferPort,minBackupPort,maxBackupPort
http.server.min_workers int No 1 Configure Http server min work count
http.server.max_workers int No 2 Configure Http server max work count
http.server.accept_count int No 1024
Configure the maximum number of queued requests for the Http server
metrics.exporter String No log.stdout Configure MetricsExporter type, log.stdout:Output to stdout.log in a standard formatted structure; log.standard:Output to disk in standard formatted structure; log.influxdb:Output to disk in InfluxDB LineProtocol format; http.influxdb:Output to InfluxDB server in InfluxDB LineProtocol format; need configure influxdb configurations
metrics.log.method String No /data/logs/MyPerf4J/metrics.log 配置方法性能监控指标的日志路径,NULL 表示丢弃收集到的监控指标
metrics.log.class_loading String No NULL 配置类加载监控指标的日志路径,NULL 表示丢弃收集到的监控指标
metrics.log.gc String No NULL 配置GC监控指标的日志路径,NULL 表示丢弃收集到的监控指标
metrics.log.memory String No NULL 配置内存监控指标的日志路径,NULL 表示丢弃收集到的监控指标
metrics.log.buff_pool String No NULL 配置 BufferPool 监控指标的日志路径,NULL 表示丢弃收集到的监控指标
metrics.log.thread String No NULL 配置线程监控指标的日志路径,NULL 表示丢弃收集到的监控指标
metrics.log.file_desc String No NULL 配置文件描述符监控指标的日志路径,NULL 表示丢弃收集到的监控指标
metrics.log.compilation String No NULL 配置编译时间监控指标的日志路径,NULL 表示丢弃收集到的监控指标
metrics.log.rolling.time_unit String No DAILY 配置日志文件滚动时间间隔,分别有 MINUTELY、HOURLY 和 DAILY 三个值
metrics.log.reserve.count int No 7 配置历史日志文件保留个数
metrics.time_slice.method int No 60000 配置方法指标采集的时间片,单位为 ms,最小 1s,最大 600s
metrics.time_slice.jvm int No 60000 配置方法指标采集的时间片,单位为 ms,最小 1s,最大 600s
metrics.method.show_params boolean No false 是否展示方法参数类型
metrics.method.class_level_mapping String No 配置 Java类的层级映射关系
recorder.mode String No rough 配置 RecordMode,包含 accurate 和 rough 两个模式
recorder.size.timing_arr int No 1000 配置通用的方法响应时间阈值,单位为 ms
recorder.size.timing_map int No 16 配置通用的方法响应时间超出指定阈值的次数,仅在 RecorderMode=accurate 时有效
recorders.backup_count Int No 1 配置备用 Recorders 的数量,最小 1,最大 8;当你的应用程序拥有非常多的方法需要监控并且你配置的MilliTimeSlice 比较小时,可以适当的提高 BackupRecordersCount 的数值。
filter.packages.include String Yes 配置需要进行监控的包的前缀,支持多个包路径,每个包路径用英文 ';' 分隔;可以使用 [] 表示包/类的集合,形如:com.demo.[p1,p2,p3];可以使用 * 表示通配符,形如:com.*.demo.*
filter.packages.exclude String No 配置不需要进行监控的包的前缀,支持多个包路径,每个包路径用英文 ';' 分隔;可以使用 [] 表示包/类的集合,形如:com.demo.[p1,p2,p3];可以使用 * 表示通配符,形如:com.*.demo.*
filter.methods.exclude String No 配置不需要进行监控的方法名,每个方法名用英文 ';' 分隔
filter.methods.exclude_private boolean No true 配置是否要排除私有方法,可配置为true/false
filter.class_loaders.exclude String No 配置不需要进行监控的 ClassLoader,支持多个 ClassLoader,每个 ClassLoader 路径用英文';'分隔
influxdb.host String No 127.0.0.1 配置 InfluxDB 的 IP 地址
influxdb.port int No 8086 配置 InfluxDB 的端口号
influxdb.database String No 配置 InfluxDB 的数据库名
influxdb.username String No 配置 InfluxDB 的用户名
influxdb.password String No 配置 InfluxDB 的密码
influxdb.conn_timeout int No 3000 配置 InfluxDB 的连接超时时间,单位为 ms
influxdb.read_timeout int No 5000 配置 InfluxDB 的读超时时间,单位为 ms

About Rough Mode and Accurate Mode

  • 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.

关于包路径规则

filter.packages.includefilter.packages.exclude 目前支持以下三种规则:

  • com.demo.p1 代表包含以 com.demo.p1 为前缀的所有包和类
  • [] 表示集合的概念:例如,com.demo.[p1,p2,p3] 代表包含以 com.demo.p1com.demo.p2com.demo.p3 为前缀的所有包和类,等价于 com.demo.p1;com.demo.p2;com.demo.p3
  • * 表示通配符:可以指代零个或多个字符,例如,com.*.demo.*

关于 filter.methods.exclude 的使用规则

filter.methods.exclude 目前支持以下三种规则:

  • filter.methods.exclude = getId1 代表排除所有方法名为 getId1 的方法
  • filter.methods.exclude = DemoServiceImpl.getId1 代表排除类 DemoServiceImpl 中所有方法名为 getId1 的方法
  • filter.methods.exclude = DemoServiceImpl.getId1(long) 代表排除类 DemoServiceImpl 中方法签名为 getId1(long) 的方法

关于 metrics.method.class_level_mapping 的使用规则

metrics.method.class_level_mapping 用于配置 Class 层级映射关系,格式为:LevelA:[classNameExpA1,classNameExpA2];LevelB:[classNameExpB1,classNameExpB2],以 metrics.method.class_level_mapping = Api:[*Api,*ApiImpl];Controller:[*Controller];为例:

  • Api:[*Api,*ApiImpl] 代表所有以 Api 和 ApiImpl 结尾的类的层级为 Api
  • Controller:[*Controller] 代表所有以 Controller 结尾的类的层级为 Controller
Clone this wiki locally