Skip to content

Commit d3fb9ef

Browse files
committed
Use const if available
Signed-off-by: Taiki Ono <[email protected]>
1 parent 1b10cee commit d3fb9ef

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

source/common/stats/statsd.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,26 +46,26 @@ UdpStatsdSink::UdpStatsdSink(ThreadLocal::SlotAllocator& tls,
4646
}
4747

4848
void UdpStatsdSink::flushCounter(const Counter& counter, uint64_t delta) {
49-
std::string message(
49+
const std::string message(
5050
fmt::format("envoy.{}:{}|c{}", getName(counter), delta, buildTagStr(counter.tags())));
5151
tls_->getTyped<Writer>().write(message);
5252
}
5353

5454
void UdpStatsdSink::flushGauge(const Gauge& gauge, uint64_t value) {
55-
std::string message(
55+
const std::string message(
5656
fmt::format("envoy.{}:{}|g{}", getName(gauge), value, buildTagStr(gauge.tags())));
5757
tls_->getTyped<Writer>().write(message);
5858
}
5959

6060
void UdpStatsdSink::onHistogramComplete(const Histogram& histogram, uint64_t value) {
6161
// For statsd histograms are all timers.
62-
std::string message(fmt::format("envoy.{}:{}|ms{}", getName(histogram),
62+
const std::string message(fmt::format("envoy.{}:{}|ms{}", getName(histogram),
6363
std::chrono::milliseconds(value).count(),
6464
buildTagStr(histogram.tags())));
6565
tls_->getTyped<Writer>().write(message);
6666
}
6767

68-
std::string UdpStatsdSink::getName(const Metric& metric) {
68+
const std::string UdpStatsdSink::getName(const Metric& metric) {
6969
if (use_tag_) {
7070
return metric.tagExtractedName();
7171
} else {

source/common/stats/statsd.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class UdpStatsdSink : public Sink {
5858
int getFdForTests() { return tls_->getTyped<Writer>().getFdForTests(); }
5959

6060
private:
61-
std::string getName(const Metric& metric);
61+
const std::string getName(const Metric& metric);
6262
const std::string buildTagStr(const std::vector<Tag>& tags);
6363

6464
ThreadLocal::SlotPtr tls_;

0 commit comments

Comments
 (0)