census-instrumentation / opencensus-service

OpenCensus service allows OpenCensus libraries to export to an exporter service rather than having to link vendor-specific exports.
Apache License 2.0
153 stars 63 forks source link

"quantile" not supported for histogram type. #645

Closed LukeCz closed 2 years ago

LukeCz commented 2 years ago

Hi, Quantile support was added to summary with https://github.com/census-instrumentation/opencensus-service/commit/b5a7ae3017eb4e377cced3507d819b7ab72803a1 but not to histogram. According to Prometheus docs "You can use both summaries and histograms to calculate so-called φ-quantiles" - https://prometheus.io/docs/practices/histograms/#quantiles.

Java allows adding quantiles to histogram

 @Bean(name = BEAN_GC_STORAGE_LOAD_TIME)
  public Timer timerGcsLoadTime() {
    return Timer.builder(BEAN_GC_STORAGE_LOAD_TIME)
        .description(
            "This timer is used to calculate time for load operation from Google Cloud Storage")
        .publishPercentiles(0.5, 0.95)
        .publishPercentileHistogram(true)
        .register(meterRegistry);
  }

Example:

# HELP test_gc_storage_load_time_seconds This timer is used to calculate time for load operation from Google Cloud Storage
# TYPE test_gc_storage_load_time_seconds histogram
test_gc_storage_load_time_seconds{quantile="0.5",} 0.0
test_gc_storage_load_time_seconds{quantile="0.95",} 0.0
test_gc_storage_load_time_seconds_bucket{le="0.001",} 0.0
test_gc_storage_load_time_seconds_bucket{le="0.001048576",} 0.0
test_gc_storage_load_time_seconds_bucket{le="0.001398101",} 0.0