如何使用监控诊断工具Arthas(阿尔萨斯)

news2024/12/22 19:59:33

 

Arthas 是一款线上监控诊断产品,通过全局视角实时查看应用 load、内存、gc、线程的状态信息,并能在不修改应用代码的情况下,对业务问题进行诊断,包括查看方法调用的出入参、异常,监测方法执行耗时,类加载信息等,大大提升线上问题排查效率


目录

一、启动安装

二、能使用Arthas(阿尔萨斯做什么

1. 全局查看系统的运行状况

2. 查看指定线程堆栈信息

3. 排查为什么没有执行到修改的代码

4. 方法调用路径,以及性能分析

5. 线上 debug


一、启动安装

##1.下载
wget https://arthas.aliyun.com/arthas-boot.jar;
##2.运行
java -jar arthas-boot.jar;

例如: Windows上使用参考

1.执行java -jar arthas-boot.jar

D:\Soft\arthas-bin>java -jar arthas-boot.jar
[INFO] arthas-boot version: 3.5.4
[INFO] Process 10668 already using port 3658
[INFO] Process 10668 already using port 8563
[INFO] Found existing java process, please choose one and input the serial number of the process, eg : 1. Then hit ENTER.
* [1]: 10668 org.jboss.Main
  [2]: 5952
  [3]: 2240

2.10668为需要监控的进程,是一个启动的Jboss服务,输入10668 前方的序号1回车,开始诊断监控,如下

[INFO] Process 10668 already using port 8563
[INFO] Found existing java process, please choose one and input the serial number of the process, eg : 1. Then hit ENTER.
* [1]: 10668 org.jboss.Main
  [2]: 5952
  [3]: 2240
1
[INFO] arthas home: D:\Soft\arthas-bin
[INFO] The target process already listen port 3658, skip attach.
[INFO] arthas-client connect 127.0.0.1 3658
  ,---.  ,------. ,--------.,--.  ,--.  ,---.   ,---.
 /  O  \ |  .--. ''--.  .--'|  '--'  | /  O  \ '   .-'
|  .-.  ||  '--'.'   |  |   |  .--.  ||  .-.  |`.  `-.
|  | |  ||  |\  \    |  |   |  |  |  ||  | |  |.-'    |
`--' `--'`--' '--'   `--'   `--'  `--'`--' `--'`-----'


wiki       https://arthas.aliyun.com/doc
tutorials  https://arthas.aliyun.com/doc/arthas-tutorials.html
version    3.5.4
main_class
pid        10668
time       2022-12-23 16:33:09

二、能使用Arthas(阿尔萨斯)做什么

1. 全局查看系统的运行状况

dashboard 命令,查看当前系统实时数据面板

参数说明

  • -i : 指刷新的时间间隔

  • -n: 指刷新次数

例如:

[arthas@10668]$ dashboard
ID        NAME                                                       GROUP                        PRIORITY            STATE               %CPU               DELTA_TIME          TIME                INTERRUPTED        DAE
129       Thread-24                                                  jboss                        5                   TIMED_WAITING       0.0                0.000               4:23.345            false              fal
14        ScannerThread                                              jboss                        5                   TIMED_WAITING       0.0                0.000               4:22.596            false              tru
157       http-0.0.0.0-8091-1                                        jboss                        5                   WAITING             0.0                0.000               0:34.304            false              tru
-1        C2 CompilerThread0                                         -                            -1                  -                   0.0                0.000               0:27.019            false              tru
-1        C2 CompilerThread1                                         -                            -1                  -                   0.0                0.000               0:26.894            false              tru
-1        VM Thread                                                  -                            -1                  -                   0.0                0.000               0:19.734            false              tru
-1        GC task thread#2 (ParallelGC)                              -                            -1                  -                   0.0                0.000               0:10.420            false              tru
-1        GC task thread#4 (ParallelGC)                              -                            -1                  -                   0.0                0.000               0:10.405            false              tru
-1        GC task thread#7 (ParallelGC)                              -                            -1                  -                   0.0                0.000               0:10.233            false              tru
-1        GC task thread#3 (ParallelGC)                              -                            -1                  -                   0.0                0.000               0:10.186            false              tru
-1        GC task thread#6 (ParallelGC)                              -                            -1                  -                   0.0                0.000               0:9.968             false              tru
-1        GC task thread#0 (ParallelGC)                              -                            -1                  -                   0.0                0.000               0:9.906             false              tru
-1        GC task thread#5 (ParallelGC)                              -                            -1                  -                   0.0                0.000               0:9.765             false              tru
-1        GC task thread#1 (ParallelGC)                              -                            -1                  -                   0.0                0.000               0:9.672             false              tru
52        JCA PoolFiller                                             jboss                        5                   WAITING             0.0                0.000               0:7.113             false              fal
154       arthas-command-execute                                     system                       5                   RUNNABLE            0.0                0.000               0:5.210             false              tru
25        Thread-5                                                   jboss                        5                   TIMED_WAITING       0.0                0.000               0:4.882             false              fal
153       arthas-NettyHttpTelnetBootstrap-3-2                        system                       5                   RUNNABLE            0.0                0.000               0:1.762             false              tru
88        IdleRemover                                                jboss                        5                   TIMED_WAITING       0.0                0.000               0:0.374             false              tru
-1        VM Periodic Task Thread                                    -                            -1                  -                   0.0                0.000               0:0.296             false              tru
49        DefaultQuartzScheduler_QuartzSchedulerThread               QuartzScheduler:DefaultQuart 5                   TIMED_WAITING       0.0                0.000               0:0.280             false              fal
24        Thread-4                                                   jboss                        5                   TIMED_WAITING       0.0                0.000               0:0.234             false              tru
133       AWT-Windows                                                system                       6                   RUNNABLE            0.0                0.000               0:0.093             false              tru
3         Finalizer                                                  system                       8                   WAITING             0.0                0.000               0:0.062             false              tru
10        DestroyJavaVM                                              main                         5                   RUNNABLE            0.0                0.000               0:0.062             false              fal
2         Reference Handler                                          system                       10                  WAITING             0.0                0.000               0:0.046             false              tru
145       logback-1                                                  system                       5                   WAITING             0.0                0.000               0:0.046             false              tru
35        ContainerBackgroundProcessor[StandardEngine[jboss.web]]    jboss                        5                   TIMED_WAITING       0.0                0.000               0:0.046             false              tru
39        DefaultQuartzScheduler_Worker-0                            jboss                        5                   TIMED_WAITING       0.0                0.000               0:0.046             false              fal
40        DefaultQuartzScheduler_Worker-1                            jboss                        5                   TIMED_WAITING       0.0                0.000               0:0.046             false              fal
70        Framework Active Thread                                    jboss                        5                   TIMED_WAITING       0.0                0.000               0:0.031             false              fal
138       http-0.0.0.0-8091-Acceptor-0                               jboss                        5                   RUNNABLE            0.0                0.000               0:0.031             false              tru
160       stariboss-payment.data                                     jboss                        5                   TIMED_WAITING       0.0                0.000               0:0.031             false              fal
5         Attach Listener                                            system                       5                   RUNNABLE            0.0                0.000               0:0.015             false              tru
19        GC Daemon                                                  system                       2                   TIMED_WAITING       0.0                0.000               0:0.015             false              tru
146       arthas-NettyHttpTelnetBootstrap-3-1                        system                       5                   RUNNABLE            0.0                0.000               0:0.015             false              tru
Memory                                             used            total            max              usage            GC
heap                                               201M            346M             455M             44.31%           gc.ps_scavenge.count                                       660
ps_eden_space                                      31M             83M              169M             18.46%           gc.ps_scavenge.time(ms)                                    10991
ps_survivor_space                                  448K            1024K            1024K            43.75%           gc.ps_marksweep.count                                      69
ps_old_gen                                         169M            262M             341M             49.85%           gc.ps_marksweep.time(ms)                                   18641
nonheap                                            175M            178M             304M             57.80%
code_cache                                         7M              10M              48M              16.48%
ps_perm_gen                                        167M            168M             256M             65.55%
direct                                             0K              0K               -                0.00%
mapped                                             1M              1M               -                100.00%
Runtime
os.name                                                                                                               Windows 7
os.version                                                                                                            6.1
java.version                                                                                                          1.7.0_80
java.home                                                                                                             C:\Java\jdk1.7.0_80\jre
systemload.average                                                                                                    -1.00
processors                                                                                                            8
timestamp/uptime                                                                                                      Mon Dec 26 10:56:25 CST 2022/239168s
[arthas@10668]$

 说明

  1. ID:Java级别的线程ID,注意这个ID不能跟jstack中的nativeID一一对应

  2. NAME:线程名

  3. GROUP:线程组名

  4. PRIORITY:线程优先级, 1~10之间的数字,越大表示优先级越高

  5. STATE:线程的状态

  6. CPU%:线程消耗的cpu占比,采样100ms,将所有线程在这100ms内的cpu使用量求和,再算出每个线程的cpu使用占比。

  7. TIME:线程运行总时间,数据格式为

  8. 分:秒
  9. INTERRUPTED:线程当前的中断位状态

  10. DAEMON:是否是daemon线程

2. 查看指定线程信息

Thread命令

参数说明

n:指定最忙的钱N个线程

b:找出当前是阻塞其他线程的线程

i :指定CPU占比统计的采样时间,单位毫秒

例如 :

  • thread 显示所有线程信息

  • thread 1 显示1号线程的运行堆栈

  • thread -b 查看阻塞的线程信息

  • thread -n 3 查看CPU使用率最高的3个线程

  • thread -i 1000 -n 3 ,每过1000秒采用,显示CPU使用最高的线程

#查看最耗CPU的两个线程

[arthas@10668]$ thread -n 
"Reference Handler" Id=2 cpuUsage=0.0% deltaTime=0ms time=46ms WAITING on java.lang.ref.Reference$Lock@2ff15375
at java.lang.Object.wait(Native Method)
-  waiting on java.lang.ref.Reference$Lock@2ff15375
at java.lang.Object.wait(Object.java:503)
at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:133)

