|
27 | 27 |
|
28 | 28 | using namespace PerformanceTest::Reporting; |
29 | 29 |
|
30 | | -struct RequestContext { |
31 | | - Aws::String serviceName; |
32 | | - Aws::String requestName; |
33 | | - std::shared_ptr<const Aws::Http::HttpRequest> request; |
34 | | - std::variant<int64_t, double> durationMs = int64_t(0); |
35 | | - bool failed = false; |
36 | | -}; |
37 | | - |
38 | 30 | JsonReportingMetrics::JsonReportingMetrics(const Aws::Set<Aws::String>& monitoredOperations, const Aws::String& productId, |
39 | 31 | const Aws::String& sdkVersion, const Aws::String& commitId, const Aws::String& outputFilename) |
40 | 32 | : m_monitoredOperations(monitoredOperations), |
@@ -107,8 +99,10 @@ void JsonReportingMetrics::AddPerformanceRecord(const Aws::String& serviceName, |
107 | 99 |
|
108 | 100 | void* JsonReportingMetrics::OnRequestStarted(const Aws::String&, const Aws::String&, |
109 | 101 | const std::shared_ptr<const Aws::Http::HttpRequest>&) const { |
110 | | - auto context = Aws::New<RequestContext>("RequestContext"); |
111 | | - return context; |
| 102 | + auto context = Aws::MakeUnique<RequestContext>("RequestContext"); |
| 103 | + auto requestID = context->requestId; |
| 104 | + m_requestContexts.emplace(requestID, std::move(context)); |
| 105 | + return m_requestContexts[requestID].get(); |
112 | 106 | } |
113 | 107 |
|
114 | 108 | void JsonReportingMetrics::OnRequestSucceeded(const Aws::String& serviceName, const Aws::String& requestName, |
@@ -136,7 +130,7 @@ void JsonReportingMetrics::OnFinish(const Aws::String&, const Aws::String&, cons |
136 | 130 | AddPerformanceRecord(requestContext->serviceName, requestContext->requestName, requestContext->request, requestContext->durationMs); |
137 | 131 | } |
138 | 132 |
|
139 | | - Aws::Delete(requestContext); |
| 133 | + m_requestContexts.erase(requestContext->requestId); |
140 | 134 | } |
141 | 135 |
|
142 | 136 | void JsonReportingMetrics::DumpJson() const { |
|
0 commit comments