Skip to content

Commit acdb96c

Browse files
committed
Fixes from Walt's review comments
1 parent 7688644 commit acdb96c

File tree

2 files changed

+38
-6
lines changed

2 files changed

+38
-6
lines changed

include/api/Metrics.h

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ class Metrics
5050
friend class Metrics;
5151

5252
public:
53-
AtomicType() = default;
54-
virtual ~AtomicType() = default;
53+
AtomicType() = default;
54+
~AtomicType() = default;
5555

5656
int64_t
5757
load() const
@@ -296,6 +296,22 @@ class Metrics
296296
{
297297
};
298298

299+
static AtomicType *
300+
lookup(const std::string_view name)
301+
{
302+
auto &instance = Metrics::instance();
303+
304+
return reinterpret_cast<AtomicType *>(instance.lookup(name));
305+
}
306+
307+
static AtomicType *
308+
lookup(const IdType id)
309+
{
310+
auto &instance = Metrics::instance();
311+
312+
return reinterpret_cast<AtomicType *>(instance.lookup(id));
313+
}
314+
299315
static Metrics::IdType
300316
create(const std::string_view name)
301317
{
@@ -335,7 +351,7 @@ class Metrics
335351
}
336352

337353
static int64_t
338-
load(AtomicType *metric)
354+
load(const AtomicType *metric)
339355
{
340356
ink_assert(metric);
341357
return metric->_value.load();
@@ -360,6 +376,22 @@ class Metrics
360376
{
361377
};
362378

379+
static AtomicType *
380+
lookup(const std::string_view name)
381+
{
382+
auto &instance = Metrics::instance();
383+
384+
return reinterpret_cast<AtomicType *>(instance.lookup(name));
385+
}
386+
387+
static AtomicType *
388+
lookup(const IdType id)
389+
{
390+
auto &instance = Metrics::instance();
391+
392+
return reinterpret_cast<AtomicType *>(instance.lookup(id));
393+
}
394+
363395
static Metrics::IdType
364396
create(const std::string_view name)
365397
{
@@ -392,7 +424,7 @@ class Metrics
392424
}
393425

394426
static int64_t
395-
load(AtomicType *metric)
427+
load(const AtomicType *metric)
396428
{
397429
ink_assert(metric);
398430
return metric->_value.load();

src/proxy/http/PreWarmManager.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,7 +1178,7 @@ PreWarmManager::_register_stats(const PreWarm::ParsedSNIConf &parsed_conf)
11781178
++stats_counter;
11791179
}
11801180
} else {
1181-
metric = dynamic_cast<Metrics::Counter::AtomicType *>(metrics.lookup(stats_id));
1181+
metric = Metrics::Counter::lookup(stats_id);
11821182
}
11831183

11841184
counters[j] = metric;
@@ -1204,7 +1204,7 @@ PreWarmManager::_register_stats(const PreWarm::ParsedSNIConf &parsed_conf)
12041204
++stats_counter;
12051205
}
12061206
} else {
1207-
metric = dynamic_cast<Metrics::Gauge::AtomicType *>(metrics.lookup(stats_id));
1207+
metric = Metrics::Gauge::lookup(stats_id);
12081208
}
12091209

12101210
gauges[j] = metric;

0 commit comments

Comments
 (0)