"http-0.0.0.0-8091-1" Id=157 cpuUsage=0.0% deltaTime=0ms time=9812ms RUNNABLE (in native)
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:152)
at java.net.SocketInputStream.read(SocketInputStream.java:122)
at oracle.net.ns.Packet.receive(Unknown Source)
at oracle.net.ns.DataPacket.receive(Unknown Source)
at oracle.net.ns.NetInputStream.getNextPacket(Unknown Source)
at oracle.net.ns.NetInputStream.read(Unknown Source)
at oracle.net.ns.NetInputStream.read(Unknown Source)
at oracle.net.ns.NetInputStream.read(Unknown Source)
at oracle.jdbc.driver.T4CMAREngine.unmarshalUB1(T4CMAREngine.java:1104)
at oracle.jdbc.driver.T4CMAREngine.unmarshalSB1(T4CMAREngine.java:1075)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:480)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:219)
at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:970)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1190)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3370)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3454)
at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:365)
at org.springframework.jdbc.core.JdbcTemplate$2.doInPreparedStatement(JdbcTemplate.java:824)
at org.springframework.jdbc.core.JdbcTemplate$2.doInPreparedStatement(JdbcTemplate.java:818)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:589)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:818)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:874)
at com.star.sms.dao.utils.SmsJdbcTemplate.update(SmsJdbcTemplate.java:119)
at com.star.sms.dao.utils.SmsJdbcTemplate.modify(SmsJdbcTemplate.java:227)
at com.star.sms.dao.customer.jdbc.CustomerInfoDaoJdbcImpl.modifyCustomer(CustomerInfoDaoJdbcImpl.java:216)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at com.star.common.interceptor.ThreadCacheInterceptor.invoke(ThreadCacheInterceptor.java:66)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)

