]> git.proxmox.com Git - ceph.git/blame - ceph/src/jaegertracing/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/view/view.h
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / jaegertracing / opentelemetry-cpp / sdk / include / opentelemetry / sdk / metrics / view / view.h
CommitLineData
1e59de90
TL
1// Copyright The OpenTelemetry Authors
2// SPDX-License-Identifier: Apache-2.0
3
4#pragma once
5#ifndef ENABLE_METRICS_PREVIEW
6# include "opentelemetry/nostd/string_view.h"
7# include "opentelemetry/sdk/metrics/aggregation/default_aggregation.h"
8# include "opentelemetry/sdk/metrics/instruments.h"
9# include "opentelemetry/sdk/metrics/view/attributes_processor.h"
10
11OPENTELEMETRY_BEGIN_NAMESPACE
12namespace sdk
13{
14namespace metrics
15{
16/**
17 * View defines the interface to allow SDK user to
18 * customize the metrics before exported.
19 */
20
21class View
22{
23public:
24 View(const std::string &name,
25 const std::string &description = "",
26 AggregationType aggregation_type = AggregationType::kDefault,
27 std::unique_ptr<opentelemetry::sdk::metrics::AttributesProcessor> attributes_processor =
28 std::unique_ptr<opentelemetry::sdk::metrics::AttributesProcessor>(
29 new opentelemetry::sdk::metrics::DefaultAttributesProcessor()))
30 : name_(name),
31 description_(description),
32 aggregation_type_{aggregation_type},
33 attributes_processor_{std::move(attributes_processor)}
34 {}
35
36 virtual std::string GetName() const noexcept { return name_; }
37
38 virtual std::string GetDescription() const noexcept { return description_; }
39
40 virtual AggregationType GetAggregationType() const noexcept { return aggregation_type_; }
41
42 virtual const opentelemetry::sdk::metrics::AttributesProcessor &GetAttributesProcessor()
43 const noexcept
44 {
45 return *attributes_processor_.get();
46 }
47
48private:
49 std::string name_;
50 std::string description_;
51 AggregationType aggregation_type_;
52 std::unique_ptr<opentelemetry::sdk::metrics::AttributesProcessor> attributes_processor_;
53};
54} // namespace metrics
55} // namespace sdk
56OPENTELEMETRY_END_NAMESPACE
57#endif