Sha256: 241c0b385ea4bcd10c2719ecf5ed594f3563cc4a804843ccfb12b2012d1c6be6

Contents?: true

Size: 693 Bytes

Versions: 1

Compression:

Stored size: 693 Bytes

Contents

# frozen_string_literal: true

module DDTelemetry
  class LabelledSummary
    def initialize
      @summaries = {}
    end

    def observe(value, label)
      get(label).observe(value)
    end

    def get(label)
      @summaries.fetch(label) { @summaries[label] = Summary.new }
    end

    def empty?
      @summaries.empty?
    end

    def quantile(fraction, label)
      get(label).quantile(fraction)
    end

    def map
      @summaries.map { |(label, summary)| yield(label, summary) }
    end

    # TODO: add quantiles(fraction)
    # TODO: add min(label)
    # TODO: add mins
    # TODO: add max(label)
    # TODO: add maxs
    # TODO: add sum(label)
    # TODO: add sums
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ddtelemetry-1.0.0a1 lib/ddtelemetry/labelled_summary.rb