perfetto icon indicating copy to clipboard operation
perfetto copied to clipboard

[examples]: example of a histogram counter

Open bsarden opened this issue 3 years ago • 3 comments

Hello! I'm looking for good examples of how others have used the TRACE_COUNTER macro in order to implement a basic histogram / metrics API for application observability. Ideally, something lightweight (i.e. not UMA) would be great to have in the //examples directory.

Thanks in advance!

bsarden avatar Jul 11 '22 14:07 bsarden

cc @skyostil @betasheet @ddiproietto for the SDK

chromy avatar Jul 11 '22 15:07 chromy

@chromy From diving in a little deeper, it looks like there are already some Histogram types exposed in different protos upstream (e.g., ProfilePacket). However, it's not clear to me how to utilize them within the SDK. Maybe something like the example below would be useful to have upstream.

perfetto::HistogramTrack my_hist (/*num_buckets=*/kMaxBuckets);
TRACE_HIST("mycategory", my_hist, <sample>);
TRACE_HIST("mycategory", my_hist, <sample>, <bin>);

Where the underlying Histogram bin calculator function is configurable somehow. Looking forward to some example links!

CC @skyostil @betasheet @ddiproietto

bsarden avatar Jul 13 '22 02:07 bsarden

I believe the only current supported use of TRACE_COUNTER is a simple numeric value counter (see example in docs). There's no support for histogram counters (yet).

betasheet avatar Jul 28 '22 12:07 betasheet