xref: /aosp_15_r20/external/perfetto/src/trace_processor/storage/stats.h (revision 6dbdd20afdafa5e3ca9b8809fa73465d530080dc)
1 /*
2  * Copyright (C) 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef SRC_TRACE_PROCESSOR_STORAGE_STATS_H_
18 #define SRC_TRACE_PROCESSOR_STORAGE_STATS_H_
19 
20 #include <cstddef>
21 
22 namespace perfetto::trace_processor::stats {
23 
24 // Compile time list of parsing and processing stats.
25 // clang-format off
26 #define PERFETTO_TP_STATS(F)                                                   \
27   F(android_br_parse_errors,              kSingle,  kError,    kTrace,    ""), \
28   F(android_log_num_failed,               kSingle,  kError,    kTrace,    ""), \
29   F(android_log_format_invalid,           kSingle,  kError,    kTrace,    ""), \
30   F(android_log_num_skipped,              kSingle,  kInfo,     kTrace,    ""), \
31   F(android_log_num_total,                kSingle,  kInfo,     kTrace,    ""), \
32   F(counter_events_out_of_order,          kSingle,  kError,    kAnalysis, ""), \
33   F(deobfuscate_location_parse_error,     kSingle,  kError,    kTrace,    ""), \
34   F(energy_breakdown_missing_values,      kSingle,  kError,    kAnalysis, ""), \
35   F(energy_descriptor_invalid,            kSingle,  kError,    kAnalysis, ""), \
36   F(entity_state_descriptor_invalid,      kSingle,  kError,    kAnalysis, ""), \
37   F(entity_state_residency_invalid,       kSingle,  kError,    kAnalysis, ""), \
38   F(entity_state_residency_lookup_failed, kSingle,  kError,    kAnalysis, ""), \
39   F(energy_uid_breakdown_missing_values,  kSingle,  kError,    kAnalysis, ""), \
40   F(frame_timeline_event_parser_errors,   kSingle,  kInfo,     kAnalysis, ""), \
41   F(frame_timeline_unpaired_end_event,    kSingle,  kInfo,     kAnalysis, ""), \
42   F(ftrace_bundle_tokenizer_errors,       kSingle,  kError,    kAnalysis, ""), \
43   F(ftrace_cpu_bytes_begin,               kIndexed, kInfo,     kTrace,    ""), \
44   F(ftrace_cpu_bytes_end,                 kIndexed, kInfo,     kTrace,    ""), \
45   F(ftrace_cpu_bytes_delta,               kIndexed, kInfo,     kTrace,    ""), \
46   F(ftrace_cpu_commit_overrun_begin,      kIndexed, kInfo,     kTrace,    ""), \
47   F(ftrace_cpu_commit_overrun_end,        kIndexed, kInfo,     kTrace,    ""), \
48   F(ftrace_cpu_commit_overrun_delta,      kIndexed, kError,    kTrace,    ""), \
49   F(ftrace_cpu_dropped_events_begin,      kIndexed, kInfo,     kTrace,    ""), \
50   F(ftrace_cpu_dropped_events_end,        kIndexed, kInfo,     kTrace,    ""), \
51   F(ftrace_cpu_dropped_events_delta,      kIndexed, kError,    kTrace,    ""), \
52   F(ftrace_cpu_entries_begin,             kIndexed, kInfo,     kTrace,    ""), \
53   F(ftrace_cpu_entries_end,               kIndexed, kInfo,     kTrace,    ""), \
54   F(ftrace_cpu_entries_delta,             kIndexed, kInfo,     kTrace,    ""), \
55   F(ftrace_cpu_now_ts_begin,              kIndexed, kInfo,     kTrace,    ""), \
56   F(ftrace_cpu_now_ts_end,                kIndexed, kInfo,     kTrace,    ""), \
57   F(ftrace_cpu_oldest_event_ts_begin,     kIndexed, kInfo,     kTrace,    ""), \
58   F(ftrace_cpu_oldest_event_ts_end,       kIndexed, kInfo,     kTrace,    ""), \
59   F(ftrace_cpu_overrun_begin,             kIndexed, kInfo,     kTrace,    ""), \
60   F(ftrace_cpu_overrun_end,               kIndexed, kInfo,     kTrace,    ""), \
61   F(ftrace_cpu_overrun_delta,             kIndexed, kInfo,     kTrace,    ""), \
62   F(ftrace_cpu_read_events_begin,         kIndexed, kInfo,     kTrace,    ""), \
63   F(ftrace_cpu_read_events_end,           kIndexed, kInfo,     kTrace,    ""), \
64   F(ftrace_cpu_read_events_delta,         kIndexed, kInfo,     kTrace,    ""), \
65   F(ftrace_cpu_has_data_loss,             kIndexed, kDataLoss, kTrace,         \
66        "Ftrace data for the given cpu has data losses and is therefore "       \
67        "unreliable. The kernel buffer overwrote events between our reads "     \
68        "in userspace. Try re-recording the trace with a bigger buffer "        \
69        "(ftrace_config.buffer_size_kb), or with fewer enabled ftrace events."),\
70   F(ftrace_kprobe_hits_begin,             kSingle,  kInfo,     kTrace,         \
71        "The number of kretprobe hits at the beginning of the trace."),         \
72   F(ftrace_kprobe_hits_end,               kSingle,  kInfo,     kTrace,         \
73        "The number of kretprobe hits at the end of the trace."),               \
74   F(ftrace_kprobe_hits_delta,             kSingle,  kInfo,     kTrace,         \
75        "The number of kprobe hits encountered during the collection of the"    \
76        "trace."),                                                              \
77   F(ftrace_kprobe_misses_begin,           kSingle,  kInfo,     kTrace,         \
78        "The number of kretprobe missed events at the beginning of the trace."),\
79   F(ftrace_kprobe_misses_end,             kSingle,  kInfo,     kTrace,         \
80        "The number of kretprobe missed events at the end of the trace."),      \
81   F(ftrace_kprobe_misses_delta,           kSingle,  kDataLoss, kTrace,         \
82        "The number of kretprobe missed events encountered during the "         \
83        "collection of the trace. A value greater than zero is due to the "     \
84        "maxactive parameter for the kretprobe being too small"),               \
85   F(ftrace_setup_errors,                  kSingle,  kInfo,     kTrace,         \
86        "One or more atrace/ftrace categories were not found or failed to "     \
87        "enable. See ftrace_setup_errors in the metadata table for details."),  \
88   F(ftrace_abi_errors_skipped_zero_data_length,                                \
89                                           kSingle,  kInfo,     kAnalysis, ""), \
90   F(ftrace_thermal_exynos_acpm_unknown_tz_id,                                  \
91                                           kSingle,  kError,    kAnalysis, ""), \
92   F(fuchsia_non_numeric_counters,         kSingle,  kError,    kAnalysis, ""), \
93   F(fuchsia_timestamp_overflow,           kSingle,  kError,    kAnalysis, ""), \
94   F(fuchsia_invalid_event,                kSingle,  kError,    kAnalysis, ""), \
95   F(gpu_counters_invalid_spec,            kSingle,  kError,    kAnalysis, ""), \
96   F(gpu_counters_missing_spec,            kSingle,  kError,    kAnalysis, ""), \
97   F(gpu_render_stage_parser_errors,       kSingle,  kError,    kAnalysis, ""), \
98   F(graphics_frame_event_parser_errors,   kSingle,  kInfo,     kAnalysis, ""), \
99   F(guess_trace_type_duration_ns,         kSingle,  kInfo,     kAnalysis, ""), \
100   F(interned_data_tokenizer_errors,       kSingle,  kInfo,     kAnalysis, ""), \
101   F(invalid_clock_snapshots,              kSingle,  kError,    kAnalysis, ""), \
102   F(invalid_cpu_times,                    kSingle,  kError,    kAnalysis, ""), \
103   F(meminfo_unknown_keys,                 kSingle,  kError,    kAnalysis, ""), \
104   F(mismatched_sched_switch_tids,         kSingle,  kError,    kAnalysis, ""), \
105   F(mm_unknown_type,                      kSingle,  kError,    kAnalysis, ""), \
106   F(parse_trace_duration_ns,              kSingle,  kInfo,     kAnalysis, ""), \
107   F(power_rail_unknown_index,             kSingle,  kError,    kTrace,    ""), \
108   F(proc_stat_unknown_counters,           kSingle,  kError,    kAnalysis, ""), \
109   F(rss_stat_unknown_keys,                kSingle,  kError,    kAnalysis, ""), \
110   F(rss_stat_negative_size,               kSingle,  kInfo,     kAnalysis, ""), \
111   F(rss_stat_unknown_thread_for_mm_id,    kSingle,  kInfo,     kAnalysis, ""), \
112   F(sched_switch_out_of_order,            kSingle,  kError,    kAnalysis, ""), \
113   F(slice_out_of_order,                   kSingle,  kError,    kAnalysis, ""), \
114   F(filter_input_bytes,                   kSingle,  kInfo,     kTrace,         \
115        "Number of bytes pre-TraceFilter. The trace file would have been this " \
116        "many bytes big if the TraceConfig didn't specify any TraceFilter. "    \
117        "This affects the actual buffer usage, as filtering happens only "      \
118        "when writing into the trace file (or over IPC)."),                     \
119   F(filter_input_packets,                 kSingle,  kInfo,     kTrace,         \
120        "Number of packets pre-TraceFilter. The trace file would have had so "  \
121        "many packets if the TraceConfig didn't specify any TraceFilter."),     \
122   F(filter_output_bytes,                  kSingle,  kInfo,     kTrace,         \
123        "Number of bytes that made it through the TraceFilter, before the "     \
124        "(optional) Zlib compression stage."),                                  \
125   F(filter_time_taken_ns,                 kSingle,  kInfo,     kTrace,         \
126        "Time cumulatively spent running the TraceFilter throughout the "       \
127        "tracing session by MaybeFilterPackets()."),                            \
128   F(filter_errors,                        kSingle,  kError,    kTrace,    ""), \
129   F(flow_duplicate_id,                    kSingle,  kError,    kTrace,    ""), \
130   F(flow_no_enclosing_slice,              kSingle,  kError,    kTrace,    ""), \
131   F(flow_step_without_start,              kSingle,  kInfo,     kTrace,    ""), \
132   F(flow_end_without_start,               kSingle,  kInfo,     kTrace,    ""), \
133   F(flow_invalid_id,                      kSingle,  kError,    kTrace,    ""), \
134   F(flow_without_direction,               kSingle,  kError,    kTrace,    ""), \
135   F(stackprofile_empty_callstack,         kSingle,  kError,    kTrace,         \
136       "Callstack had no frames. Ignored"),                                     \
137   F(stackprofile_invalid_string_id,       kSingle,  kError,    kTrace,    ""), \
138   F(stackprofile_invalid_mapping_id,      kSingle,  kError,    kTrace,    ""), \
139   F(stackprofile_invalid_frame_id,        kSingle,  kError,    kTrace,    ""), \
140   F(stackprofile_invalid_callstack_id,    kSingle,  kError,    kTrace,    ""), \
141   F(stackprofile_parser_error,            kSingle,  kError,    kTrace,    ""), \
142   F(systrace_parse_failure,               kSingle,  kError,    kAnalysis, ""), \
143   F(task_state_invalid,                   kSingle,  kError,    kAnalysis, ""), \
144   F(traced_buf_abi_violations,            kIndexed, kDataLoss, kTrace,    ""), \
145   F(traced_buf_buffer_size,               kIndexed, kInfo,     kTrace,    ""), \
146   F(traced_buf_bytes_overwritten,         kIndexed, kInfo,     kTrace,    ""), \
147   F(traced_buf_bytes_read,                kIndexed, kInfo,     kTrace,    ""), \
148   F(traced_buf_bytes_filtered_out,        kIndexed, kInfo,     kTrace,         \
149        "Number of bytes discarded (input - output) by the TraceFilter for "    \
150        "each buffer. It is a subset of, but does not add up perfectly to, "    \
151        "(filter_input_bytes - filter_output_bytes) because of the synthetic "  \
152        "metadata and stats packets generated by the tracing service itself."), \
153   F(traced_buf_bytes_written,             kIndexed, kInfo,     kTrace,    ""), \
154   F(traced_buf_chunks_discarded,          kIndexed, kInfo,     kTrace,    ""), \
155   F(traced_buf_chunks_overwritten,        kIndexed, kInfo,     kTrace,    ""), \
156   F(traced_buf_chunks_read,               kIndexed, kInfo,     kTrace,    ""), \
157   F(traced_buf_chunks_rewritten,          kIndexed, kInfo,     kTrace,    ""), \
158   F(traced_buf_chunks_written,            kIndexed, kInfo,     kTrace,    ""), \
159   F(traced_buf_chunks_committed_out_of_order,                                  \
160                                           kIndexed, kInfo,     kTrace,    ""), \
161   F(traced_buf_padding_bytes_cleared,     kIndexed, kInfo,     kTrace,    ""), \
162   F(traced_buf_padding_bytes_written,     kIndexed, kInfo,     kTrace,    ""), \
163   F(traced_buf_patches_failed,            kIndexed, kDataLoss, kTrace,         \
164       "The tracing service potentially lost data from one of the data sources "\
165       "writing into the given target_buffer. This entry can be ignored "       \
166       "if you're using DISCARD buffers and traced_buf_chunks_discarded is "    \
167       "nonzero, meaning that the buffer was filled."),                         \
168   F(traced_buf_patches_succeeded,         kIndexed, kInfo,     kTrace,    ""), \
169   F(traced_buf_readaheads_failed,         kIndexed, kInfo,     kTrace,    ""), \
170   F(traced_buf_readaheads_succeeded,      kIndexed, kInfo,     kTrace,    ""), \
171   F(traced_buf_trace_writer_packet_loss,  kIndexed, kDataLoss, kTrace,         \
172       "The tracing service observed packet loss for this buffer during this "  \
173       "tracing session. This also counts packet loss that happened before "    \
174       "the RING_BUFFER start or after the DISCARD buffer end."),               \
175   F(traced_buf_sequence_packet_loss,      kIndexed, kDataLoss, kAnalysis,      \
176       "The number of groups of consecutive packets lost in each sequence for " \
177       "this buffer"),                                                          \
178   F(traced_buf_incremental_sequences_dropped, kIndexed, kDataLoss, kAnalysis,  \
179       "For a given buffer, indicates the number of sequences where all the "   \
180       "packets on that sequence were dropped due to lack of a valid "          \
181       "incremental state (i.e. interned data). This is usually a strong sign " \
182       "that either: "                                                          \
183       "1) incremental state invalidation is disabled. "                        \
184       "2) the incremental state invalidation interval is too low. "            \
185       "In either case, see "                                                   \
186       "https://perfetto.dev/docs/concepts/buffers"                             \
187       "#incremental-state-in-trace-packets"),                                  \
188   F(traced_buf_write_wrap_count,          kIndexed, kInfo,     kTrace,    ""), \
189   F(traced_chunks_discarded,              kSingle,  kInfo,     kTrace,    ""), \
190   F(traced_data_sources_registered,       kSingle,  kInfo,     kTrace,    ""), \
191   F(traced_data_sources_seen,             kSingle,  kInfo,     kTrace,    ""), \
192   F(traced_final_flush_failed,            kSingle,  kDataLoss, kTrace,    ""), \
193   F(traced_final_flush_succeeded,         kSingle,  kInfo,     kTrace,    ""), \
194   F(traced_flushes_failed,                kSingle,  kDataLoss, kTrace,    ""), \
195   F(traced_flushes_requested,             kSingle,  kInfo,     kTrace,    ""), \
196   F(traced_flushes_succeeded,             kSingle,  kInfo,     kTrace,    ""), \
197   F(traced_patches_discarded,             kSingle,  kInfo,     kTrace,    ""), \
198   F(traced_producers_connected,           kSingle,  kInfo,     kTrace,    ""), \
199   F(traced_producers_seen,                kSingle,  kInfo,     kTrace,    ""), \
200   F(traced_total_buffers,                 kSingle,  kInfo,     kTrace,    ""), \
201   F(traced_tracing_sessions,              kSingle,  kInfo,     kTrace,    ""), \
202   F(track_event_parser_errors,            kSingle,  kInfo,     kAnalysis, ""), \
203   F(track_event_dropped_packets_outside_of_range_of_interest,                  \
204                                           kSingle,  kInfo,     kAnalysis,      \
205       "The number of TrackEvent packets dropped by trace processor due to "    \
206       "being outside of the range of interest. This happens if a trace has a " \
207       "TrackEventRangeOfInterest packet, and track event dropping is "         \
208       "enabled."),                                                             \
209   F(track_event_tokenizer_errors,         kSingle,  kInfo,     kAnalysis, ""), \
210   F(track_event_thread_invalid_end,       kSingle,  kError,    kTrace,         \
211       "The end event for a thread track does not match a track event "         \
212       "begin event. This can happen on mixed atrace/track_event traces "       \
213       "and is usually caused by data loss or bugs when the events are "        \
214       "emitted. The outcome of this is that slices can appear to be closed "   \
215       "before they were closed in reality"),                                   \
216   F(tokenizer_skipped_packets,            kSingle,  kInfo,     kAnalysis, ""), \
217   F(vmstat_unknown_keys,                  kSingle,  kError,    kAnalysis, ""), \
218   F(psi_unknown_resource,                 kSingle,  kError,    kAnalysis, ""), \
219   F(vulkan_allocations_invalid_string_id,                                      \
220                                           kSingle,  kError,    kTrace,    ""), \
221   F(clock_sync_failure,                   kSingle,  kError,    kAnalysis, ""), \
222   F(clock_sync_cache_miss,                kSingle,  kInfo,     kAnalysis, ""), \
223   F(process_tracker_errors,               kSingle,  kError,    kAnalysis, ""), \
224   F(json_tokenizer_failure,               kSingle,  kError,    kTrace,    ""), \
225   F(json_parser_failure,                  kSingle,  kError,    kTrace,    ""), \
226   F(json_display_time_unit,               kSingle,  kInfo,     kTrace,         \
227       "The displayTimeUnit key was set in the JSON trace. In some prior "      \
228       "versions of trace processor this key could effect how the trace "       \
229       "processor parsed timestamps and durations. In this version the key is " \
230       "ignored which more closely matches the bavahiour of catapult."),        \
231   F(heap_graph_invalid_string_id,         kIndexed, kError,    kTrace,    ""), \
232   F(heap_graph_non_finalized_graph,       kSingle,  kError,    kTrace,    ""), \
233   F(heap_graph_malformed_packet,          kIndexed, kError,    kTrace,    ""), \
234   F(heap_graph_missing_packet,            kIndexed, kError,    kTrace,    ""), \
235   F(heapprofd_buffer_corrupted,           kIndexed, kError,    kTrace,         \
236       "Shared memory buffer corrupted. This is a bug or memory corruption "    \
237       "in the target. Indexed by target upid."),                               \
238   F(heapprofd_hit_guardrail,              kIndexed, kError,    kTrace,         \
239       "HeapprofdConfig specified a CPU or Memory Guardrail that was hit. "     \
240       "Indexed by target upid."),                                              \
241   F(heapprofd_buffer_overran,             kIndexed, kDataLoss, kTrace,         \
242       "The shared memory buffer between the target and heapprofd overran. "    \
243       "The profile was truncated early. Indexed by target upid."),             \
244   F(heapprofd_client_error,               kIndexed, kError,    kTrace,         \
245       "The heapprofd client ran into a problem and disconnected. "             \
246       "See profile_packet.proto  for error codes."),                           \
247   F(heapprofd_client_disconnected,        kIndexed, kInfo,     kTrace,    ""), \
248   F(heapprofd_malformed_packet,           kIndexed, kError,    kTrace,    ""), \
249   F(heapprofd_missing_packet,             kSingle,  kError,    kTrace,    ""), \
250   F(heapprofd_rejected_concurrent,        kIndexed, kError,    kTrace,         \
251       "The target was already profiled by another tracing session, so the "    \
252       "profile was not taken. Indexed by target upid."),                       \
253   F(heapprofd_non_finalized_profile,      kSingle,  kError,    kTrace,    ""), \
254   F(heapprofd_sampling_interval_adjusted,                                      \
255     kIndexed, kInfo,    kTrace,                                                \
256       "By how many byes the interval for PID was increased "                   \
257       "by adaptive sampling."),                                                \
258   F(heapprofd_unwind_time_us,             kIndexed, kInfo,     kTrace,         \
259       "Time spent unwinding callstacks."),                                     \
260   F(heapprofd_unwind_samples,             kIndexed, kInfo,     kTrace,         \
261       "Number of samples unwound."),                                           \
262   F(heapprofd_client_spinlock_blocked,    kIndexed, kInfo,     kTrace,         \
263        "Time (us) the heapprofd client was blocked on the spinlock."),         \
264   F(heapprofd_last_profile_timestamp,     kIndexed, kInfo,     kTrace,         \
265        "The timestamp (in trace time) for the last dump for a process"),       \
266   F(symbolization_tmp_build_id_not_found,     kSingle,  kError,    kAnalysis,  \
267        "Number of file mappings in /data/local/tmp without a build id. "       \
268        "Symbolization doesn't work for executables in /data/local/tmp "        \
269        "because of SELinux. Please use /data/local/tests"),                    \
270   F(metatrace_overruns,                   kSingle,  kError,    kTrace,    ""), \
271   F(packages_list_has_parse_errors,       kSingle,  kError,    kTrace,    ""), \
272   F(packages_list_has_read_errors,        kSingle,  kError,    kTrace,    ""), \
273   F(game_intervention_has_parse_errors,   kSingle,  kError,    kTrace,         \
274        "One or more parsing errors occurred. This could result from "          \
275        "unknown game more or intervention added to the file to be parsed."),   \
276   F(game_intervention_has_read_errors,    kSingle,  kError,    kTrace,         \
277        "The file to be parsed can't be opened. This can happend when "         \
278        "the file name is not found or no permission to access the file"),      \
279   F(compact_sched_has_parse_errors,       kSingle,  kError,    kTrace,    ""), \
280   F(misplaced_end_event,                  kSingle,  kDataLoss, kAnalysis, ""), \
281   F(truncated_sys_write_duration,         kSingle,  kInfo,     kAnalysis,      \
282       "Count of sys_write slices that have a truncated duration to resolve "   \
283       "nesting incompatibilities with atrace slices. Real durations "          \
284       "can be recovered via the |raw| table."),                                \
285   F(sched_waking_out_of_order,            kSingle,  kError,    kAnalysis, ""), \
286   F(compact_sched_switch_skipped,         kSingle,  kInfo,     kAnalysis, ""), \
287   F(compact_sched_waking_skipped,         kSingle,  kInfo,     kAnalysis, ""), \
288   F(empty_chrome_metadata,                kSingle,  kError,    kTrace,    ""), \
289   F(ninja_parse_errors,                   kSingle,  kError,    kTrace,    ""), \
290   F(perf_cpu_lost_records,                kIndexed, kDataLoss, kTrace,         \
291       "Count of perf samples lost due to kernel buffer overruns. The trace "   \
292       "is missing information, but it's not known which processes are "        \
293       "affected. Consider lowering the sampling frequency or raising "         \
294       "the ring_buffer_pages config option."),                                 \
295   F(perf_process_shard_count,             kIndexed, kInfo,     kTrace,    ""), \
296   F(perf_chosen_process_shard,            kIndexed, kInfo,     kTrace,    ""), \
297   F(perf_guardrail_stop_ts,               kIndexed, kDataLoss, kTrace,    ""), \
298   F(perf_unknown_record_type,             kIndexed, kInfo,     kAnalysis, ""), \
299   F(perf_record_skipped,                  kIndexed, kError,    kAnalysis, ""), \
300   F(perf_samples_skipped,                 kSingle,  kError,    kAnalysis,      \
301       "Count of skipped perf samples that otherwise matched the tracing "      \
302       "config. This will cause a process to be completely absent from the "    \
303       "trace, but does *not* imply data loss for processes that do have "      \
304       "samples in this trace."),                                               \
305   F(perf_counter_skipped_because_no_cpu,  kSingle,  kError,    kAnalysis, ""), \
306   F(perf_features_skipped,                kIndexed, kInfo,     kAnalysis, ""), \
307   F(perf_samples_cpu_mode_unknown,        kSingle,  kError,    kAnalysis, ""), \
308   F(perf_samples_skipped_dataloss,        kSingle,  kDataLoss, kTrace,         \
309       "Count of perf samples lost within the profiler (traced_perf), likely "  \
310       "due to load shedding. This may impact any traced processes. The trace " \
311       "protobuf needs to be inspected manually to confirm which processes "    \
312       "are affected."),                                                        \
313   F(perf_dummy_mapping_used,              kSingle,  kInfo,     kAnalysis, ""), \
314   F(perf_aux_missing,                     kSingle,  kDataLoss, kTrace,         \
315       "Number of bytes missing in AUX data streams due to missing "            \
316       "PREF_RECORD_AUX messages."),                                            \
317   F(perf_aux_ignored,                     kSingle,  kInfo,     kTrace,         \
318        "AUX data was ignored because the proper parser is not implemented."), \
319   F(perf_aux_lost,                        kSingle,  kDataLoss, kTrace,         \
320       "Gaps in the AUX data stream pased to the tokenizer."), \
321   F(perf_aux_truncated,                   kSingle,  kDataLoss, kTrace,         \
322       "Data was truncated when being written to the AUX stream at the "        \
323       "source."),\
324   F(perf_aux_partial,                     kSingle,  kDataLoss, kTrace,         \
325       "The PERF_RECORD_AUX contained partial data."), \
326   F(perf_aux_collision,                   kSingle,  kDataLoss, kTrace,         \
327       "The collection of a sample colliden with another. You should reduce "   \
328       "the rate at which samples are collected."),                             \
329   F(perf_auxtrace_missing,                kSingle,  kDataLoss, kTrace,         \
330       "Number of bytes missing in AUX data streams due to missing "            \
331       "PREF_RECORD_AUXTRACE messages."),                                       \
332   F(perf_unknown_aux_data,                kIndexed, kDataLoss, kTrace,         \
333       "AUX data type encountered for which there is no known parser."),        \
334   F(perf_no_tsc_data,                     kSingle,  kInfo,     kTrace,         \
335       "TSC data unavailable. Will be unable to translate HW clocks."),         \
336   F(spe_no_timestamp,                     kSingle,  kInfo,     kTrace,         \
337       "SPE record with no timestamp. Will try our best to assign a "           \
338       "timestamp."),                                                           \
339   F(spe_record_dropped,                   kSingle,  kDataLoss, kTrace,         \
340       "SPE record dropped. E.g. Unable to assign it a timestamp."),            \
341   F(etm_no_importer,                      kSingle,  kError,    kAnalysis,      \
342       "Unable to parse ETM data because TraceProcessor was not compiled to  "  \
343       " support it. Make sure you enable the `enable_perfetto_etm_importer` "  \
344       " GN flag."),                                                            \
345   F(memory_snapshot_parser_failure,       kSingle,  kError,    kAnalysis, ""), \
346   F(thread_time_in_state_out_of_order,    kSingle,  kError,    kAnalysis, ""), \
347   F(thread_time_in_state_unknown_cpu_freq,                                     \
348                                           kSingle,  kError,    kAnalysis, ""), \
349   F(ftrace_packet_before_tracing_start,   kSingle,  kInfo,     kAnalysis,      \
350       "An ftrace packet was seen before the tracing start timestamp from "     \
351       "the tracing service. This happens if the ftrace buffers were not "      \
352       "cleared properly. These packets are silently dropped by trace "         \
353       "processor."),                                                           \
354   F(sorter_push_event_out_of_order,       kSingle, kError,     kTrace,         \
355       "Trace events are out of order event after sorting. This can happen "    \
356       "due to many factors including clock sync drift, producers emitting "    \
357       "events out of order or a bug in trace processor's logic of sorting."),  \
358   F(unknown_extension_fields,             kSingle,  kError,    kTrace,         \
359       "TraceEvent had unknown extension fields, which might result in "        \
360       "missing some arguments. You may need a newer version of trace "         \
361       "processor to parse them."),                                             \
362   F(network_trace_intern_errors,          kSingle,  kInfo,     kAnalysis, ""), \
363   F(network_trace_parse_errors,           kSingle,  kInfo,     kAnalysis, ""), \
364   F(atom_timestamp_missing,               kSingle,  kError,    kTrace,         \
365       "The corresponding timestamp_nanos entry for a StatsdAtom was "          \
366       "missing. Defaulted to inaccurate packet timestamp."),                   \
367   F(atom_unknown,                         kSingle,  kInfo,     kAnalysis,      \
368       "Unknown statsd atom. Atom descriptor may need to be updated"),          \
369   F(v8_intern_errors,                                                          \
370                                           kSingle,  kDataLoss, kAnalysis,      \
371       "Failed to resolve V8 interned data."),                                  \
372   F(v8_isolate_has_no_code_range,                                              \
373                                           kSingle,  kError,    kAnalysis,      \
374       "V8 isolate had no code range. THis is currently no supported and means" \
375       "we will be unable to parse JS code events for this isolate."),          \
376   F(v8_no_defaults,                                                            \
377                                           kSingle,  kDataLoss, kAnalysis,      \
378       "Failed to resolve V8 default data."),                                   \
379   F(v8_no_code_range,                                                          \
380                                           kSingle,  kError,    kAnalysis,      \
381       "V8 isolate had no code range."),                                        \
382   F(v8_unknown_code_type,                 kSingle,  kError,    kAnalysis, ""), \
383   F(v8_code_load_missing_code_range,      kSingle,  kError,    kAnalysis,      \
384       "V8 load had no code range or an empty one. Event ignored."),            \
385   F(winscope_inputmethod_clients_parse_errors,                                 \
386                                           kSingle,  kInfo,     kAnalysis,      \
387       "InputMethod clients packet has unknown fields, which results in "       \
388       "some arguments missing. You may need a newer version of trace "         \
389       "processor to parse them."),                                             \
390   F(winscope_inputmethod_manager_service_parse_errors,                         \
391                                           kSingle,  kInfo,     kAnalysis,      \
392       "InputMethod manager service packet has unknown fields, which results "  \
393       "in some arguments missing. You may need a newer version of trace "      \
394       "processor to parse them."),                                             \
395   F(winscope_inputmethod_service_parse_errors,                                 \
396                                           kSingle,  kInfo,     kAnalysis,      \
397       "InputMethod service packet has unknown fields, which results in "       \
398       "some arguments missing. You may need a newer version of trace "         \
399       "processor to parse them."),                                             \
400   F(winscope_sf_layers_parse_errors,      kSingle,  kInfo,     kAnalysis,      \
401       "SurfaceFlinger layers snapshot has unknown fields, which results in "   \
402       "some arguments missing. You may need a newer version of trace "         \
403       "processor to parse them."),                                             \
404   F(winscope_sf_transactions_parse_errors,                                     \
405                                           kSingle,  kInfo,     kAnalysis,      \
406       "SurfaceFlinger transactions packet has unknown fields, which results "  \
407       "in some arguments missing. You may need a newer version of trace "      \
408       "processor to parse them."),                                             \
409   F(winscope_shell_transitions_parse_errors,                                   \
410                                           kSingle,  kInfo,     kAnalysis,      \
411       "Shell transition packet has unknown fields, which results "             \
412       "in some arguments missing. You may need a newer version of trace "      \
413       "processor to parse them."),                                             \
414   F(winscope_protolog_invalid_interpolation_parse_errors,                      \
415                                           kSingle,  kInfo,     kAnalysis,      \
416       "ProtoLog message string has invalid interplation parameter."),          \
417   F(winscope_protolog_missing_interned_arg_parse_errors,                       \
418                                           kSingle,  kInfo,     kAnalysis,      \
419       "Failed to find interned ProtoLog argument."),                           \
420   F(winscope_protolog_missing_interned_stacktrace_parse_errors,                \
421                                           kSingle,  kInfo,     kAnalysis,      \
422       "Failed to find interned ProtoLog stacktrace."),                         \
423   F(winscope_protolog_message_decoding_failed,                                 \
424                                           kSingle,  kInfo,     kAnalysis,      \
425       "Failed to decode ProtoLog message."),                                   \
426   F(winscope_protolog_view_config_collision,                                   \
427                                           kSingle,  kInfo,     kAnalysis,      \
428       "Got a viewer config collision!"),                                       \
429   F(winscope_viewcapture_parse_errors,                                         \
430                                           kSingle,  kInfo,     kAnalysis,      \
431       "ViewCapture packet has unknown fields, which results in some "          \
432       "arguments missing. You may need a newer version of trace processor "    \
433       "to parse them."),                                                       \
434   F(winscope_viewcapture_missing_interned_string_parse_errors,                 \
435                                           kSingle,  kInfo,     kAnalysis,      \
436       "Failed to find interned ViewCapture string."),                          \
437   F(winscope_windowmanager_parse_errors, kSingle,  kInfo,     kAnalysis,       \
438       "WindowManager state packet has unknown fields, which results "          \
439       "in some arguments missing. You may need a newer version of trace "      \
440       "processor to parse them."),                                             \
441   F(jit_unknown_frame,                    kSingle,  kDataLoss, kTrace,         \
442       "Indicates that we were unable to determine the function for a frame in "\
443       "a jitted memory region"),                                               \
444   F(ftrace_missing_event_id,              kSingle,  kInfo,    kAnalysis,       \
445       "Indicates that the ftrace event was dropped because the event id was "  \
446       "missing. This is an 'info' stat rather than an error stat because "     \
447       "this can be legitimately missing due to proto filtering."),             \
448   F(android_input_event_parse_errors,     kSingle,  kInfo,     kAnalysis,      \
449       "Android input event packet has unknown fields, which results "          \
450       "in some arguments missing. You may need a newer version of trace "      \
451       "processor to parse them."),                                             \
452   F(mali_unknown_mcu_state_id,            kSingle,  kError,   kAnalysis,       \
453       "An invalid Mali GPU MCU state ID was detected."),                       \
454   F(pixel_modem_negative_timestamp,       kSingle,  kError,   kAnalysis,       \
455       "A negative timestamp was received from a Pixel modem event."),          \
456   F(legacy_v8_cpu_profile_invalid_callsite, kSingle,  kInfo,  kAnalysis,       \
457       "Indicates a callsite in legacy v8 CPU profiling is invalid."),          \
458   F(legacy_v8_cpu_profile_invalid_sample, kSingle,  kError,  kAnalysis,        \
459       "Indicates a sample in legacy v8 CPU profile is invalid. This will "     \
460       "cause CPU samples to be missing in the UI."),                           \
461   F(config_write_into_file_no_flush,      kSingle,  kError,  kTrace,           \
462       "The trace was collected with the `write_into_file` option set but "     \
463       "*without* `flush_period_ms` being set. This will cause the trace to "   \
464       "be fully loaded into memory and use significantly more memory than "    \
465       "necessary."),                                                           \
466   F(config_write_into_file_discard,        kIndexed,  kDataLoss,  kTrace,      \
467       "The trace was collected with the `write_into_file` option set but "     \
468       "uses a `DISCARD` buffer. This configuration is strongly discouraged "   \
469       "and can cause mysterious data loss in the trace. Please use "           \
470       "`RING_BUFFER` buffers instead.")
471 // clang-format on
472 
473 enum Type {
474   kSingle,  // Single-value property, one value per key.
475   kIndexed  // Indexed property, multiple value per key (e.g. cpu_stats[1]).
476 };
477 
478 enum Severity {
479   kInfo,      // Diagnostic counters
480   kDataLoss,  // Correct operation that still resulted in data loss
481   kError      // If any kError counter is > 0 trace_processor_shell will
482               // raise an error. This is also surfaced in the web UI.
483 };
484 
485 enum Source {
486   // The counter is collected when recording the trace on-device and is just
487   // being reflected in the stats table.
488   kTrace,
489 
490   // The counter is generated when importing / processing the trace in the trace
491   // processor.
492   kAnalysis
493 };
494 
495 // Ignore GCC warning about a missing argument for a variadic macro parameter.
496 #if defined(__GNUC__) || defined(__clang__)
497 #pragma GCC system_header
498 #endif
499 
500 // Declares an enum of literals (one for each stat). The enum values of each
501 // literal corresponds to the string index in the arrays below.
502 #define PERFETTO_TP_STATS_ENUM(name, ...) name
503 enum KeyIDs : size_t { PERFETTO_TP_STATS(PERFETTO_TP_STATS_ENUM), kNumKeys };
504 
505 // The code below declares an array for each property (name, type, ...).
506 
507 #define PERFETTO_TP_STATS_NAME(name, ...) #name
508 constexpr char const* kNames[] = {PERFETTO_TP_STATS(PERFETTO_TP_STATS_NAME)};
509 
510 #define PERFETTO_TP_STATS_TYPE(_, type, ...) type
511 constexpr Type kTypes[] = {PERFETTO_TP_STATS(PERFETTO_TP_STATS_TYPE)};
512 
513 #define PERFETTO_TP_STATS_SEVERITY(_, __, severity, ...) severity
514 constexpr Severity kSeverities[] = {
515     PERFETTO_TP_STATS(PERFETTO_TP_STATS_SEVERITY)};
516 
517 #define PERFETTO_TP_STATS_SOURCE(_, __, ___, source, ...) source
518 constexpr Source kSources[] = {PERFETTO_TP_STATS(PERFETTO_TP_STATS_SOURCE)};
519 
520 #define PERFETTO_TP_STATS_DESCRIPTION(_, __, ___, ____, descr, ...) descr
521 constexpr char const* kDescriptions[] = {
522     PERFETTO_TP_STATS(PERFETTO_TP_STATS_DESCRIPTION)};
523 
524 }  // namespace perfetto::trace_processor::stats
525 
526 #endif  // SRC_TRACE_PROCESSOR_STORAGE_STATS_H_
527