Skip to content

Commit 76a033e

Browse files
committed
Move invalid latency tracking to request context
1 parent 94aa414 commit 76a033e

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

tests/performance-tests/include/performance-tests/reporting/JsonReportingMetrics.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ class JsonReportingMetrics : public Aws::Monitoring::MonitoringInterface {
155155
Aws::String m_sdkVersion;
156156
Aws::String m_commitId;
157157
Aws::String m_outputFilename;
158-
mutable bool m_hasInvalidLatency;
159158
};
160159

161160
/**

tests/performance-tests/src/reporting/JsonReportingMetrics.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

3738
JsonReportingMetrics::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

4646
JsonReportingMetrics::~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

Comments
 (0)