• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1
2## TS解析htrace数据时间戳的规则
3ProfilerPluginData是所有proto格式数据插件的最外层message。
4其中包含多个时间戳。根据name字段反序列化的data字段中包含一个时间戳,一般为具体事件发生的时刻;另外tv_sec, tv_nsec号数据域组成最外层的时间戳,一般为端侧使用该插件采集数据上报的时刻。
5在一些需要精确展示事件时间的业务中, 采用的是data中的时间; 在一些周期性采集统计数据的业务(如:进程的内存数据)中使用的是最外层tv_sec, tv_nsec.
6message ProfilerPluginData {
7    string name = 1;
8    uint32 status = 2;
9    bytes data = 3;
10    enum ClockId {
11        CLOCKID_REALTIME = 0;
12        CLOCKID_REALTIME_ALARM = 1;     // since Linux 3.0; Linux-specific
13        CLOCKID_REALTIME_COARSE = 2;    // since Linux 2.6.32; Linux-specific
14        CLOCKID_TAI = 3;                // since Linux 3.10; Linux-specific
15        CLOCKID_MONOTONIC = 4;
16        CLOCKID_MONOTONIC_COARSE = 5;   // since Linux 2.6.32; Linux-specific
17        CLOCKID_MONOTONIC_RAW = 6;      // since Linux 2.6.28; Linux-specific
18        CLOCKID_BOOTTIME = 7;           // since Linux 2.6.39; Linux-specific
19        CLOCKID_BOOTTIME_ALARM = 8;     // since Linux 3.0; Linux-specific
20        CLOCKID_PROCESS_CPUTIME_ID = 9; // since Linux 2.6.12
21        CLOCKID_THREAD_CPUTIME_ID = 10; // since Linux 2.6.12
22    };
23    ClockId clock_id = 4;
24    uint64 tv_sec = 5;
25    uint64 tv_nsec = 6;
26    string version = 7; // "1.01"
27}
28
29## 解析不同插件数据使用的时间戳对照表
30<table>
31    <tr>
32        <td></td>
33        <td>对应的插件</td>
34        <td>对应的业务说明</td>
35    </tr>
36    <tr>
37        <td rowspan="4">使用ProfilerPluginData.data中的时间戳</td>
38        <td>ftrace-plugin</td>
39        <td>ftrace</td>
40    </tr>
41    <tr>
42        <td>hilog-plugin</td>
43        <td>hilog日志</td>
44    </tr>
45    <tr>
46        <td>nativehook</td>
47        <td>native_memory(malloc, free, mmap,munmap, 统计事件)</td>
48    </tr>
49    <tr>
50        <td>hidump-plugin</td>
51        <td>fps</td>
52    </tr>
53    <tr>
54        <td rowspan="6">使用ProfilerPluginData.tv_sectv_nsec/td>
55        <td>memory-plugin</td>
56        <td>系统内存</td>
57    </tr>
58    <tr>
59        <td>network-plugin</td>
60        <td>网络</td>
61    </tr>
62    <tr>
63        <td>cpu-plugin</td>
64        <td>cpu占用率</td>
65    </tr>
66    <tr>
67        <td>process-plugin</td>
68        <td>进程内存</td>
69    </tr>
70    <tr>
71        <td>diskio-plugin</td>
72        <td>磁盘读写速率</td>
73    </tr>
74    <tr>
75        <td>hisysevent-plugin</td>
76        <td>hisysevent</td>
77    </tr>
78</table>