1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
5 #ifndef ENABLE_METRICS_PREVIEW
6 # include "opentelemetry/sdk/metrics/data/metric_data.h"
7 # include "opentelemetry/sdk/metrics/export/metric_producer.h"
9 OPENTELEMETRY_BEGIN_NAMESPACE
21 virtual AggregationTemporality
GetAggregationTemporality() noexcept
= 0;
25 * An internal opaque interface that the MetricReader receives as
26 * MetricProducer. It acts as the storage key to the internal metric stream
27 * state for each MetricReader.
30 class MetricCollector
: public MetricProducer
, public CollectorHandle
33 MetricCollector(std::shared_ptr
<MeterContext
> &&context
,
34 std::unique_ptr
<MetricReader
> metric_reader
);
36 AggregationTemporality
GetAggregationTemporality() noexcept override
;
39 * The callback to be called for each metric exporter. This will only be those
40 * metrics that have been produced since the last time this method was called.
42 * @return a status of completion of method.
44 bool Collect(nostd::function_ref
<bool(ResourceMetrics
&metric_data
)> callback
) noexcept override
;
46 bool ForceFlush(std::chrono::microseconds timeout
= std::chrono::microseconds::max()) noexcept
;
48 bool Shutdown(std::chrono::microseconds timeout
= std::chrono::microseconds::max()) noexcept
;
51 std::shared_ptr
<MeterContext
> meter_context_
;
52 std::shared_ptr
<MetricReader
> metric_reader_
;
54 } // namespace metrics
56 OPENTELEMETRY_END_NAMESPACE