AlexaClientSDK  1.26.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 
65  inline AmdMetricsWrapper& addZeroCounter(const std::string& name) {
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_
alexaClientSDK::acsdkAssets::common::AmdMetricsWrapper::operator=
AmdMetricsWrapper & operator=(const AmdMetricsWrapper &other)=delete
alexaClientSDK::acsdkAssets::common::AmdMetricsWrapper::setStaticRecorder
static void setStaticRecorder(std::shared_ptr< alexaClientSDK::avsCommon::utils::metrics::MetricRecorderInterface > recorder)
Definition: AmdMetricWrapper.cpp:44
alexaClientSDK::acsdkAssets::common::AmdMetricsWrapper::addZeroCounter
AmdMetricsWrapper & addZeroCounter(const std::string &name)
Definition: AmdMetricWrapper.h:65
MetricRecorderInterface.h
alexaClientSDK::acsdkAssets::common::AmdMetricsWrapper::addString
AmdMetricsWrapper & addString(const std::string &name, const std::string &str)
Definition: AmdMetricWrapper.cpp:81
alexaClientSDK::acsdkAssets::common::AmdMetricsWrapper::AmdMetricsWrapper
AmdMetricsWrapper(const std::string &sourceName)
alexaClientSDK
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
alexaClientSDK::acsdkAssets::common::AmdMetricsWrapper::creator
static std::function< AmdMetricsWrapper()> creator(const std::string &sourceName)
Definition: AmdMetricWrapper.h:43
alexaClientSDK::acsdkAssets::common::AmdMetricsWrapper::addTimer
AmdMetricsWrapper & addTimer(const std::string &name, std::chrono::milliseconds value)
Definition: AmdMetricWrapper.cpp:74
alexaClientSDK::acsdkAssets::common::AmdMetricsWrapper
Definition: AmdMetricWrapper.h:36
alexaClientSDK::acsdkAssets::common::AmdMetricsWrapper::~AmdMetricsWrapper
~AmdMetricsWrapper()
Definition: AmdMetricWrapper.cpp:51
alexaClientSDK::acsdkAssets::common::AmdMetricsWrapper::addCounter
AmdMetricsWrapper & addCounter(const std::string &name, int count=1)
Definition: AmdMetricWrapper.cpp:67

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