AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
AmdMetricWrapper.h
Go to the documentation of this file.
1 /*
2  * Copyright 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 #ifndef ACSDKASSETSCOMMON_AMDMETRICWRAPPER_H_
17 #define ACSDKASSETSCOMMON_AMDMETRICWRAPPER_H_
18 
20 #include <chrono>
21 #include <functional>
22 #include <memory>
23 #include <string>
24 
25 #define METRIC_PREFIX_ERROR(str) ("ERROR." str)
26 #define METRIC_PREFIX_ERROR_CREATE(str) METRIC_PREFIX_ERROR("Create." str)
27 #define METRIC_PREFIX_ERROR_INIT(str) METRIC_PREFIX_ERROR("Init." str)
28 
29 namespace alexaClientSDK {
30 namespace acsdkAssets {
31 namespace common {
32 
33 /*
34  * Wrapper around the MetricRecorder
35  */
37 public:
41  AmdMetricsWrapper(const std::string& sourceName);
42 
43  static std::function<AmdMetricsWrapper()> creator(const std::string& sourceName) {
44  return [sourceName] { return AmdMetricsWrapper(sourceName); };
45  }
46 
47  static void setStaticRecorder(
48  std::shared_ptr<alexaClientSDK::avsCommon::utils::metrics::MetricRecorderInterface> recorder);
49 
50  AmdMetricsWrapper(const AmdMetricsWrapper&) = delete;
51  AmdMetricsWrapper& operator=(const AmdMetricsWrapper& other) = delete;
52  AmdMetricsWrapper(AmdMetricsWrapper&& other) = default;
54 
56 
60  AmdMetricsWrapper& addCounter(const std::string& name, int count = 1);
61 
66  return addCounter(name, 0);
67  }
68 
72  AmdMetricsWrapper& addTimer(const std::string& name, std::chrono::milliseconds value);
73 
77  AmdMetricsWrapper& addString(const std::string& name, const std::string& str);
78 
79 private:
83  const std::string m_sourceName;
87  std::vector<alexaClientSDK::avsCommon::utils::metrics::DataPoint> m_dataPoints;
88 
89  static std::shared_ptr<alexaClientSDK::avsCommon::utils::metrics::MetricRecorderInterface> s_recorder;
90 };
91 
92 } // namespace common
93 } // namespace acsdkAssets
94 } // namespace alexaClientSDK
95 
96 #endif // ACSDKASSETSCOMMON_AMDMETRICWRAPPER_H_
int * count
Definition: gmock_stress_test.cc:176
::std::string string
Definition: gtest-port.h:1097
AmdMetricsWrapper & addTimer(const std::string &name, std::chrono::milliseconds value)
static std::function< AmdMetricsWrapper()> creator(const std::string &sourceName)
Definition: AmdMetricWrapper.h:43
static void setStaticRecorder(std::shared_ptr< alexaClientSDK::avsCommon::utils::metrics::MetricRecorderInterface > recorder)
AmdMetricsWrapper & addCounter(const std::string &name, int count=1)
Definition: common.py:1
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
AmdMetricsWrapper & addString(const std::string &name, const std::string &str)
AmdMetricsWrapper & operator=(const AmdMetricsWrapper &other)=delete
AmdMetricsWrapper & addZeroCounter(const std::string &name)
Definition: AmdMetricWrapper.h:65

AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0