#查看157号线程信息

[arthas@10668]$ thread 157
"http-0.0.0.0-8091-1" Id=157 RUNNABLE (in native)
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:152)
at java.net.SocketInputStream.read(SocketInputStream.java:122)
at oracle.net.ns.Packet.receive(Unknown Source)
at oracle.net.ns.DataPacket.receive(Unknown Source)
at oracle.net.ns.NetInputStream.getNextPacket(Unknown Source)
at oracle.net.ns.NetInputStream.read(Unknown Source)
at oracle.net.ns.NetInputStream.read(Unknown Source)
at oracle.net.ns.NetInputStream.read(Unknown Source)
at oracle.jdbc.driver.T4CMAREngine.unmarshalUB1(T4CMAREngine.java:1104)
at oracle.jdbc.driver.T4CMAREngine.unmarshalSB1(T4CMAREngine.java:1075)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:480)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:219)
at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:970)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1190)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3370)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3454)
at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:365)
at org.springframework.jdbc.core.JdbcTemplate$2.doInPreparedStatement(JdbcTemplate.java:824)
at org.springframework.jdbc.core.JdbcTemplate$2.doInPreparedStatement(JdbcTemplate.java:818)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:589)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:818)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:874)
at com.star.sms.dao.utils.SmsJdbcTemplate.update(SmsJdbcTemplate.java:119)
at com.star.sms.dao.utils.SmsJdbcTemplate.modify(SmsJdbcTemplate.java:227)
at com.star.sms.dao.customer.jdbc.CustomerInfoDaoJdbcImpl.modifyCustomer(CustomerInfoDaoJdbcImpl.java:216)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at com.star.common.interceptor.ThreadCacheInterceptor.invoke(ThreadCacheInterceptor.java:66)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at com.sun.proxy.$Proxy1908.modifyCustomer(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)

如果堆栈信息过大, 可以输出日志到文件

默认情况下arthas执行结果是不保存日志的,当然我们通过arthas提供的命令行options进行开启:

关闭日志打印

[arthas@10668]$ options save-result false NAME BEFORE-VALUE AFTER-VALUE

save-result true false

开启日志打印 [arthas@10668]$ options save-result true NAME BEFORE-VALUE AFTER-VALUE

save-result false true

[arthas@10668]$

日志会异步保存在 {user.home}/logs/arthas-cache/result.log;

3.排查为什么没有执行到修改的代码

jad 命令

参数说明

  • jad 包名.类名 反编译类
  • jad包名.类名 方法名 只反编译某个方法

例如:

反编译com.star.sms.service.accept2.dto.NewInstallAcceptDTO如下。jad命令不仅可以查看到ClassLoader还能看到运行的Location信息。 这样可以很清楚了解到运行的是那个包下的类。类覆盖问题就变的很容易发现。

[arthas@10668]$
[arthas@10668]$ jad com.star.sms.service.accept2.dto.NewInstallAcceptDTO

ClassLoader:
+-com.star.osgi.patch.classloader.BundlePatchURLClassLoader[stariboss-accept_interface]
  +-org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@4911704b[stariboss-accept_interface:1.0.0(id=99)]
    +-org.eclipse.osgi.baseadaptor.BaseAdaptor$1@3983efa2

