1/**
2 * Copyright (c) Glow Contributors. See CONTRIBUTORS file.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "glow/Runtime/StatsExporter.h"
18
19#include <vector>
20
21namespace glow {
22
23void StatsExporterRegistry::registerStatsExporter(StatsExporter *exporter) {
24 exporters_.push_back(exporter);
25}
26
27void StatsExporterRegistry::revokeStatsExporter(StatsExporter *exporter) {
28 exporters_.erase(std::remove(exporters_.begin(), exporters_.end(), exporter),
29 exporters_.end());
30}
31
32void StatsExporterRegistry::addTimeSeriesValue(llvm::StringRef key,
33 double value) {
34 for (auto const &exporter : exporters_) {
35 exporter->addTimeSeriesValue(key, value);
36 }
37}
38
39void StatsExporterRegistry::setCounter(llvm::StringRef key, int64_t value) {
40 for (auto const &exporter : exporters_) {
41 exporter->setCounter(key, value);
42 }
43}
44
45void StatsExporterRegistry::incrementCounter(llvm::StringRef key,
46 int64_t value) {
47 for (auto const &exporter : exporters_) {
48 exporter->incrementCounter(key, value);
49 }
50}
51
52std::shared_ptr<StatsExporterRegistry> StatsExporterRegistry::Stats() {
53 static auto stats = std::make_shared<StatsExporterRegistry>();
54 return stats;
55}
56
57} // namespace glow
58