Commit 9c0b5d1d authored by Dan Zhang's avatar Dan Zhang Committed by Commit Bot

relnote: Add platform API for UMA histograms.

Add stats platform API for client and server side.

R=rch@chromium.org

Change-Id: Ic26e26b1e77916f1f76da3c7cb9b1b1cc43e3e8f
Reviewed-on: https://chromium-review.googlesource.com/c/1344193Reviewed-by: default avatarRyan Hamilton <rch@chromium.org>
Commit-Queue: Dan Zhang <danzh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#611857}
parent 5f4aded6
...@@ -1521,6 +1521,7 @@ component("net") { ...@@ -1521,6 +1521,7 @@ component("net") {
"third_party/quic/platform/api/quic_aligned.h", "third_party/quic/platform/api/quic_aligned.h",
"third_party/quic/platform/api/quic_arraysize.h", "third_party/quic/platform/api/quic_arraysize.h",
"third_party/quic/platform/api/quic_bug_tracker.h", "third_party/quic/platform/api/quic_bug_tracker.h",
"third_party/quic/platform/api/quic_client_stats.h",
"third_party/quic/platform/api/quic_clock.cc", "third_party/quic/platform/api/quic_clock.cc",
"third_party/quic/platform/api/quic_clock.h", "third_party/quic/platform/api/quic_clock.h",
"third_party/quic/platform/api/quic_containers.h", "third_party/quic/platform/api/quic_containers.h",
...@@ -1551,6 +1552,7 @@ component("net") { ...@@ -1551,6 +1552,7 @@ component("net") {
"third_party/quic/platform/api/quic_prefetch.h", "third_party/quic/platform/api/quic_prefetch.h",
"third_party/quic/platform/api/quic_ptr_util.h", "third_party/quic/platform/api/quic_ptr_util.h",
"third_party/quic/platform/api/quic_reference_counted.h", "third_party/quic/platform/api/quic_reference_counted.h",
"third_party/quic/platform/api/quic_server_stats.h",
"third_party/quic/platform/api/quic_singleton.h", "third_party/quic/platform/api/quic_singleton.h",
"third_party/quic/platform/api/quic_sleep.h", "third_party/quic/platform/api/quic_sleep.h",
"third_party/quic/platform/api/quic_socket_address.cc", "third_party/quic/platform/api/quic_socket_address.cc",
...@@ -1565,11 +1567,11 @@ component("net") { ...@@ -1565,11 +1567,11 @@ component("net") {
"third_party/quic/platform/impl/quic_bug_tracker_impl.h", "third_party/quic/platform/impl/quic_bug_tracker_impl.h",
"third_party/quic/platform/impl/quic_chromium_clock.cc", "third_party/quic/platform/impl/quic_chromium_clock.cc",
"third_party/quic/platform/impl/quic_chromium_clock.h", "third_party/quic/platform/impl/quic_chromium_clock.h",
"third_party/quic/platform/impl/quic_client_stats_impl.h",
"third_party/quic/platform/impl/quic_containers_impl.h", "third_party/quic/platform/impl/quic_containers_impl.h",
"third_party/quic/platform/impl/quic_endian_impl.h", "third_party/quic/platform/impl/quic_endian_impl.h",
"third_party/quic/platform/impl/quic_estimate_memory_usage_impl.h", "third_party/quic/platform/impl/quic_estimate_memory_usage_impl.h",
"third_party/quic/platform/impl/quic_export_impl.h", "third_party/quic/platform/impl/quic_export_impl.h",
"third_party/quic/platform/impl/quic_exported_stats_impl.h",
"third_party/quic/platform/impl/quic_fallthrough_impl.h", "third_party/quic/platform/impl/quic_fallthrough_impl.h",
"third_party/quic/platform/impl/quic_file_utils_impl.h", "third_party/quic/platform/impl/quic_file_utils_impl.h",
"third_party/quic/platform/impl/quic_flag_utils_impl.h", "third_party/quic/platform/impl/quic_flag_utils_impl.h",
...@@ -1597,6 +1599,7 @@ component("net") { ...@@ -1597,6 +1599,7 @@ component("net") {
"third_party/quic/platform/impl/quic_prefetch_impl.h", "third_party/quic/platform/impl/quic_prefetch_impl.h",
"third_party/quic/platform/impl/quic_ptr_util_impl.h", "third_party/quic/platform/impl/quic_ptr_util_impl.h",
"third_party/quic/platform/impl/quic_reference_counted_impl.h", "third_party/quic/platform/impl/quic_reference_counted_impl.h",
"third_party/quic/platform/impl/quic_server_stats_impl.h",
"third_party/quic/platform/impl/quic_singleton_impl.h", "third_party/quic/platform/impl/quic_singleton_impl.h",
"third_party/quic/platform/impl/quic_sleep_impl.h", "third_party/quic/platform/impl/quic_sleep_impl.h",
"third_party/quic/platform/impl/quic_socket_address_impl.cc", "third_party/quic/platform/impl/quic_socket_address_impl.cc",
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "net/third_party/quic/core/quic_utils.h" #include "net/third_party/quic/core/quic_utils.h"
#include "net/third_party/quic/platform/api/quic_arraysize.h" #include "net/third_party/quic/platform/api/quic_arraysize.h"
#include "net/third_party/quic/platform/api/quic_bug_tracker.h" #include "net/third_party/quic/platform/api/quic_bug_tracker.h"
#include "net/third_party/quic/platform/api/quic_client_stats.h"
#include "net/third_party/quic/platform/api/quic_endian.h" #include "net/third_party/quic/platform/api/quic_endian.h"
#include "net/third_party/quic/platform/api/quic_hostname_utils.h" #include "net/third_party/quic/platform/api/quic_hostname_utils.h"
#include "net/third_party/quic/platform/api/quic_logging.h" #include "net/third_party/quic/platform/api/quic_logging.h"
...@@ -40,17 +41,17 @@ namespace { ...@@ -40,17 +41,17 @@ namespace {
// ClientHello to the server. // ClientHello to the server.
void RecordInchoateClientHelloReason( void RecordInchoateClientHelloReason(
QuicCryptoClientConfig::CachedState::ServerConfigState state) { QuicCryptoClientConfig::CachedState::ServerConfigState state) {
UMA_HISTOGRAM_ENUMERATION( QUIC_CLIENT_HISTOGRAM_ENUM(
"Net.QuicInchoateClientHelloReason", state, "QuicInchoateClientHelloReason", state,
QuicCryptoClientConfig::CachedState::SERVER_CONFIG_COUNT); QuicCryptoClientConfig::CachedState::SERVER_CONFIG_COUNT, "");
} }
// Tracks the state of the QUIC server information loaded from the disk cache. // Tracks the state of the QUIC server information loaded from the disk cache.
void RecordDiskCacheServerConfigState( void RecordDiskCacheServerConfigState(
QuicCryptoClientConfig::CachedState::ServerConfigState state) { QuicCryptoClientConfig::CachedState::ServerConfigState state) {
UMA_HISTOGRAM_ENUMERATION( QUIC_CLIENT_HISTOGRAM_ENUM(
"Net.QuicServerInfo.DiskCacheState", state, "QuicServerInfo.DiskCacheState", state,
QuicCryptoClientConfig::CachedState::SERVER_CONFIG_COUNT); QuicCryptoClientConfig::CachedState::SERVER_CONFIG_COUNT, "");
} }
} // namespace } // namespace
...@@ -86,8 +87,8 @@ bool QuicCryptoClientConfig::CachedState::IsComplete(QuicWallTime now) const { ...@@ -86,8 +87,8 @@ bool QuicCryptoClientConfig::CachedState::IsComplete(QuicWallTime now) const {
const CryptoHandshakeMessage* scfg = GetServerConfig(); const CryptoHandshakeMessage* scfg = GetServerConfig();
if (!scfg) { if (!scfg) {
// Should be impossible short of cache corruption. // Should be impossible short of cache corruption.
DCHECK(false);
RecordInchoateClientHelloReason(SERVER_CONFIG_CORRUPTED); RecordInchoateClientHelloReason(SERVER_CONFIG_CORRUPTED);
DCHECK(false);
return false; return false;
} }
...@@ -95,11 +96,13 @@ bool QuicCryptoClientConfig::CachedState::IsComplete(QuicWallTime now) const { ...@@ -95,11 +96,13 @@ bool QuicCryptoClientConfig::CachedState::IsComplete(QuicWallTime now) const {
return true; return true;
} }
UMA_HISTOGRAM_CUSTOM_TIMES( QUIC_CLIENT_HISTOGRAM_TIMES(
"Net.QuicClientHelloServerConfig.InvalidDuration", "QuicClientHelloServerConfig.InvalidDuration",
base::TimeDelta::FromSeconds(now.ToUNIXSeconds() - QuicTime::Delta::FromSeconds(now.ToUNIXSeconds() -
expiration_time_.ToUNIXSeconds()), expiration_time_.ToUNIXSeconds()),
base::TimeDelta::FromMinutes(1), base::TimeDelta::FromDays(20), 50); QuicTime::Delta::FromSeconds(60), // 1 min.
QuicTime::Delta::FromSeconds(20 * 24 * 3600), // 20 days.
50, "");
RecordInchoateClientHelloReason(SERVER_CONFIG_EXPIRED); RecordInchoateClientHelloReason(SERVER_CONFIG_EXPIRED);
return false; return false;
} }
...@@ -413,9 +416,9 @@ QuicCryptoClientConfig::CachedState* QuicCryptoClientConfig::LookupOrCreate( ...@@ -413,9 +416,9 @@ QuicCryptoClientConfig::CachedState* QuicCryptoClientConfig::LookupOrCreate(
CachedState* cached = new CachedState; CachedState* cached = new CachedState;
cached_states_.insert(std::make_pair(server_id, QuicWrapUnique(cached))); cached_states_.insert(std::make_pair(server_id, QuicWrapUnique(cached)));
bool cache_populated = PopulateFromCanonicalConfig(server_id, cached); bool cache_populated = PopulateFromCanonicalConfig(server_id, cached);
UMA_HISTOGRAM_BOOLEAN( QUIC_CLIENT_HISTOGRAM_BOOL(
"Net.QuicCryptoClientConfig.PopulatedFromCanonicalConfig", "QuicCryptoClientConfig.PopulatedFromCanonicalConfig", cache_populated,
cache_populated); "");
return cached; return cached;
} }
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "net/third_party/quic/core/quic_pending_retransmission.h" #include "net/third_party/quic/core/quic_pending_retransmission.h"
#include "net/third_party/quic/core/quic_utils.h" #include "net/third_party/quic/core/quic_utils.h"
#include "net/third_party/quic/platform/api/quic_bug_tracker.h" #include "net/third_party/quic/platform/api/quic_bug_tracker.h"
#include "net/third_party/quic/platform/api/quic_client_stats.h"
#include "net/third_party/quic/platform/api/quic_exported_stats.h" #include "net/third_party/quic/platform/api/quic_exported_stats.h"
#include "net/third_party/quic/platform/api/quic_flag_utils.h" #include "net/third_party/quic/platform/api/quic_flag_utils.h"
#include "net/third_party/quic/platform/api/quic_flags.h" #include "net/third_party/quic/platform/api/quic_flags.h"
...@@ -1971,8 +1972,8 @@ void QuicConnection::WriteQueuedPackets() { ...@@ -1971,8 +1972,8 @@ void QuicConnection::WriteQueuedPackets() {
SendVersionNegotiationPacket(send_ietf_version_negotiation_packet_); SendVersionNegotiationPacket(send_ietf_version_negotiation_packet_);
} }
UMA_HISTOGRAM_COUNTS_1000("Net.QuicSession.NumQueuedPacketsBeforeWrite", QUIC_CLIENT_HISTOGRAM_COUNTS("QuicSession.NumQueuedPacketsBeforeWrite",
queued_packets_.size()); queued_packets_.size(), 1, 1000, 50, "");
while (!queued_packets_.empty()) { while (!queued_packets_.empty()) {
// WritePacket() can potentially clear all queued packets, so we need to // WritePacket() can potentially clear all queued packets, so we need to
// save the first queued packet to a local variable before calling it. // save the first queued packet to a local variable before calling it.
...@@ -2126,8 +2127,8 @@ bool QuicConnection::WritePacket(SerializedPacket* packet) { ...@@ -2126,8 +2127,8 @@ bool QuicConnection::WritePacket(SerializedPacket* packet) {
if (packet->packet_number < sent_packet_manager_.GetLargestSentPacket()) { if (packet->packet_number < sent_packet_manager_.GetLargestSentPacket()) {
QUIC_BUG << "Attempt to write packet:" << packet->packet_number QUIC_BUG << "Attempt to write packet:" << packet->packet_number
<< " after:" << sent_packet_manager_.GetLargestSentPacket(); << " after:" << sent_packet_manager_.GetLargestSentPacket();
UMA_HISTOGRAM_COUNTS_1000("Net.QuicSession.NumQueuedPacketsAtOutOfOrder", QUIC_CLIENT_HISTOGRAM_COUNTS("QuicSession.NumQueuedPacketsAtOutOfOrder",
queued_packets_.size()); queued_packets_.size(), 1, 1000, 50, "");
CloseConnection(QUIC_INTERNAL_ERROR, "Packet written out of order.", CloseConnection(QUIC_INTERNAL_ERROR, "Packet written out of order.",
ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET);
return true; return true;
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "net/third_party/quic/core/crypto/crypto_protocol.h" #include "net/third_party/quic/core/crypto/crypto_protocol.h"
#include "net/third_party/quic/core/crypto/crypto_utils.h" #include "net/third_party/quic/core/crypto/crypto_utils.h"
#include "net/third_party/quic/core/quic_session.h" #include "net/third_party/quic/core/quic_session.h"
#include "net/third_party/quic/platform/api/quic_client_stats.h"
#include "net/third_party/quic/platform/api/quic_flags.h" #include "net/third_party/quic/platform/api/quic_flags.h"
#include "net/third_party/quic/platform/api/quic_logging.h" #include "net/third_party/quic/platform/api/quic_logging.h"
#include "net/third_party/quic/platform/api/quic_str_cat.h" #include "net/third_party/quic/platform/api/quic_str_cat.h"
...@@ -96,6 +97,7 @@ QuicCryptoClientHandshaker::QuicCryptoClientHandshaker( ...@@ -96,6 +97,7 @@ QuicCryptoClientHandshaker::QuicCryptoClientHandshaker(
proof_handler_(proof_handler), proof_handler_(proof_handler),
verify_ok_(false), verify_ok_(false),
stateless_reject_received_(false), stateless_reject_received_(false),
proof_verify_start_time_(QuicTime::Zero()),
num_scup_messages_received_(0), num_scup_messages_received_(0),
encryption_established_(false), encryption_established_(false),
handshake_confirmed_(false), handshake_confirmed_(false),
...@@ -272,7 +274,7 @@ void QuicCryptoClientHandshaker::DoInitialize( ...@@ -272,7 +274,7 @@ void QuicCryptoClientHandshaker::DoInitialize(
// the proof. // the proof.
DCHECK(crypto_config_->proof_verifier()); DCHECK(crypto_config_->proof_verifier());
// Track proof verification time when cached server config is used. // Track proof verification time when cached server config is used.
proof_verify_start_time_ = base::TimeTicks::Now(); proof_verify_start_time_ = session()->connection()->clock()->Now();
chlo_hash_ = cached->chlo_hash(); chlo_hash_ = cached->chlo_hash();
// If the cached state needs to be verified, do it now. // If the cached state needs to be verified, do it now.
next_state_ = STATE_VERIFY_PROOF; next_state_ = STATE_VERIFY_PROOF;
...@@ -426,11 +428,11 @@ void QuicCryptoClientHandshaker::DoReceiveREJ( ...@@ -426,11 +428,11 @@ void QuicCryptoClientHandshaker::DoReceiveREJ(
} }
DVLOG(1) << "Reasons for rejection: " << packed_error; DVLOG(1) << "Reasons for rejection: " << packed_error;
if (num_client_hellos_ == QuicCryptoClientStream::kMaxClientHellos) { if (num_client_hellos_ == QuicCryptoClientStream::kMaxClientHellos) {
base::UmaHistogramSparse("Net.QuicClientHelloRejectReasons.TooMany", QuicClientSparseHistogram("QuicClientHelloRejectReasons.TooMany",
packed_error); packed_error);
} }
base::UmaHistogramSparse("Net.QuicClientHelloRejectReasons.Secure", QuicClientSparseHistogram("QuicClientHelloRejectReasons.Secure",
packed_error); packed_error);
} }
// Receipt of a REJ message means that the server received the CHLO // Receipt of a REJ message means that the server received the CHLO
...@@ -498,9 +500,12 @@ QuicAsyncStatus QuicCryptoClientHandshaker::DoVerifyProof( ...@@ -498,9 +500,12 @@ QuicAsyncStatus QuicCryptoClientHandshaker::DoVerifyProof(
void QuicCryptoClientHandshaker::DoVerifyProofComplete( void QuicCryptoClientHandshaker::DoVerifyProofComplete(
QuicCryptoClientConfig::CachedState* cached) { QuicCryptoClientConfig::CachedState* cached) {
if (!proof_verify_start_time_.is_null()) { if (proof_verify_start_time_.IsInitialized()) {
UMA_HISTOGRAM_TIMES("Net.QuicSession.VerifyProofTime.CachedServerConfig", QUIC_CLIENT_HISTOGRAM_TIMES(
base::TimeTicks::Now() - proof_verify_start_time_); "QuicSession.VerifyProofTime.CachedServerConfig",
(session()->connection()->clock()->Now() - proof_verify_start_time_),
QuicTime::Delta::FromMilliseconds(1), QuicTime::Delta::FromSeconds(10),
50, "");
} }
if (!verify_ok_) { if (!verify_ok_) {
if (verify_details_) { if (verify_details_) {
...@@ -512,8 +517,8 @@ void QuicCryptoClientHandshaker::DoVerifyProofComplete( ...@@ -512,8 +517,8 @@ void QuicCryptoClientHandshaker::DoVerifyProofComplete(
return; return;
} }
next_state_ = STATE_NONE; next_state_ = STATE_NONE;
UMA_HISTOGRAM_BOOLEAN("Net.QuicVerifyProofFailed.HandshakeConfirmed", QUIC_CLIENT_HISTOGRAM_BOOL("QuicVerifyProofFailed.HandshakeConfirmed",
handshake_confirmed()); handshake_confirmed(), "");
stream_->CloseConnectionWithDetails( stream_->CloseConnectionWithDetails(
QUIC_PROOF_INVALID, "Proof invalid: " + verify_error_details_); QUIC_PROOF_INVALID, "Proof invalid: " + verify_error_details_);
return; return;
...@@ -663,8 +668,8 @@ void QuicCryptoClientHandshaker::DoInitializeServerConfigUpdate( ...@@ -663,8 +668,8 @@ void QuicCryptoClientHandshaker::DoInitializeServerConfigUpdate(
update_ignored = true; update_ignored = true;
next_state_ = STATE_NONE; next_state_ = STATE_NONE;
} }
UMA_HISTOGRAM_COUNTS_1M("Net.QuicNumServerConfig.UpdateMessagesIgnored", QUIC_CLIENT_HISTOGRAM_COUNTS("QuicNumServerConfig.UpdateMessagesIgnored",
update_ignored); update_ignored, 1, 1000000, 50, "");
} }
void QuicCryptoClientHandshaker::SetCachedProofValid( void QuicCryptoClientHandshaker::SetCachedProofValid(
......
...@@ -221,8 +221,7 @@ class QUIC_EXPORT_PRIVATE QuicCryptoClientHandshaker ...@@ -221,8 +221,7 @@ class QUIC_EXPORT_PRIVATE QuicCryptoClientHandshaker
// STATE_VERIFY_PROOF*, and subsequent STATE_SEND_CHLO state. // STATE_VERIFY_PROOF*, and subsequent STATE_SEND_CHLO state.
bool stateless_reject_received_; bool stateless_reject_received_;
// Only used in chromium, not internally. QuicTime proof_verify_start_time_;
base::TimeTicks proof_verify_start_time_;
int num_scup_messages_received_; int num_scup_messages_received_;
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef NET_THIRD_PARTY_QUIC_PLATFORM_API_QUIC_CLIENT_STATS_H_
#define NET_THIRD_PARTY_QUIC_PLATFORM_API_QUIC_CLIENT_STATS_H_
#include "net/third_party/quic/platform/impl/quic_client_stats_impl.h"
namespace quic {
//------------------------------------------------------------------------------
// Enumeration histograms.
//
// Sample usage:
// // In Chrome, these values are persisted to logs. Entries should not be
// // renumbered and numeric values should never be reused.
// enum class MyEnum {
// FIRST_VALUE = 0,
// SECOND_VALUE = 1,
// ...
// FINAL_VALUE = N,
// COUNT
// };
// QUIC_CLIENT_HISTOGRAM_ENUM("My.Enumeration", MyEnum::SOME_VALUE,
// MyEnum::COUNT, "Number of time $foo equals to some enum value");
//
// Note: The value in |sample| must be strictly less than |enum_size|.
#define QUIC_CLIENT_HISTOGRAM_ENUM(name, sample, enum_size, docstring) \
QUIC_CLIENT_HISTOGRAM_ENUM_IMPL(name, sample, enum_size, docstring)
//------------------------------------------------------------------------------
// Histogram for boolean values.
// Sample usage:
// QUIC_CLIENT_HISTOGRAM_BOOL("My.Boolean", bool,
// "Number of times $foo is true or false");
#define QUIC_CLIENT_HISTOGRAM_BOOL(name, sample, docstring) \
QUIC_CLIENT_HISTOGRAM_BOOL_IMPL(name, sample, docstring)
//------------------------------------------------------------------------------
// Timing histograms. These are used for collecting timing data (generally
// latencies).
// These macros create exponentially sized histograms (lengths of the bucket
// ranges exponentially increase as the sample range increases). The units for
// sample and max are unspecified, but they must be the same for one histogram.
// Sample usage:
// QUIC_CLIENT_HISTOGRAM_TIMES("Very.Long.Timing.Histogram", time_delta,
// QuicTime::Delta::FromSeconds(1), QuicTime::Delta::FromSecond(3600 *
// 24), 100, "Time spent in doing operation.");
#define QUIC_CLIENT_HISTOGRAM_TIMES(name, sample, min, max, bucket_count, \
docstring) \
QUIC_CLIENT_HISTOGRAM_TIMES_IMPL(name, sample, min, max, bucket_count, \
docstring)
//------------------------------------------------------------------------------
// Count histograms. These are used for collecting numeric data.
// These macros default to exponential histograms - i.e. the lengths of the
// bucket ranges exponentially increase as the sample range increases.
// All of these macros must be called with |name| as a runtime constant.
// Any data outside the range here will be put in underflow and overflow
// buckets. Min values should be >=1 as emitted 0s will still go into the
// underflow bucket.
// Sample usage:
// UMA_CLIENT_HISTOGRAM_CUSTOM_COUNTS("My.Histogram", 1, 100000000, 100,
// "Counters of hitting certian code.");
#define QUIC_CLIENT_HISTOGRAM_COUNTS(name, sample, min, max, bucket_count, \
docstring) \
QUIC_CLIENT_HISTOGRAM_COUNTS_IMPL(name, sample, min, max, bucket_count, \
docstring)
inline void QuicClientSparseHistogram(const std::string& name, int sample) {
QuicClientSparseHistogramImpl(name, sample);
}
} // namespace quic
#endif // NET_THIRD_PARTY_QUIC_PLATFORM_API_QUIC_CLIENT_STATS_H_
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
#ifndef NET_THIRD_PARTY_QUIC_PLATFORM_API_QUIC_EXPORTED_STATS_H_ #ifndef NET_THIRD_PARTY_QUIC_PLATFORM_API_QUIC_EXPORTED_STATS_H_
#define NET_THIRD_PARTY_QUIC_PLATFORM_API_QUIC_EXPORTED_STATS_H_ #define NET_THIRD_PARTY_QUIC_PLATFORM_API_QUIC_EXPORTED_STATS_H_
#include "net/third_party/quic/platform/impl/quic_exported_stats_impl.h" #include "net/third_party/quic/platform/impl/quic_client_stats_impl.h"
#include "net/third_party/quic/platform/impl/quic_server_stats_impl.h"
namespace quic { namespace quic {
...@@ -29,8 +30,11 @@ namespace quic { ...@@ -29,8 +30,11 @@ namespace quic {
// //
// Note: The value in |sample| must be strictly less than |enum_size|. // Note: The value in |sample| must be strictly less than |enum_size|.
#define QUIC_HISTOGRAM_ENUM(name, sample, enum_size, docstring) \ #define QUIC_HISTOGRAM_ENUM(name, sample, enum_size, docstring) \
QUIC_HISTOGRAM_ENUM_IMPL(name, sample, enum_size, docstring) do { \
QUIC_CLIENT_HISTOGRAM_ENUM_IMPL(name, sample, enum_size, docstring); \
QUIC_SERVER_HISTOGRAM_ENUM_IMPL(name, sample, enum_size, docstring); \
} while (0)
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Histogram for boolean values. // Histogram for boolean values.
...@@ -38,8 +42,11 @@ namespace quic { ...@@ -38,8 +42,11 @@ namespace quic {
// Sample usage: // Sample usage:
// QUIC_HISTOGRAM_BOOL("My.Boolean", bool, // QUIC_HISTOGRAM_BOOL("My.Boolean", bool,
// "Number of times $foo is true or false"); // "Number of times $foo is true or false");
#define QUIC_HISTOGRAM_BOOL(name, sample, docstring) \ #define QUIC_HISTOGRAM_BOOL(name, sample, docstring) \
QUIC_HISTOGRAM_BOOL_IMPL(name, sample, docstring) do { \
QUIC_CLIENT_HISTOGRAM_BOOL_IMPL(name, sample, docstring); \
QUIC_SERVER_HISTOGRAM_BOOL_IMPL(name, sample, docstring); \
} while (0)
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Timing histograms. These are used for collecting timing data (generally // Timing histograms. These are used for collecting timing data (generally
...@@ -50,13 +57,17 @@ namespace quic { ...@@ -50,13 +57,17 @@ namespace quic {
// sample and max are unspecified, but they must be the same for one histogram. // sample and max are unspecified, but they must be the same for one histogram.
// Sample usage: // Sample usage:
// QUIC_HISTOGRAM_TIMES("My.Timing.Histogram.InMs", // QUIC_HISTOGRAM_TIMES("My.Timing.Histogram.InMs", time_delta,
// sample, // Time spent in milliseconds. // QuicTime::Delta::FromSeconds(1), QuicTime::Delta::FromSecond(3600 *
// 10 * 1000, // Record up to 10K milliseconds. // 24), 100, "Time spent in doing operation.");
// "Time spent in doing something");
#define QUIC_HISTOGRAM_TIMES(name, sample, min, max, bucket_count, docstring) \
#define QUIC_HISTOGRAM_TIMES(name, sample, max, docstring) \ do { \
QUIC_HISTOGRAM_TIMES_IMPL(name, sample, max, 50, docstring) QUIC_CLIENT_HISTOGRAM_TIMES_IMPL(name, sample, min, max, bucket_count, \
docstring) \
QUIC_SERVER_HISTOGRAM_TIMES_IMPL(name, sample, min, max, bucket_count, \
docstring) \
} while (0)
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Count histograms. These are used for collecting numeric data. // Count histograms. These are used for collecting numeric data.
...@@ -72,8 +83,13 @@ namespace quic { ...@@ -72,8 +83,13 @@ namespace quic {
// 1000, // Record up to 1K of something. // 1000, // Record up to 1K of something.
// "Number of something."); // "Number of something.");
#define QUIC_HISTOGRAM_COUNTS(name, sample, max, docstring) \ #define QUIC_HISTOGRAM_COUNTS(name, sample, min, max, bucket_count, docstring) \
QUIC_HISTOGRAM_COUNTS_IMPL(name, sample, max, 50, docstring) do { \
QUIC_CLIENT_HISTOGRAM_COUNTS_IMPL(name, sample, min, max, bucket_count, \
docstring); \
QUIC_SERVER_HISTOGRAM_COUNTS_IMPL(name, sample, min, max, bucket_count, \
docstring); \
} while (0)
} // namespace quic } // namespace quic
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef NET_THIRD_PARTY_QUIC_PLATFORM_API_QUIC_SERVER_STATS_H_
#define NET_THIRD_PARTY_QUIC_PLATFORM_API_QUIC_SERVER_STATS_H_
#include "net/third_party/quic/platform/impl/quic_server_stats_impl.h"
namespace quic {
//------------------------------------------------------------------------------
// Enumeration histograms.
//
// Sample usage:
// // In Chrome, these values are persisted to logs. Entries should not be
// // renumbered and numeric values should never be reused.
// enum class MyEnum {
// FIRST_VALUE = 0,
// SECOND_VALUE = 1,
// ...
// FINAL_VALUE = N,
// COUNT
// };
// QUIC_SERVER_HISTOGRAM_ENUM("My.Enumeration", MyEnum::SOME_VALUE,
// MyEnum::COUNT, "Number of time $foo equals to some enum value");
//
// Note: The value in |sample| must be strictly less than |enum_size|.
#define QUIC_SERVER_HISTOGRAM_ENUM(name, sample, enum_size, docstring) \
QUIC_SERVER_HISTOGRAM_ENUM_IMPL(name, sample, enum_size, docstring)
//------------------------------------------------------------------------------
// Histogram for boolean values.
// Sample usage:
// QUIC_SERVER_HISTOGRAM_BOOL("My.Boolean", bool,
// "Number of times $foo is true or false");
#define QUIC_SERVER_HISTOGRAM_BOOL(name, sample, docstring) \
QUIC_SERVER_HISTOGRAM_BOOL_IMPL(name, sample, docstring)
//------------------------------------------------------------------------------
// Timing histograms. These are used for collecting timing data (generally
// latencies).
// These macros create exponentially sized histograms (lengths of the bucket
// ranges exponentially increase as the sample range increases). The units for
// sample and max are unspecified, but they must be the same for one histogram.
// Sample usage:
// QUIC_SERVER_HISTOGRAM_TIMES("Very.Long.Timing.Histogram", time_delta,
// QuicTime::Delta::FromSeconds(1), QuicTime::Delta::FromSecond(3600 *
// 24), 100, "Time spent in doing operation.");
#define QUIC_SERVER_HISTOGRAM_TIMES(name, sample, min, max, bucket_count, \
docstring) \
QUIC_SERVER_HISTOGRAM_TIMES_IMPL(name, sample, min, max, bucket_count, \
docstring)
//------------------------------------------------------------------------------
// Count histograms. These are used for collecting numeric data.
// These macros default to exponential histograms - i.e. the lengths of the
// bucket ranges exponentially increase as the sample range increases.
// All of these macros must be called with |name| as a runtime constant.
// Any data outside the range here will be put in underflow and overflow
// buckets. Min values should be >=1 as emitted 0s will still go into the
// underflow bucket.
// Sample usage:
// QUIC_SERVER_SERVER_HISTOGRAM_CUSTOM_COUNTS("My.Histogram", 1, 100000000,
// 100, "Counters of hitting certian code.");
#define QUIC_SERVER_HISTOGRAM_COUNTS(name, sample, min, max, bucket_count, \
docstring) \
QUIC_SERVER_HISTOGRAM_COUNTS_IMPL(name, sample, min, max, bucket_count, \
docstring)
} // namespace quic
#endif // NET_THIRD_PARTY_QUIC_PLATFORM_API_QUIC_SERVER_STATS_H_
...@@ -2,25 +2,39 @@ ...@@ -2,25 +2,39 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef NET_THIRD_PARTY_QUIC_PLATFORM_IMPL_QUIC_EXPORTED_STATS_IMPL_H_ #ifndef NET_THIRD_PARTY_QUIC_PLATFORM_IMPL_QUIC_CLIENT_STATS_IMPL_H_
#define NET_THIRD_PARTY_QUIC_PLATFORM_IMPL_QUIC_EXPORTED_STATS_IMPL_H_ #define NET_THIRD_PARTY_QUIC_PLATFORM_IMPL_QUIC_CLIENT_STATS_IMPL_H_
#include "base/metrics/histogram_functions.h"
namespace quic {
// By convention, all QUIC histograms are prefixed by "Net.". // By convention, all QUIC histograms are prefixed by "Net.".
#define QUIC_HISTOGRAM_NAME(raw_name) "Net." raw_name #define QUIC_HISTOGRAM_NAME(raw_name) "Net." raw_name
#define QUIC_HISTOGRAM_ENUM_IMPL(name, sample, enum_size, docstring) \ #define QUIC_CLIENT_HISTOGRAM_ENUM_IMPL(name, sample, enum_size, docstring) \
UMA_HISTOGRAM_ENUMERATION(QUIC_HISTOGRAM_NAME(name), sample, enum_size) UMA_HISTOGRAM_ENUMERATION(QUIC_HISTOGRAM_NAME(name), sample, enum_size)
#define QUIC_HISTOGRAM_BOOL_IMPL(name, sample, docstring) \ #define QUIC_CLIENT_HISTOGRAM_BOOL_IMPL(name, sample, docstring) \
UMA_HISTOGRAM_BOOLEAN(QUIC_HISTOGRAM_NAME(name), sample) UMA_HISTOGRAM_BOOLEAN(QUIC_HISTOGRAM_NAME(name), sample)
#define QUIC_HISTOGRAM_TIMES_IMPL(name, sample, max, num_buckets, docstring) \ #define QUIC_CLIENT_HISTOGRAM_TIMES_IMPL(name, sample, min, max, bucket_count, \
docstring) \
UMA_HISTOGRAM_CUSTOM_TIMES( \ UMA_HISTOGRAM_CUSTOM_TIMES( \
QUIC_HISTOGRAM_NAME(name), sample, base::TimeDelta::FromMilliseconds(1), \ QUIC_HISTOGRAM_NAME(name), \
base::TimeDelta::FromMilliseconds(max), num_buckets) base::TimeDelta::FromMicroseconds(sample.ToMicroseconds()), \
base::TimeDelta::FromMicroseconds(min.ToMicroseconds()), \
base::TimeDelta::FromMicroseconds(max.ToMicroseconds()), bucket_count)
#define QUIC_CLIENT_HISTOGRAM_COUNTS_IMPL(name, sample, min, max, \
bucket_count, docstring) \
UMA_HISTOGRAM_CUSTOM_COUNTS(QUIC_HISTOGRAM_NAME(name), sample, min, max, \
bucket_count)
inline void QuicClientSparseHistogramImpl(const std::string& name, int sample) {
base::UmaHistogramSparse(name, sample);
}
#define QUIC_HISTOGRAM_COUNTS_IMPL(name, sample, max, num_buckets, docstring) \ } // namespace quic
UMA_HISTOGRAM_CUSTOM_COUNTS(QUIC_HISTOGRAM_NAME(name), sample, 1, max, \
num_buckets)
#endif // NET_THIRD_PARTY_QUIC_PLATFORM_IMPL_QUIC_EXPORTED_STATS_IMPL_H_ #endif // NET_THIRD_PARTY_QUIC_PLATFORM_IMPL_QUIC_CLIENT_STATS_IMPL_H_
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef NET_THIRD_PARTY_QUIC_PLATFORM_IMPL_QUIC_SERVER_STATS_IMPL_H_
#define NET_THIRD_PARTY_QUIC_PLATFORM_IMPL_QUIC_SERVER_STATS_IMPL_H_
namespace quic {
#define QUIC_SERVER_HISTOGRAM_ENUM_IMPL(name, sample, enum_size, docstring) \
do { \
} while (0)
#define QUIC_SERVER_HISTOGRAM_BOOL_IMPL(name, sample, docstring) \
do { \
} while (0)
#define QUIC_SERVER_HISTOGRAM_TIMES_IMPL(name, sample, min, max, bucket_count, \
docstring) \
do { \
} while (0)
#define QUIC_SERVER_HISTOGRAM_COUNTS_IMPL(name, sample, min, max, \
bucket_count, docstring) \
do { \
} while (0)
} // namespace quic
#endif // NET_THIRD_PARTY_QUIC_PLATFORM_IMPL_QUIC_SERVER_STATS_IMPL_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment