MCPcopy Create free account
hub / github.com/apache/trafficserver / RecLookupMatchingRecords

Function RecLookupMatchingRecords

src/records/RecCore.cc:549–596  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

547}
548
549RecErrT
550RecLookupMatchingRecords(unsigned rec_type, const char *match, void (*callback)(const RecRecord *, void *), void *data,
551 bool /* lock ATS_UNUSED */)
552{
553 int num_records;
554 DFA regex;
555
556 if (!regex.compile(match, RE_CASE_INSENSITIVE | RE_UNANCHORED)) {
557 return REC_ERR_FAIL;
558 }
559
560 if ((rec_type & (RECT_PROCESS | RECT_NODE | RECT_PLUGIN))) {
561 // First find the new metrics, this is a bit of a hack, because we still use the old
562 // librecords callback with a "pseudo" record.
563 RecRecord tmp;
564
565 tmp.rec_type = RECT_PROCESS;
566 tmp.data_type = RECD_INT;
567
568 for (auto &&[name, val] : ts::Metrics::instance()) {
569 if (regex.match(name.data()) >= 0) {
570 tmp.name = name.data();
571 tmp.data.rec_int = val;
572 callback(&tmp, data);
573 }
574 }
575 // Fall through to return any matching string metrics
576 }
577
578 num_records = g_num_records;
579 for (int i = 0; i < num_records; i++) {
580 RecRecord *r = &(g_records[i]);
581
582 if ((r->rec_type & rec_type) == 0) {
583 continue;
584 }
585
586 if (regex.match(r->name) < 0) {
587 continue;
588 }
589
590 rec_mutex_acquire(&(r->lock));
591 callback(r, data);
592 rec_mutex_release(&(r->lock));
593 }
594
595 return REC_ERR_OKAY;
596}
597
598RecErrT
599RecGetRecordType(const char *name, RecT *rec_type, bool lock)

Callers 1

get_record_regex_implFunction · 0.85

Calls 5

rec_mutex_acquireFunction · 0.85
rec_mutex_releaseFunction · 0.85
compileMethod · 0.45
matchMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected