00001 /* 00002 * Copyright 2018 The Cartographer Authors 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #ifndef CARTOGRAPHER_CLOUD_METRICS_PROMETHEUS_FAMILY_FACTORY_H_ 00018 #define CARTOGRAPHER_CLOUD_METRICS_PROMETHEUS_FAMILY_FACTORY_H_ 00019 00020 #include <memory> 00021 #include <string> 00022 00023 #include "cartographer/metrics/family_factory.h" 00024 #include "prometheus/registry.h" 00025 00026 namespace cartographer { 00027 namespace cloud { 00028 namespace metrics { 00029 namespace prometheus { 00030 00031 class FamilyFactory : public ::cartographer::metrics::FamilyFactory { 00032 public: 00033 FamilyFactory(); 00034 00035 ::cartographer::metrics::Family<::cartographer::metrics::Counter>* 00036 NewCounterFamily(const std::string& name, 00037 const std::string& description) override; 00038 ::cartographer::metrics::Family<::cartographer::metrics::Gauge>* 00039 NewGaugeFamily(const std::string& name, 00040 const std::string& description) override; 00041 ::cartographer::metrics::Family<::cartographer::metrics::Histogram>* 00042 NewHistogramFamily(const std::string& name, const std::string& description, 00043 const ::cartographer::metrics::Histogram::BucketBoundaries& 00044 boundaries) override; 00045 00046 std::weak_ptr<::prometheus::Collectable> GetCollectable() const; 00047 00048 private: 00049 std::vector<std::unique_ptr< 00050 ::cartographer::metrics::Family<::cartographer::metrics::Counter>>> 00051 counters_; 00052 std::vector<std::unique_ptr< 00053 ::cartographer::metrics::Family<::cartographer::metrics::Gauge>>> 00054 gauges_; 00055 std::vector<std::unique_ptr< 00056 ::cartographer::metrics::Family<::cartographer::metrics::Histogram>>> 00057 histograms_; 00058 std::shared_ptr<::prometheus::Registry> registry_; 00059 }; 00060 00061 } // namespace prometheus 00062 } // namespace metrics 00063 } // namespace cloud 00064 } // namespace cartographer 00065 00066 #endif // CARTOGRAPHER_CLOUD_METRICS_PROMETHEUS_FAMILY_FACTORY_H_