@@ -32,6 +32,7 @@ struct RequestContext {
3232 Aws::String requestName;
3333 std::shared_ptr<const Aws::Http::HttpRequest> request;
3434 std::variant<int64_t , double > durationMs = int64_t (0 );
35+ bool failed = false ;
3536};
3637
3738JsonReportingMetrics::JsonReportingMetrics (const Aws::Set<Aws::String>& monitoredOperations, const Aws::String& productId,
@@ -40,8 +41,7 @@ JsonReportingMetrics::JsonReportingMetrics(const Aws::Set<Aws::String>& monitore
4041 m_productId(productId),
4142 m_sdkVersion(sdkVersion),
4243 m_commitId(commitId),
43- m_outputFilename(outputFilename),
44- m_hasInvalidLatency(false ) {}
44+ m_outputFilename(outputFilename) {}
4545
4646JsonReportingMetrics::~JsonReportingMetrics () { DumpJson (); }
4747
@@ -72,7 +72,7 @@ void JsonReportingMetrics::StoreLatencyInContext(const Aws::String& serviceName,
7272 requestContext->request = request;
7373 requestContext->durationMs = iterator->second ;
7474 } else {
75- m_hasInvalidLatency = true ;
75+ requestContext-> failed = true ;
7676 }
7777}
7878
@@ -132,7 +132,7 @@ void JsonReportingMetrics::OnFinish(const Aws::String&, const Aws::String&, cons
132132 void * context) const {
133133 RequestContext* requestContext = static_cast <RequestContext*>(context);
134134
135- if (std::visit ([]( auto && v) { return v > 0 ; }, requestContext->durationMs ) ) {
135+ if (! requestContext->failed ) {
136136 AddPerformanceRecord (requestContext->serviceName , requestContext->requestName , requestContext->request , requestContext->durationMs );
137137 }
138138
@@ -145,8 +145,7 @@ void JsonReportingMetrics::DumpJson() const {
145145 root.WithString (" sdkVersion" , m_sdkVersion);
146146 root.WithString (" commitId" , m_commitId);
147147
148- // If there is an invalid latency or there are no records, then use an empty results array
149- if (m_hasInvalidLatency || m_performanceRecords.empty ()) {
148+ if (m_performanceRecords.empty ()) {
150149 root.WithArray (" results" , Aws::Utils::Array<Aws::Utils::Json::JsonValue>(0 ));
151150 WriteJsonToFile (root);
152151 return ;
0 commit comments