AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Metrics.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 ALEXA_CLIENT_SDK_AVSCOMMON_UTILS_INCLUDE_AVSCOMMON_UTILS_METRICS_H_
17 #define ALEXA_CLIENT_SDK_AVSCOMMON_UTILS_INCLUDE_AVSCOMMON_UTILS_METRICS_H_
18 
21 
22 namespace alexaClientSDK {
23 namespace avsCommon {
24 namespace utils {
25 
26 const std::string METRICS_TAG = ":METRICS:";
27 
28 class Metrics {
29 public:
33  enum Location {
34  // Enqueue message in ADSL module
36 
37  // Dequeue message in ADSL module
39 
40  // SpeechSynthesizer receive the message
42 
43  // AudioInputProcessor receive the message
45 
46  // AudioInputProcessor send the message
48 
49  // Used when issuing an extra metric log for missing Ids
51  };
52 
62  static logger::LogEntry& d(
64  const std::string& name,
65  const std::string& messageId,
66  const std::string& dialogRequestId,
67  Location location);
68 
76  static logger::LogEntry& d(
78  const std::shared_ptr<alexaClientSDK::avsCommon::avs::AVSMessage> msg,
79  Location location);
80 
81 private:
87  static const std::string locationToString(Location location);
88 };
89 
90 } // namespace utils
91 } // namespace avsCommon
92 } // namespace alexaClientSDK
93 
94 #ifdef ACSDK_LATENCY_LOG_ENABLED
95 
101 #define ACSDK_METRIC_WITH_ENTRY(entry) ACSDK_INFO(entry)
102 
112 #define ACSDK_METRIC_IDS(TAG, name, messageId, dialogRequestId, location) \
113  do { \
114  alexaClientSDK::avsCommon::utils::logger::LogEntry logEntry( \
115  TAG, __func__ + alexaClientSDK::avsCommon::utils::METRICS_TAG); \
116  alexaClientSDK::avsCommon::utils::Metrics::d(logEntry, name, messageId, dialogRequestId, location); \
117  ACSDK_METRIC_WITH_ENTRY(logEntry); \
118  } while (false)
119 
127 #define ACSDK_METRIC_MSG(TAG, msg, location) \
128  do { \
129  alexaClientSDK::avsCommon::utils::logger::LogEntry logEntry( \
130  TAG, __func__ + alexaClientSDK::avsCommon::utils::METRICS_TAG); \
131  alexaClientSDK::avsCommon::utils::Metrics::d(logEntry, msg, location); \
132  ACSDK_METRIC_WITH_ENTRY(logEntry); \
133  } while (false)
134 
135 #else // ACSDK_LATENCY_LOG_ENABLED
136 
146 #define ACSDK_METRIC_IDS(TAG, name, messageId, dialogRequestId, location)
147 
155 #define ACSDK_METRIC_MSG(TAG, msg, location)
156 
157 #endif // ACSDK_LATENCY_LOG_ENABLED
158 
159 #endif // ALEXA_CLIENT_SDK_AVSCOMMON_UTILS_INCLUDE_AVSCOMMON_UTILS_METRICS_H_
::std::string string
Definition: gtest-port.h:1097
const std::string METRICS_TAG
Definition: Metrics.h:26
void logEntry(Level level, const LogEntry &entry)
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
static logger::LogEntry & d(alexaClientSDK::avsCommon::utils::logger::LogEntry &logEntry, const std::string &name, const std::string &messageId, const std::string &dialogRequestId, Location location)
LogEntry is used to compile the log entry text to log via Logger.
Definition: LogEntry.h:33

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