title: How to correctly use Prometheus Histogram from java client to track size rather than latency?
body: <p>I have an API that that processes collections. 
  The execution time of this API is related to the collection size (the larger the collection, the more it will take).</p>
  
  <p>I am researching how can I do this with prometheus but am unsure whether I am doing things correctly (documentation is a bit lacking in this area).</p>
  
  <p>the first thing I did is define a Summary metric to measure execution time of the API. I am using the canonical rate(sum)/rate(count) as explained <a href="https://prometheus.io/docs/practices/histograms/" rel="noreferrer">here</a>.</p>
  
  <p>Now, since I know that the latency may be affected by the size of the input, I also want to overlay the request <em>size</em> on the avg execution time. Since I dont want to measure each possible size, I figured I'd use a histogram. Like so:</p>
  
  <pre><code>Histogram histogram = Histogram.build().buckets(10, 30, 50)
          .name("BULK_REQUEST_SIZE")
          .help("histogram of bulk sizes to correlate with duration")
          .labelNames("method", "entity")
          .register();
  </code></pre>
  
  <p><strong>Note</strong>: the term 'size' does <em>not</em> relate to the size in bytes but to the <em>length</em> of the collection that needs to be processed. 2 items, 5 items, 50 items...</p>
  
  <p>and in the execution I do (simplified):</p>
  
  <pre><code>@PUT
  void process(Collection&lt;Entity&gt; entitiesToProcess, string entityName){
     Timer t = summary.labels("PUT_BULK", entityName).startTimer()
  
        // process...
  
     t.observeDuration();
     histogram.labels("PUT_BULK", entityName).observe(entitiesToProcess.size())
  }
  </code></pre>
  
  <p>Question:</p>
  
  <ul>
  <li>Later when I am looking at the BULK_REQUEST_SIZE_bucket in Grafana, I see that all buckets have the same value, so clearly I am doing something wrong.</li>
  <li>Is there a more canonical way to do it?</li>
  </ul>