Title: Theory / Important / Chrome / Metrics / Histogram
On every note of this deck, unless a note says otherwise:
Page: https://chromium.googlesource.com/chromium/src.git/+/HEAD/tools/metrics/histograms/README.md#Enum-Histograms

Name: Histogram
Definition: Events that occur in chrome Google want to track
Page: https://chromium.googlesource.com/chromium/src.git/+/HEAD/tools/metrics/histograms/README.md#Enum-Histograms
Context: Chrome

Question: The kinds of histogram
Answer: Enumerated histogram
Context: Chrome
Answer2: Count histogram
Answer3: Sparse histogram

Question: What kind of histogram to use when the precision is important over a wide range
Answer: Sparse histogram
Context: Chrome

Question: What kind of histogram to use when the range is not possible to specify a priori
Answer: Sparse histogram
Context: Chrome

Question: What kind of histogram to use for arbitrary number
Answer: count histogram
Context: Chrome

Question: Best practice to derive a measure from another one
Answer: Never do it.
Context: Chrome

Question: How are histogram named
Answer: category.subcategory...subsubcategory.name
Context: Chrome

Question: How to create a new histogram category
Answer: Have it reviewed by chromium-metrics-reviews@google.com
Context: Chrome
Answer2: add it to tools/metrics/histograms/histograms.xml

Question: How to record an histogram
Answer: With function most of the time, but with macro on critical path
Context: Chrome

Question: How to use the same histogram in multiple place?
Answer: Use a helper function that ensure that all calls are consistent
Context: Chrome

Question: Enums logged in histograms must
Answer: be prefixed with the comment:
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused
Context: Chrome
Answer2: be numbered starting from 0. Note this bullet point does not apply for enums logged with sparse histograms
Answer3: have enumerators with explicit values (= 0, = 1, = 2) to make it clear that the actual values are important. This also makes it easy to match the values between the C++/Java definition and histograms.xml
Answer4: not renumber or reuse enumerator values. When adding a new enumerator, append the new enumerator to the end. When removing an unused enumerator, comment it out, making it clear the value was previously used.

Name: An enum histogram
Definition: An histogram which logs an event with one value in a finite determined set of value
Page: https://chromium.googlesource.com/chromium/src.git/+/HEAD/tools/metrics/histograms/README.md#Enum-Histograms
Context: Chrome
Example: What did the user do after opening a new tab

Constant: EnumClass.kMaxValue
Meaning: The maximal value associated to an element of EnumClass
Page: https://chromium.googlesource.com/chromium/src.git/+/HEAD/tools/metrics/histograms/README.md#Enum-Histograms
Context: Chrome

Question: When you measure something, what must you do
Answer: Have a base measure to compare it too
Context: Chrome

Instruction: UMA_HISTOGRAM_ENUMERATION("HistogramName", value);
UmaHistogramEnumeration("HistogramName", value);
Page: https://chromium.googlesource.com/chromium/src.git/+/HEAD/tools/metrics/histograms/README.md#Enum-Histograms
Effect: Log a value for HistogramName
Context: Chrome
Variables: HistogramName a name of an enumeration histogram

Question: How to create an enum for histogram
Answer: Start with enum value 0
Context: Chrome
Answer2: Save the enum in enums.xml
Answer3: In C++, set kMaxValue

Name: A count histogram
Definition: An histogram associated to a numerical value with a min/max.
Page: https://chromium.googlesource.com/chromium/src.git/+/HEAD/tools/metrics/histograms/README.md#Enum-Histograms
Context: Chrome

Question: What is the default number of buckets in count histogram
Answer: 50. Or 100 if wide range
Context: Chrome

Question: What are the buckets in wide range
Answer: They are exponentially distributed, to get precision in small counts
Context: Chrome

Name: A local histogram
Definition: An histogram that can be used for debugging and is not sent to UMA
Page: https://chromium.googlesource.com/chromium/src.git/+/HEAD/tools/metrics/histograms/README.md#Enum-Histograms
Context: Chrome

Question: What are the possible expirity dates of histogram
Answer: YYYY-MM-DD
Context: Chrome
Answer2: MNN a chrome version number
Answer3: Never (very rare)

Question: How to prolong an histogram
Answer: If it was expired, add a comment noting that it was not active from date D to D'
Context: Chrome

Question: What is the usual duration of an histogram
Answer: 3 to 6 months after feature launch
Context: Chrome
Answer2: always for heartbeat

Variable: chrome://histograms
Meaning: Web pages with histograms sent by this machine
Page: https://chromium.googlesource.com/chromium/src.git/+/HEAD/tools/metrics/histograms/README.md#Enum-Histograms
Context: Chrome

Variable: chrome://histograms/foo
Meaning: List histograms sent by this machine starting with foo
Page: https://chromium.googlesource.com/chromium/src.git/+/HEAD/tools/metrics/histograms/README.md#Enum-Histograms
Context: Chrome

Instruction: base::UmaHistogramBoolean("HistoName", b)
Page: https://source.chromium.org/chromium/chromium/src/+/main:base/metrics/histogram_functions.h
Effect: Add a sample indicating whether HistoName holds at the time it's emitted
Context: Chrome

Instruction: base::UmaHistogramPercentage("HistoName", p)
Page: https://source.chromium.org/chromium/chromium/src/+/main:base/metrics/histogram_functions.h
Effect: Add a sample for histoName at percentage p
Context: Chrome

Instruction: base::UmaHistogramEnumerate("HistoName", value)
Page: https://source.chromium.org/chromium/chromium/src/+/main:base/metrics/histogram_functions.h
Effect: Add a sample for HistoName, registering the value
Context: Chrome