Sending Multiple (Aggregate) Observations to Summary

16 views
Skip to first unread message

Oren

unread,
Jun 1, 2020, 9:38:23 AM6/1/20
to Prometheus Developers
Hi All,

Using the java client, one usually calls Summary.observe with one amount each call. 
In my case I'm timing the operations of an insert to the database, and those inserts are batches of a variable amount of records.
I cannot time each record insertion separately, and since the batches are of variable size, I would also not like to just time the batches.

I can use one of two approaches:
1. Time the batch, divide by the number of records in the batch, and call observe N times (where N is the number of records in the batch) with the average time.
2. Create two counters instead and just sum the times and records myself separately.

I was thinking that more elegantly a method for recording multiple observations could be added to Summary that would take both a total amount observed and an incrementation number, such that it would increment the counter by the incrementation number. That way Summary would handle this all itself and no workarounds would be necessary.

Any thoughts on this? Seems straightforward to implement, but maybe I'm going about it the wrong way.
Any comments or pointers for a first-timer are welcome.

Thanks,
Oren


Brian Brazil

unread,
Jun 1, 2020, 10:02:30 AM6/1/20
to Oren, Prometheus Developers
On Mon, 1 Jun 2020 at 14:38, Oren <oren.pa...@gmail.com> wrote:
Hi All,

Using the java client, one usually calls Summary.observe with one amount each call. 
In my case I'm timing the operations of an insert to the database, and those inserts are batches of a variable amount of records.
I cannot time each record insertion separately, and since the batches are of variable size, I would also not like to just time the batches.

I can use one of two approaches:
1. Time the batch, divide by the number of records in the batch, and call observe N times (where N is the number of records in the batch) with the average time.
2. Create two counters instead and just sum the times and records myself separately.

I was thinking that more elegantly a method for recording multiple observations could be added to Summary that would take both a total amount observed and an incrementation number, such that it would increment the counter by the incrementation number. That way Summary would handle this all itself and no workarounds would be necessary.

That wouldn't be quite right though, as it assumes that all of the observations are exactly the same size. Having separate counters/summary metrics for the batches and then times is usual. You can they do whatever math if appropriate in PromQL.

Brian
 

Any thoughts on this? Seems straightforward to implement, but maybe I'm going about it the wrong way.
Any comments or pointers for a first-timer are welcome.

Thanks,
Oren


--
You received this message because you are subscribed to the Google Groups "Prometheus Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-devel...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-developers/6987053c-2fb5-4b0f-b1da-e43a6686a639%40googlegroups.com.


--
Reply all
Reply to author
Forward
0 new messages