blob: b780ba695c8216d021c463fc184f733cb16b0fdc [file] [log] [blame]
QUICHE teama6ef0a62019-03-07 20:34:33 -05001// Copyright 2018 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef QUICHE_QUIC_PLATFORM_API_QUIC_CLIENT_STATS_H_
6#define QUICHE_QUIC_PLATFORM_API_QUIC_CLIENT_STATS_H_
7
8#include <string>
9#include "net/quic/platform/impl/quic_client_stats_impl.h"
10
11namespace quic {
12
13//------------------------------------------------------------------------------
14// Enumeration histograms.
15//
16// Sample usage:
17// // In Chrome, these values are persisted to logs. Entries should not be
18// // renumbered and numeric values should never be reused.
19// enum class MyEnum {
20// FIRST_VALUE = 0,
21// SECOND_VALUE = 1,
22// ...
23// FINAL_VALUE = N,
24// COUNT
25// };
26// QUIC_CLIENT_HISTOGRAM_ENUM("My.Enumeration", MyEnum::SOME_VALUE,
27// MyEnum::COUNT, "Number of time $foo equals to some enum value");
28//
29// Note: The value in |sample| must be strictly less than |enum_size|.
30
31#define QUIC_CLIENT_HISTOGRAM_ENUM(name, sample, enum_size, docstring) \
32 QUIC_CLIENT_HISTOGRAM_ENUM_IMPL(name, sample, enum_size, docstring)
33
34//------------------------------------------------------------------------------
35// Histogram for boolean values.
36
37// Sample usage:
38// QUIC_CLIENT_HISTOGRAM_BOOL("My.Boolean", bool,
39// "Number of times $foo is true or false");
40#define QUIC_CLIENT_HISTOGRAM_BOOL(name, sample, docstring) \
41 QUIC_CLIENT_HISTOGRAM_BOOL_IMPL(name, sample, docstring)
42
43//------------------------------------------------------------------------------
44// Timing histograms. These are used for collecting timing data (generally
45// latencies).
46
47// These macros create exponentially sized histograms (lengths of the bucket
48// ranges exponentially increase as the sample range increases). The units for
49// sample and max are unspecified, but they must be the same for one histogram.
50
51// Sample usage:
52// QUIC_CLIENT_HISTOGRAM_TIMES("Very.Long.Timing.Histogram", time_delta,
53// QuicTime::Delta::FromSeconds(1), QuicTime::Delta::FromSecond(3600 *
54// 24), 100, "Time spent in doing operation.");
55#define QUIC_CLIENT_HISTOGRAM_TIMES(name, sample, min, max, bucket_count, \
56 docstring) \
57 QUIC_CLIENT_HISTOGRAM_TIMES_IMPL(name, sample, min, max, bucket_count, \
58 docstring)
59
60//------------------------------------------------------------------------------
61// Count histograms. These are used for collecting numeric data.
62
63// These macros default to exponential histograms - i.e. the lengths of the
64// bucket ranges exponentially increase as the sample range increases.
65
66// All of these macros must be called with |name| as a runtime constant.
67
68// Any data outside the range here will be put in underflow and overflow
69// buckets. Min values should be >=1 as emitted 0s will still go into the
70// underflow bucket.
71
72// Sample usage:
73// UMA_CLIENT_HISTOGRAM_CUSTOM_COUNTS("My.Histogram", 1, 100000000, 100,
74// "Counters of hitting certian code.");
75
76#define QUIC_CLIENT_HISTOGRAM_COUNTS(name, sample, min, max, bucket_count, \
77 docstring) \
78 QUIC_CLIENT_HISTOGRAM_COUNTS_IMPL(name, sample, min, max, bucket_count, \
79 docstring)
80
81inline void QuicClientSparseHistogram(const std::string& name, int sample) {
82 QuicClientSparseHistogramImpl(name, sample);
83}
84
85} // namespace quic
86
87#endif // QUICHE_QUIC_PLATFORM_API_QUIC_CLIENT_STATS_H_