Program Listing for File metric_producer.h

Return to documentation for file (/home/docs/checkouts/readthedocs.org/user_builds/opentelemetry-cpp/checkouts/v1.8.3/sdk/include/opentelemetry/sdk/metrics/export/metric_producer.h)

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

#pragma once

#include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h"
#include "opentelemetry/sdk/metrics/data/metric_data.h"
#include "opentelemetry/sdk/resource/resource.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace sdk
{
namespace metrics
{

struct ScopeMetrics
{
  const opentelemetry::sdk::instrumentationscope::InstrumentationScope *scope_;
  std::vector<MetricData> metric_data_;
};

struct ResourceMetrics
{
  const opentelemetry::sdk::resource::Resource *resource_;
  std::vector<ScopeMetrics> scope_metric_data_;
};

class MetricProducer
{
public:
  MetricProducer()          = default;
  virtual ~MetricProducer() = default;

  virtual bool Collect(
      nostd::function_ref<bool(ResourceMetrics &metric_data)> callback) noexcept = 0;
};

}  // namespace metrics
}  // namespace sdk
OPENTELEMETRY_END_NAMESPACE