Location:
/E:/Jboss/jboss-4.2.3-8.2.1R1-8091-liaoning_821-5g/server/default/./deploy/stariboss.war/tmp/.patchtmp/1671784240888/a_780103_server_22112711_DB-9452.stariboss-accept_interface.jar

       /*
        * Decompiled with CFR.
        *
        * Could not load the following classes:
        *  com.star.common.lang.Money
        *  com.star.sms.model.customer.Customer
        *  com.star.sms.service.accept2.dto.AcceptSheetDTO
        *  com.star.sms.service.accept2.dto.BatchNoteInfoDTO
        */
       package com.star.sms.service.accept2.dto;

       import com.star.common.lang.Money;
       import com.star.sms.model.customer.Customer;
       import com.star.sms.service.accept2.dto.AcceptSheetDTO;
       import com.star.sms.service.accept2.dto.BatchNoteInfoDTO;
       import java.io.Serializable;
       import java.util.Map;

       /*
        * This class specifies class file version 49.0 but uses Java 6 signatures.  Assumed Java 6.
        */
       public class NewInstallAcceptDTO
       implements Serializable {
           private static final long serialVersionUID = 5229054864090922612L;
           private int rowNum;
           private AcceptSheetDTO acceptSheetDTO;
           private Customer customer;
           private Money businessFee;
           private Money preSavingFee;
           private Money transferFee;
           private Map<String, BatchNoteInfoDTO> notedtos;
           private boolean contactTelRepeatAble = false;

           public boolean getContactTelRepeatAble() {
/*86*/         return this.contactTelRepeatAble;
           }

           public void setContactTelRepeatAble(boolean contactTelRepeatAble) {
/*90*/         this.contactTelRepeatAble = contactTelRepeatAble;
           }

           public Customer getCustomer() {
/*38*/         return this.customer;
           }

           public void setCustomer(Customer customer) {
/*42*/         this.customer = customer;
           }

           public AcceptSheetDTO getAcceptSheetDTO() {
/*30*/         return this.acceptSheetDTO;
           }

           public void setAcceptSheetDTO(AcceptSheetDTO acceptSheetDTO) {
/*34*/         this.acceptSheetDTO = acceptSheetDTO;
           }

           public Money getBusinessFee() {
/*46*/         return this.businessFee;
           }

           public void setBusinessFee(Money businessFee) {
/*50*/         this.businessFee = businessFee;
           }

           public Money getPreSavingFee() {
/*54*/         return this.preSavingFee;
           }

           public void setPreSavingFee(Money preSavingFee) {
/*58*/         this.preSavingFee = preSavingFee;
           }

           public Money getTransferFee() {
/*62*/         return this.transferFee;
           }

           public void setTransferFee(Money transferFee) {
/*66*/         this.transferFee = transferFee;
           }

           public Map<String, BatchNoteInfoDTO> getNotedtos() {
/*70*/         return this.notedtos;
           }

           public void setNotedtos(Map<String, BatchNoteInfoDTO> notedtos) {
/*74*/         this.notedtos = notedtos;
           }

           public int getRowNum() {
/*78*/         return this.rowNum;
           }

           public void setRowNum(int rowNum) {
/*82*/         this.rowNum = rowNum;
           }
       }

如果类过大,反编译内容会很多,建议只反编译某个方法,例如

[arthas@10668]$
[arthas@10668]$ jad com.star.sms.service.support.GroupParamContainer getCustomer
Affect(row-cnt:0) cost in 37 ms.
No class found for: com.star.sms.service.support.GroupParamContainer
[arthas@10668]$ jad com.star.sms.business.customer.CustomerInfoService getCustomer

ClassLoader:
+-com.star.osgi.patch.classloader.BundlePatchURLClassLoader[stariboss-customer]
  +-org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@4089eba3[stariboss-customer:1.0.0(id=124)]
    +-org.eclipse.osgi.baseadaptor.BaseAdaptor$1@3983efa2

Location:
/E:/Jboss/jboss-4.2.3-8.2.1R1-8091-liaoning_821-5g/server/default/./deploy/stariboss.war/tmp/.patchtmp/1671784240888/a_780108_server_22112201_DB-9505.stariboss-customer.jar

        private Customer getCustomer(CustomerInfoDTO result, Long certificateTypeId, String certificateNum, SubscriberResultDTO subscriberResultDTO) {
            Customer customer = new Customer();
/*730*/     if (this.getCustomerCodeGenerator() == null) {
                throw new MsrRuntimeException("customer.code.is.required", false, false, null);
            }
/*731*/     this.getCustomerCodeGenerator().generateAndSetCustomerCode(customer);
/*736*/     customer.setName(result.getCUST_NAME());
/*748*/     customer.setCertificate(this.getCertificate(result, certificateTypeId, certificateNum));
/*752*/     customer.setContactAddress("");
/*753*/     customer.setContactTel(result.getCONT_NUMBER());
/*755*/     customer.setEnrolDate(new Date());
/*758*/     customer.setMobileTel(result.getCONT_NUMBER());
/*760*/     customer.setCustomerAddress("");
/*762*/     customer.setSaleChannel((SaleChannel)ApplicationSessionHolder.getApplicationSession().getValue("currentSaleChannel"));
/*765*/     Sex sex = Sex.getByCode((String)result.getGENDER());
/*766*/     customer.setSex(sex == null ? Sex.MAN : sex);
/*769*/     customer.setStatus(CustomerStatus.EXISTING);
/*771*/     customer.setType(CustomerType.INDIVIDUAL);
/*773*/     SaleArea saleArea = this.getSaleAreaByGw(subscriberResultDTO.getCITY_CODE());
/*774*/     customer.setSaleArea(saleArea);
/*777*/     Address address = this.getAddress(saleArea.getId());
/*778*/     customer.setAddress(address);
/*779*/     customer.setContactMan(result.getCUST_NAME());
/*785*/     customer.setDetailAddressCode("");
/*796*/     customer.setRemark("createByGwInfo,");
/*797*/     return customer;
        }

4.方法调用路径,以及性能分析

trace 命令: 方法内部调用路径,并输出方法路径上的每个节点上耗时

例如: 查看GwPaymentService#callFeePay 调用路径和耗时

[arthas@10668]$ trace com.star.sms.business.payment.gw.GwPaymentService callFeePay
Press Q or Ctrl+C to abort.
Affect(class count: 1 , method count: 1) cost in 184 ms, listenerId: 3
`---ts=2022-12-26 13:37:22;thread_name=http-0.0.0.0-8091-1;id=9d;is_daemon=true;priority=5;TCCL=org.jboss.web.tomc
    `---[41.232898ms] com.star.sms.business.payment.gw.GwPaymentService:callFeePay()
        +---[0.020813ms] com.star.sms.business.payment.gw.helper.GwPaymentConverter:getInstance() #65
        +---[0.018817ms] com.star.sms.business.payment.gw.helper.GwPaymentConverter:callFeePayConvert() #65
        +---[0.019102ms] com.star.sms.gw.payment.GwPayDTO:getPayRecordId() #66
        `---[41.047583ms] com.star.sms.business.payment.gw.GwPaymentService:doPayFee() #66

5.线上 debug

watch命令检测函数入参返回值,抛出异常等信息

参数说明、

  • params : 表示所有参数数组 (因为不确定是几个参数)
  • returnObject:表示返回值
  • -b 方法调用之前观察
  • -e 方法异常后观察
  • -s 方法返回后观察
  • -f 方法结束后观察
  • -x 属性深度

例如:

watch com.star.sms.business.payment.gw.GwPayService payOrder returnObj 观察返回值

watch com.star.sms.business.payment.gw.GwPayService payOrder params 观察输入参数

watch com.star.sms.business.payment.gw.GwPayService payOrder "{params, returnObj}" -x 3


[arthas@10668]$ watch com.star.sms.business.payment.gw.GwPayService payOrder returnObj
Press Q or Ctrl+C to abort.
Affect(class count: 1 , method count: 1) cost in 694 ms, listenerId: 1
method=com.star.sms.business.payment.gw.GwPayService.payOrder location=AtExit
ts=2022-12-23 16:39:28; [cost=85.028278ms] result=@GwPayRecord[
serialVersionUID=@Long[6159375491528104642],
USER_ID=null,
groupNumber=null,
phoneNumber=@String[19200000078],
operationType=@GwPayOperaType[CALL_FEE_PAY],
payMethod=@DictionaryData[com.star.sms.model.system.basicparameter.DictionaryData@13d7],
payChannelType=@PayChannelType[SCAN_PAY],
payFee=@Money[锟? 10.00],
payDate=@Date[2022-12-23 00:00:00,000],
tradeNo=@String[202291392],
outTradeNo=@String[221223163927000244],
barCode=null,
buyerId=null,
thirdPayStatus=@PayStatus[SUCCESS],
bossPayStatus=@ScanPaymentSign[UNPAYED],
developOperator=null,
status=@Status[VALID],
acceptSheetId=null,
resp_code=@String[000000],
resp_desc=@String[璋冪敤鎴愬姛],
order_no=@String[12],
order_pay_status=@String[2],
pay_page_url=null,
scan_url=@String[http://www.baidu.com],
sign_info=@String[hhggr],
business_id=null,
gw_pos_trade_no=null,
prov_mer_order_no=null,
posPayStatus=null,
posRespDesc=null,
payNo=@String[13214],
id=@Long[893],
name=null,
createDate=@Timestamp[2022-12-23 16:39:27,292],
modifyDate=@Timestamp[2022-12-23 16:39:28,000],
createOperator=@Operator[com.star.sms.model.system.organization.Operator@5d],
modifyOperator=@Operator[com.star.sms.model.system.organization.Operator@5d],
remark=null,
operationTerminal=@Terminal[com.star.sms.model.system.organization.Terminal@2d660cb5],
operationSpot=@SaleChannel[com.star.sms.model.system.organization.SaleChannel@9],
version=@Integer[0],
]
[arthas@10668]$
[arthas@10668]$ watch com.star.sms.business.payment.gw.GwPayService payOrder "{params, returnObj}"  -x 3
Press Q or Ctrl+C to abort.
Affect(class count: 1 , method count: 1) cost in 129 ms, listenerId: 4
method=com.star.sms.business.payment.gw.GwPayService.payOrder location=AtExit
ts=2022-12-26 13:56:10; [cost=43.709849ms] result=@ArrayList[
    @Object[][
        @GwPayRecord[
            serialVersionUID=@Long[6159375491528104642],
            USER_ID=null,
            groupNumber=null,
            phoneNumber=@String[19200007899],
            operationType=@GwPayOperaType[CALL_FEE_PAY],
            payMethod=@DictionaryData[com.star.sms.model.system.basicparameter.DictionaryData@13d7],
            payChannelType=@PayChannelType[SCAN_PAY],
            payFee=@Money[锟? 99.00],
            payDate=@Date[2022-12-26 00:00:00,000],
            tradeNo=@String[202299042],
            outTradeNo=@String[221226135609002605],
            barCode=null,
            buyerId=null,
            thirdPayStatus=@PayStatus[SUCCESS],
            bossPayStatus=@ScanPaymentSign[UNPAYED],
            developOperator=null,
            status=@Status[VALID],
            acceptSheetId=null,
            resp_code=@String[000000],
            resp_desc=@String[璋冪敤鎴愬姛],
            order_no=@String[12],
            order_pay_status=@String[2],
            pay_page_url=null,
            scan_url=@String[http://www.baidu.com],
            sign_info=@String[hhggr],
            business_id=null,
            gw_pos_trade_no=null,
            prov_mer_order_no=null,
            posPayStatus=null,
            posRespDesc=null,
            payNo=@String[13214],
            id=@Long[898],
            name=null,
            createDate=@Timestamp[2022-12-26 13:56:09,981],
            modifyDate=@Timestamp[2022-12-26 13:56:10,000],
            createOperator=@Operator[com.star.sms.model.system.organization.Operator@5d],
            modifyOperator=@Operator[com.star.sms.model.system.organization.Operator@5d],
            remark=@String[TRACE TEST],
            operationTerminal=@Terminal[com.star.sms.model.system.organization.Terminal@7a05dcd9],
            operationSpot=@SaleChannel[com.star.sms.model.system.organization.SaleChannel@9],
            version=@Integer[0],
        ],
    ],
    @GwPayRecord[
        serialVersionUID=@Long[6159375491528104642],
        USER_ID=null,
        groupNumber=null,
        phoneNumber=@String[19200007899],
        operationType=@GwPayOperaType[
            CALL_FEE_PAY=@GwPayOperaType[CALL_FEE_PAY],
            BUSINESS_PAY=@GwPayOperaType[BUSINESS_PAY],
            DAMAGES_PAY=@GwPayOperaType[DAMAGES_PAY],
            $VALUES=@GwPayOperaType[][isEmpty=false;size=3],
            name=@String[CALL_FEE_PAY],
            ordinal=@Integer[0],
        ],
        payMethod=@DictionaryData[
            serialVersionUID=@Long[4048790182402733107],
            code=@String[2800],
            displayPos=@Integer[0],
            type=@DictionaryDataType[com.star.sms.model.system.basicparameter.DictionaryDataType@1b5b],
            status=@Status[VALID],
            operateLevel=null,
            saleAreas=null,
            synchronizeStatus=@SynchronizeStatus[UNSYNCHRONIZED],
            synchronizedt=null,
            gw5GCorpOrgCode=null,
            regionID=null,
            regionExtId=null,
            id=@Long[5079],
            name=@String[鐜伴噾鏀粯],
            createDate=@Timestamp[2022-03-30 12:13:49,000],
            modifyDate=null,
            createOperator=@Operator[com.star.sms.model.system.organization.Operator@710107e1],
            modifyOperator=@Operator[com.star.sms.model.system.organization.Operator@7aac7ebc],
            remark=null,
            operationTerminal=@Terminal[com.star.sms.model.system.organization.Terminal@52b4a78f],
            operationSpot=@SaleChannel[com.star.sms.model.system.organization.SaleChannel@5264c7b4],
            version=@Integer[0],
        ],
        payChannelType=@PayChannelType[
            CARD_SWIP=@PayChannelType[CARD_SWIP],
            SCAN_PAY=@PayChannelType[SCAN_PAY],
            $VALUES=@PayChannelType[][isEmpty=false;size=2],
            name=@String[SCAN_PAY],
            ordinal=@Integer[1],
        ],
        payFee=@Money[
            MOVE_CODE=@Integer[32],
            serialVersionUID=@Long[3256444694312726840],
            CENTS=@int[][isEmpty=false;size=4],
            HanDigiStr=@String[][isEmpty=false;size=10],
            HanDiviStr=@String[][isEmpty=false;size=24],
            ZERO=@Money[锟? 0.00],
            CURRENCY_SYMBOL_POSTFIX=@String[ ],
            amount=@Long[9900],
            currency=@Currency[CNY],
            currentCurrency=@Currency[CNY],
        ],
        payDate=@Date[2022-12-26 00:00:00,000],
        tradeNo=@String[202299042],
        outTradeNo=@String[221226135609002605],
        barCode=null,
        buyerId=null,
        thirdPayStatus=@PayStatus[
            SUCCESS=@PayStatus[SUCCESS],
            FAIL=@PayStatus[FAIL],
            UNKOWN=@PayStatus[UNKOWN],
            CANCEL=@PayStatus[CANCEL],
            NOTPAY=@PayStatus[NOTPAY],
            $VALUES=@PayStatus[][isEmpty=false;size=5],
            name=@String[SUCCESS],
            ordinal=@Integer[0],
        ],
        bossPayStatus=@ScanPaymentSign[
            UNPAYED=@ScanPaymentSign[UNPAYED],
            PAYED=@ScanPaymentSign[PAYED],
            $VALUES=@ScanPaymentSign[][isEmpty=false;size=2],
            name=@String[UNPAYED],
            ordinal=@Integer[0],
        ],
        developOperator=null,
        status=@Status[
            INVALID=@Status[INVALID],
            VALID=@Status[VALID],
            $VALUES=@Status[][isEmpty=false;size=2],
            name=@String[VALID],
            ordinal=@Integer[1],
        ],
        acceptSheetId=null,
        resp_code=@String[000000],
        resp_desc=@String[璋冪敤鎴愬姛],
        order_no=@String[12],
        order_pay_status=@String[2],
        pay_page_url=null,
        scan_url=@String[http://www.baidu.com],
        sign_info=@String[hhggr],
        business_id=null,
        gw_pos_trade_no=null,
        prov_mer_order_no=null,
        posPayStatus=null,
        posRespDesc=null,
        payNo=@String[13214],
        id=@Long[898],
        name=null,
        createDate=@Timestamp[2022-12-26 13:56:09,981],
        modifyDate=@Timestamp[2022-12-26 13:56:10,000],
        createOperator=@Operator[
            PROPERTY_USERNAME=@String[code],
            PROPERTY_PASSWORD=@String[password],
            DYNAMIC_PASSWORD=@String[dynamicPassword],
            serialVersionUID=@Long[3256443599062578999],
            code=@String[0147],
            password=null,
            dynamicPassword=null,
            type=@OperatorType[COMMON_OP],
            tel=null,
            familyAddress=null,
            email=null,
            validDateRange=null,
            sex=null,
            identityCard=null,
            education=null,
            department=@Department[com.star.sms.model.system.organization.Department@3],
            level=@OperationLevel[com.star.sms.model.system.privilege.OperationLevel@1],
            address=@Address[com.star.sms.model.system.resource.Address@1],
            rayNode=null,
            saleAreas=@ArrayList[isEmpty=false;size=13],
            roles=@ArrayList[isEmpty=false;size=16],
            saleChannels=@ArrayList[isEmpty=false;size=15],
            channelBindings=@ArrayList[isEmpty=false;size=15],
            segment=null,
            synchronizeStatus=null,
            synchronizedt=null,
            gw5GOperCode=@String[OPER0001],
            storeHouses=null,
            terminals=null,
            mustBindTerminal=@Boolean[false],
            status=null,
            selectedSaleChannel=null,
            dynamicPasswordCheck=null,
            isVIPOperator=@Boolean[false],
            passwordLastModifyDate=@Date[2021-11-02 00:00:00,000],
            imei=null,
            jobType=null,
            id=@Long[93],
            name=@String[huangzw],
            createDate=null,
            modifyDate=null,
            createOperator=null,
            modifyOperator=null,
            remark=null,
            operationTerminal=null,
            operationSpot=null,
            version=@Integer[0],
        ],
         //略
  
        version=@Integer[0],
    ],
]


上一篇:如何使用CURL工具及简单介绍

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/115905.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

【python】实现精美圣诞树-拿下女神不是梦

&#x1f341;博主简介&#xff1a; &#x1f3c5;云计算领域优质创作者 &#x1f3c5;2022年CSDN新星计划python赛道第一名 &#x1f3c5;2022年CSDN原力计划优质作者 &#x1f3c5;阿里云ACE认证高级工程师 &#x1f3c5;阿里云开发者社区专…

Java Web基础面试题

✅作者简介&#xff1a;热爱国学的Java后端开发者&#xff0c;修心和技术同步精进。 &#x1f34e;个人主页&#xff1a;Java Fans的博客 &#x1f34a;个人信条&#xff1a;不迁怒&#xff0c;不贰过。小知识&#xff0c;大智慧。 &#x1f49e;当前专栏&#xff1a;Java面试题…

【K3s】第4篇 一篇文章带你了解使用Kompose

目录 1、Kompose介绍 2、安装Kompose 3、docker-compose文件转换为k8s文件 1、Kompose介绍 kompose是一个帮助熟悉 Kubernetes 的用户迁移到k8s的工具。 获取 Docker Compose 文件并将其转换为 Kubernetes 资源。 kompose是一个方便的工具&#xff0c;可以从本地 Docker …

Ffuf爆破神器(超详细)

目录为什么是Ffuf基本使用最基本的使用多个字典同时使用带cookie扫描&#xff08;-b&#xff09;静默模式&#xff08;-s&#xff09;递归扫描&#xff08;-recursion&#xff09;指定扩展名&#xff08;-e&#xff09;POST请求爆破方式1&#xff1a;指明请求地址和请求体【不推…

iOS 自动化测试踩坑(一): 技术方案、环境配置与落地实践

移动端的自动化测试&#xff0c;最常见的是 Android 自动化测试&#xff0c;我个人觉得 Android 的测试优先级会更高&#xff0c;也更开放&#xff0c;更容易测试&#xff1b;而 iOS 相较于 Android 要安全稳定的多&#xff0c;但也是一个必须测试的方向&#xff0c;这个系列文…

Android实现雪花特效自定义view

一、前言 这个冬天&#xff0c;老家一直没有下雨&#xff0c; 正好圣诞节&#xff0c;就想着制作一个下雪的特效。 圣诞祝福&#xff1a;平安夜&#xff0c;舞翩阡。雪花飘&#xff0c;飞满天。心与心&#xff0c;永相伴。 圣诞节是传统的宗教节日&#xff0c;对于基 督徒&…

前端自学你还在浪费时间吗?

其实最主要不是学的过程&#xff0c;而是学完后&#xff0c;你有没有把今天的练习题自己在重新敲个2&#xff0c;3遍&#xff0c;这样印象就会更加深刻&#xff0c;以后自己写代码的时候也会更加的得心应手。 手抄笔记让我打好了HTML基础和良好的CSS能力&#xff0c;当然这不一…

Cesium打包入门(gulp与esbuild)

本文针对Cesium源码包的打包工具gulp和esbuild进行了初步探讨&#xff0c;属于入门篇。 首先简要介绍采用gulpesbuild如何为多个源代码文件打包成一个单独文件&#xff0c;然后介绍了下Cesium中的源码包的结构&#xff0c;并简要分析了其打包的相关函数。 本文编译环境IDE使用…

【并发编程学习】一、线程的基本认识

一、线程的基本认识 1.1线程的基本介绍 线程是什么&#xff1f; 线程是操作系统能够进行运算调度的最小单位。它被包含在进程之中&#xff0c;是进程中的实际运行单位。 为什么会有多线程&#xff1f; ①因为其是CPU的最小调度单位&#xff0c;所以在多核CPU中&#xff0c…

圣诞节,深圳街头有点冷清了~

正文大家好&#xff0c;我是bug菌~今天是圣诞节&#xff0c;这也是我新冠康复的第二周了吧&#xff0c;还有点小咳嗽&#xff0c;伴随有点鼻炎&#xff0c;不过这周已经上了三天班了&#xff0c;整体感觉还算好吧&#xff0c;毕竟我嘴巴不硬&#xff0c;也比较低调不嚣张&#…

底层硬件创新夯实算力、应用创新贴近业务:英特尔至强助力下的VR医疗培训系统

早在1935年&#xff0c;科幻小说家斯坦利温鲍姆的小说《皮格马利翁的眼镜》中&#xff0c;就构想了一款实现虚拟现实&#xff08;VR&#xff09;的眼镜。近年来&#xff0c;除游戏、娱乐等大众熟知的应用场景外&#xff0c;VR逐渐涉足医疗、教育、生产制造等各种领域。 以医疗…

LeetCode-1759-统计同构子字符串的数目

1、数学 我们可以使用数学进行分析&#xff1a;每当出现连续的nnn个字符时&#xff0c;我们最终将其合在一起进行计算个数。显然我们可以获得的同构子字符串的个数应为n(n1)2\frac{n \times (n1)}{2}2n(n1)​。因此我们只需要遍历整个字符串&#xff0c;分别统计连续出现的字符…

57岛屿数量-61全排列 最长递增路径

57岛屿数量 矩阵中多处聚集着1&#xff0c;要想统计1聚集的堆数而不重复统计&#xff0c;那我们可以考虑每次找到一堆相邻的1&#xff0c;就将其全部改成0&#xff0c;而将所有相邻的1改成0的步骤又可以使用深度优先搜索&#xff08;dfs&#xff09;&#xff1a;当我们遇到矩阵…

AtCoder Beginner Contest 283 (A~F)

比赛名称&#xff1a;UNIQUE VISION Programming Contest 2022 Winter(AtCoder Beginner Contest 283) 比赛链接&#xff1a;AtCoder Beginner Contest 283 A - Power 题意&#xff1a; 求A^B(1<A,B<9) 要注意这个int强制转换&#xff0c;不然9^9输出结果时387420489&…

python根据json数据画疫情分布地图

目录 一.基础地图使用 1.掌握使用pyecharts构建基础的全国地图可视化图表 二.疫情地图——国内疫情地图 1.案例效果 代码 三.疫情地图——省级疫情地图 四.数据集 注&#xff1a;数据集在文章最后 一.基础地图使用 1.掌握使用pyecharts构建基础的全国地图可视化图表 演…

Learning to Segment Every Thing

摘要 现有的目标实例分割方法要求所有训练样本都具有分割mask标注。然而&#xff0c;标注新的类别是非常费劲的&#xff0c;因此这将实例分割模型的应用范围限制在100个左右的有标注的类。本文的目的是提出一种新的部分监督的训练模型&#xff0c;以及一种新的权重传递函数&am…

洛谷【算法1-7】搜索刷题——优化、错题

文章目录[USACO1.5]八皇后 Checker Challenge题目描述输入格式输出格式样例 #1样例输入 #1样例输出 #1提示思路搜索框架代码位运算优化lowbit运算思路kkksc03考前临时抱佛脚题目背景题目描述输入格式输出格式样例 #1样例输入 #1样例输出 #1提示思路代码吃奶酪题目描述输入格式输…

C++ STL 之可变长数组 Vector 详解

文章目录Part.I AttentionChap.I 注意事项Chap.II 操作技巧Part.II FunctionChap.I 构造函数Chap.II 增加函数Chap.III 删除函数Chap.IV 遍历函数Chap.V 判断/大小/其他函数Part.III CodePart.I Attention Chap.I 注意事项 使用vector需要注意的地方&#xff1a; 加引用#inc…

分布式与微服务系列 - SpringBoot + Zookeeper集群 + Dubbo分布式托管(提供者、消费者)+ Nginx反向代理

一、前言 本内容仅用于个人学习笔记&#xff0c;如有侵扰&#xff0c;联系删除 再搭建集群项目前&#xff0c;请先学习相关技术的知识&#xff1a; 分布式与微服务系列 - Dubbo分布式与微服务系列 - Zookeeper上篇&#xff1a;入门到精通参考文档&#xff1a;分布式与微服务…

状态机——奇葩的状态表示

状态机——奇葩的状态表示 简述 在动态规划中&#xff0c;遇到有一个点有多个状态&#xff0c;混在一起无法表示&#xff0c;那么就可以把状态分开&#xff0c;并且构造出不同状态之间的转移关系&#xff0c;然后再求出状态转移方程&#xff0c;之后就OK了。 题目 1049. 大…