| 96 | } |
| 97 | |
| 98 | static bool |
| 99 | createStat(const String &prefix, const String &space, const char *module, const char *statName, |
| 100 | TSRecordDataType /* statType ATS_UNUSED */, int &statId) |
| 101 | { |
| 102 | String name(prefix); |
| 103 | name.append(".").append(space); |
| 104 | if (nullptr != module) { |
| 105 | name.append(".").append(module); |
| 106 | } |
| 107 | name.append(".").append(statName); |
| 108 | |
| 109 | if (TSStatFindName(name.c_str(), &statId) == TS_ERROR) { |
| 110 | statId = TSStatCreate(name.c_str(), TS_RECORDDATATYPE_INT, TS_STAT_NON_PERSISTENT, TS_STAT_SYNC_SUM); |
| 111 | if (statId == TS_ERROR) { |
| 112 | PrefetchError("failed to register '%s'", name.c_str()); |
| 113 | return false; |
| 114 | } |
| 115 | |
| 116 | TSStatIntSet(statId, 0); |
| 117 | } |
| 118 | |
| 119 | PrefetchDebug("created metric '%s (id:%d)'", name.c_str(), statId); |
| 120 | |
| 121 | return true; |
| 122 | } |
| 123 | |
| 124 | BgFetchState::BgFetchState() |
| 125 | { |
no test coverage detected