iceberg-cpp
Loading...
Searching...
No Matches
metrics_reporters.h
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20#pragma once
21
24
25#include <functional>
26#include <memory>
27#include <string>
28#include <string_view>
29#include <unordered_map>
30#include <unordered_set>
31
32#include "iceberg/iceberg_export.h"
33#include "iceberg/metrics/metrics_reporter.h"
34#include "iceberg/result.h"
35
36namespace iceberg {
37
42constexpr std::string_view kMetricsReporterImpl = "metrics-reporter-impl";
43
45constexpr std::string_view kMetricsReporterTypeNoop = "noop";
46
51using MetricsReporterFactory = std::function<Result<std::unique_ptr<MetricsReporter>>(
52 const std::unordered_map<std::string, std::string>& properties)>;
53
63class ICEBERG_EXPORT CompositeMetricsReporter : public MetricsReporter {
64 public:
66 std::unordered_set<std::shared_ptr<MetricsReporter>> reporters);
67
68 Status Report(const MetricsReport& report) override;
69
73 const std::unordered_set<std::shared_ptr<MetricsReporter>>& Reporters() const;
74
75 private:
76 std::unordered_set<std::shared_ptr<MetricsReporter>> reporters_;
77};
78
84class ICEBERG_EXPORT MetricsReporters {
85 public:
94 static Result<std::unique_ptr<MetricsReporter>> Load(
95 const std::unordered_map<std::string, std::string>& properties);
96
107 static Status Register(std::string_view reporter_type, MetricsReporterFactory factory);
108
114 static std::shared_ptr<MetricsReporter> Combine(
115 std::shared_ptr<MetricsReporter> first, std::shared_ptr<MetricsReporter> second);
116};
117
118} // namespace iceberg
A MetricsReporter that delegates to multiple reporters.
Definition metrics_reporters.h:63
Interface for reporting metrics from Iceberg operations.
Definition metrics_reporter.h:82
Factory class for creating and managing MetricsReporter instances.
Definition metrics_reporters.h:84
constexpr std::string_view kMetricsReporterTypeNoop
Property value for the noop metrics reporter.
Definition metrics_reporters.h:45
std::function< Result< std::unique_ptr< MetricsReporter > >(const std::unordered_map< std::string, std::string > &properties)> MetricsReporterFactory
Function type for creating MetricsReporter instances.
Definition metrics_reporters.h:52
constexpr std::string_view kMetricsReporterImpl
Property key for configuring the metrics reporter implementation.
Definition metrics_reporters.h:42