iceberg-cpp
Loading...
Searching...
No Matches
metrics_reporter.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 <string>
26#include <string_view>
27#include <unordered_map>
28#include <utility>
29#include <variant>
30
35#include "iceberg/result.h"
36
37namespace iceberg {
38
41 kScanReport,
42 kCommitReport,
43};
44
46ICEBERG_EXPORT constexpr std::string_view ToString(MetricsReportType type) noexcept {
47 switch (type) {
48 case MetricsReportType::kScanReport:
49 return "scan";
50 case MetricsReportType::kCommitReport:
51 return "commit";
52 }
54}
55
60using MetricsReport = std::variant<ScanReport, CommitReport>;
61
66ICEBERG_EXPORT inline MetricsReportType GetReportType(const MetricsReport& report) {
67 return std::visit(
68 [](const auto& r) -> MetricsReportType {
69 using T = std::decay_t<decltype(r)>;
70 if constexpr (std::is_same_v<T, ScanReport>) {
71 return MetricsReportType::kScanReport;
72 } else {
73 return MetricsReportType::kCommitReport;
74 }
75 },
76 report);
77}
78
86class ICEBERG_EXPORT MetricsReporter {
87 public:
88 virtual ~MetricsReporter() = default;
89
96 [[maybe_unused]] const std::unordered_map<std::string, std::string>& properties) {
97 return {};
98 }
99
106 virtual Status Report(const MetricsReport& report) = 0;
107};
108
109} // namespace iceberg
Interface for reporting metrics from Iceberg operations.
Definition metrics_reporter.h:86
virtual Status Initialize(const std::unordered_map< std::string, std::string > &properties)
Initialize the reporter with catalog properties after construction.
Definition metrics_reporter.h:95
virtual Status Report(const MetricsReport &report)=0
Report a metrics report.
Definition expected.h:1199
Define commit metrics and reports.
Define symbol visibility macros for core Iceberg APIs.
Core Apache Iceberg C++ APIs.
Definition arrow_io_util.h:34
ICEBERG_EXPORT std::string_view ToString(Expression::Operation op)
Returns a string representation of an expression operation.
void unreachable() noexcept
Marks a branch the program can never take.
Definition unreachable.h:35
MetricsReportType
The type of a metrics report.
Definition metrics_reporter.h:40
std::variant< ScanReport, CommitReport > MetricsReport
A metrics report, which can be either a ScanReport or CommitReport.
Definition metrics_reporter.h:60
ICEBERG_EXPORT MetricsReportType GetReportType(const MetricsReport &report)
Get the type of a metrics report.
Definition metrics_reporter.h:66
Define Result, Status, and error helpers.
Define scan metrics and reports.
Portable stand-in for std::unreachable.