@@ -37,6 +37,11 @@ struct PerformanceMetricRecord {
3737 Aws::Map<Aws::String, Aws::String> dimensions;
3838};
3939
40+ /* *
41+ * Context will be shared between monitor invocations.
42+ */
43+ struct RequestContext ;
44+
4045/* *
4146 * An implementation of the MonitoringInterface that collects performance metrics
4247 * and reports them in a JSON format.
@@ -58,17 +63,17 @@ class JsonReportingMetrics : public Aws::Monitoring::MonitoringInterface {
5863 ~JsonReportingMetrics () override ;
5964
6065 /* *
61- * Called when an AWS request is started. Returns context for tracking.
66+ * Called when an AWS request is started. Creates and returns context for tracking.
6267 * @param serviceName Name of the AWS service
6368 * @param requestName Name of the operation
6469 * @param request HTTP request object
65- * @return Context pointer (always returns nullptr)
70+ * @return Context pointer to newly created RequestContext
6671 */
6772 void * OnRequestStarted (const Aws::String& serviceName, const Aws::String& requestName,
6873 const std::shared_ptr<const Aws::Http::HttpRequest>& request) const override ;
6974
7075 /* *
71- * Called when an AWS request succeeds. Records performance metrics.
76+ * Called when an AWS request succeeds. Stores latency metrics in context .
7277 * @param serviceName Name of the AWS service
7378 * @param requestName Name of the operation
7479 * @param request HTTP request object
@@ -81,7 +86,7 @@ class JsonReportingMetrics : public Aws::Monitoring::MonitoringInterface {
8186 const Aws::Monitoring::CoreMetricsCollection& metrics, void * context) const override ;
8287
8388 /* *
84- * Called when an AWS request fails. Records performance metrics.
89+ * Called when an AWS request fails. Stores latency metrics in context .
8590 * @param serviceName Name of the AWS service
8691 * @param requestName Name of the operation
8792 * @param request HTTP request object
@@ -104,7 +109,7 @@ class JsonReportingMetrics : public Aws::Monitoring::MonitoringInterface {
104109 const std::shared_ptr<const Aws::Http::HttpRequest>& request, void * context) const override ;
105110
106111 /* *
107- * Called when an AWS request finishes. No action taken .
112+ * Called when an AWS request finishes. Processes stored metrics and cleans up context .
108113 * @param serviceName Name of the AWS service
109114 * @param requestName Name of the operation
110115 * @param request HTTP request object
@@ -150,6 +155,7 @@ class JsonReportingMetrics : public Aws::Monitoring::MonitoringInterface {
150155 void WriteJsonToFile (const Aws::Utils::Json::JsonValue& root) const ;
151156
152157 mutable Aws::Vector<PerformanceMetricRecord> m_performanceRecords;
158+ mutable Aws::UnorderedMap<Aws::String, Aws::UniquePtr<RequestContext>> m_requestContexts;
153159 Aws::Set<Aws::String> m_monitoredOperations;
154160 Aws::String m_productId;
155161 Aws::String m_sdkVersion;
0 commit comments