]>
Commit | Line | Data |
---|---|---|
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 | ||
11 | OPENTELEMETRY_BEGIN_NAMESPACE | |
12 | namespace sdk | |
13 | { | |
14 | namespace metrics | |
15 | { | |
16 | /** | |
17 | * View defines the interface to allow SDK user to | |
18 | * customize the metrics before exported. | |
19 | */ | |
20 | ||
21 | class View | |
22 | { | |
23 | public: | |
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 | ||
48 | private: | |
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 | |
56 | OPENTELEMETRY_END_NAMESPACE | |
57 | #endif |