Program Listing for File base2_exponential_histogram_indexer.h

Return to documentation for file (/home/docs/checkouts/readthedocs.org/user_builds/opentelemetry-cpp/checkouts/stable/sdk/include/opentelemetry/sdk/metrics/aggregation/base2_exponential_histogram_indexer.h)

// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#pragma once

#include "opentelemetry/version.h"

#include <cstdint>

OPENTELEMETRY_BEGIN_NAMESPACE
namespace sdk
{
namespace metrics
{

/*
 * An indexer for base2 exponential histograms. It is used to calculate index for a given value and
 * scale.
 */
class Base2ExponentialHistogramIndexer
{
public:
  /*
   * Construct a new indexer for a given scale.
   */
  explicit Base2ExponentialHistogramIndexer(int32_t scale = 0);
  Base2ExponentialHistogramIndexer(const Base2ExponentialHistogramIndexer &other) = default;
  Base2ExponentialHistogramIndexer &operator=(const Base2ExponentialHistogramIndexer &other) =
      default;

  int32_t ComputeIndex(double value) const;

private:
  int32_t scale_;
  double scale_factor_;
};

}  // namespace metrics
}  // namespace sdk
OPENTELEMETRY_END_NAMESPACE