metrics_collector.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
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  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
16 #pragma once
17 
19 #include <ros/ros.h>
20 #include <ros_monitoring_msgs/MetricList.h>
21 #include <ros_monitoring_msgs/MetricData.h>
22 #include <std_srvs/Trigger.h>
23 #include <std_srvs/Empty.h>
24 
27 
28 #include <string>
29 #include <map>
30 
31 namespace Aws {
32 namespace CloudWatchMetrics {
33 namespace Utils {
34 
35 class MetricsCollector : public Service
36 {
37 public:
38 
39  MetricsCollector() = default;
40  ~MetricsCollector() override = default;
41 
48  int RecordMetrics(const ros_monitoring_msgs::MetricList::ConstPtr & metric_list_msg);
49 
53  void TriggerPublish(const ros::TimerEvent &);
54 
65  void Initialize(std::string metric_namespace,
66  std::map<std::string, std::string> & default_dimensions,
67  int storage_resolution,
68  const ros::NodeHandle& node_handle,
69  const Aws::Client::ClientConfiguration & config,
70  const Aws::SDKOptions & sdk_options,
71  const Aws::CloudWatchMetrics::CloudWatchOptions & cloudwatch_options,
72  const std::shared_ptr<MetricServiceFactory>& metric_service_factory = std::make_shared<MetricServiceFactory>());
73 
74  void SubscribeAllTopics();
75 
76  bool start() override;
77  bool shutdown() override;
78 
86  bool checkIfOnline(std_srvs::Trigger::Request& request, std_srvs::Trigger::Response& response);
87 
91  static int64_t GetMetricDataEpochMillis(const ros_monitoring_msgs::MetricData & metric_msg);
92 
93 private:
94 
95  std::string metric_namespace_;
96  std::map<std::string, std::string> default_dimensions_;
97  std::atomic<int> storage_resolution_{};
98  std::shared_ptr<MetricService> metric_service_;
99  std::vector<ros::Subscriber> subscriptions_;
101  std::vector<std::string> topics_;
102 };
103 
104 } // namespace Utils
105 } // namespace CloudWatchMetrics
106 } // namespace Aws
int RecordMetrics(const ros_monitoring_msgs::MetricList::ConstPtr &metric_list_msg)
void Initialize(std::string metric_namespace, std::map< std::string, std::string > &default_dimensions, int storage_resolution, const ros::NodeHandle &node_handle, const Aws::Client::ClientConfiguration &config, const Aws::SDKOptions &sdk_options, const Aws::CloudWatchMetrics::CloudWatchOptions &cloudwatch_options, const std::shared_ptr< MetricServiceFactory > &metric_service_factory=std::make_shared< MetricServiceFactory >())
std::map< std::string, std::string > default_dimensions_
static int64_t GetMetricDataEpochMillis(const ros_monitoring_msgs::MetricData &metric_msg)
bool checkIfOnline(std_srvs::Trigger::Request &request, std_srvs::Trigger::Response &response)
std::shared_ptr< MetricService > metric_service_


cloudwatch_metrics_collector
Author(s): AWS RoboMaker
autogenerated on Fri Mar 5 2021 03:38:40