Copilot commented on code in PR #13505:
URL: https://github.com/apache/trafficserver/pull/13505#discussion_r3724977511
##########
src/records/RecCore.cc:
##########
@@ -612,6 +612,22 @@ RecLookupMatchingRecords(unsigned rec_type, const char
*match, void (*callback)(
});
}
+ if (rec_type & RECT_HIDDEN_METRIC) {
+ // Opt-in only: hidden metrics are never reachable through RECT_ALL, see
RecDefs.h.
+ for (auto &&[name, type, val] : ts::Metrics::hidden_instance()) {
+ if (regex.exec(name.data())) {
+ RecRecord tmp;
+
+ tmp.rec_type = RECT_PROCESS;
+
+ tmp.name = name.data();
+ tmp.data_type = type == ts::Metrics::MetricType::COUNTER ?
RECD_COUNTER : RECD_INT;
+ tmp.data.rec_int = val;
+ callback(&tmp, data);
Review Comment:
`RecRecord tmp;` is left uninitialized for hidden metrics, but it is passed
into the YAML/JSONRPC conversion path. Because `tmp.rec_type` is set to
`RECT_PROCESS`, the encoder treats it as a STAT record and will read
`tmp.stat_meta` (and other fields) even though they were never initialized,
leading to nondeterministic/garbage metadata in responses. Also, setting
`rec_type` to `RECT_PROCESS` prevents hidden metrics from being returned if a
client requests only `RECT_HIDDEN_METRIC` (64) in `rec_types`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]