// not necessarily timers in milliseconds, for Envoy histograms suffixed with their corresponding
// SI unit symbol this is acceptable, but for histograms without a suffix, especially those which
// are timers but record in units other than milliseconds, it may make sense to scale the value to
// milliseconds here and potentially suffix the names accordingly (minus the pre-existing ones for
template <class StatType> const std::string UdpStatsdSink::getName(const StatType& metric) const {
void TcpStatsdSink::TlsSink::commonFlush(const std::string& name, uint64_t value, char stat_type) {
// This written this way for maximum perf since with a large number of stats and at a high flush
// Ultimately it would be nice to perf optimize this path also, but it's not very frequent. It's
void TcpStatsdSink::TlsSink::onPercentHistogramComplete(const std::string& name, float value) {
Buffer::OwnedImpl buffer(fmt::format("{}.{}:{}|h\n", parent_.getPrefix().c_str(), name, value));
Upstream::ClusterTrafficStats& cluster_traffic_stats = *parent_.cluster_info_->trafficStats();
if (cluster_traffic_stats.upstream_cx_tx_bytes_buffered_.value() > MAX_BUFFERED_STATS_BYTES) {
return current_slice_mem_ - reinterpret_cast<char*>(current_buffer_reservation_->slice().mem_);