[Metrics][Discover] Render legacy histograms with a warning#253044
Merged
kpatticha merged 8 commits intoelastic:mainfrom Feb 20, 2026
Merged
[Metrics][Discover] Render legacy histograms with a warning#253044kpatticha merged 8 commits intoelastic:mainfrom
kpatticha merged 8 commits intoelastic:mainfrom
Conversation
Contributor
💛 Build succeeded, but was flaky
Failed CI StepsMetrics [docs]Module Count
Async chunks
History
|
lucaslopezf
approved these changes
Feb 20, 2026
Contributor
lucaslopezf
left a comment
There was a problem hiding this comment.
Nice!! Could we add a test here for the legacy histogram, since we have for the other ones?
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #244194
Summary
TO_TDIGESTin ES|QL).Changes
Legacy histogram support
isLegacyHistogramhelper (src/common/utils/legacy_histogram.ts): Returnstruewhen both fieldtypeandinstrumentare'histogram'(legacy histogram). Used for filtering, aggregation choice, and when to show user messages.use_metric_fields(src/components/observability/metrics/hooks/use_metric_fields.ts): Skips a metric only when it is a histogram field but not a legacy histogram (metricField.type === 'histogram' && !isLegacyHistogram(metricField)). Legacy histograms are now included in the grid.src/common/utils/esql/create_aggregation.ts): For legacy histogram,getAggregationTemplatereturnsPERCENTILE(TO_TDIGEST(??placeholder), 95)so the chart renders the 95th percentile. Other types (exponential_histogram, tdigest, counter, default) are unchanged.Consumer-controlled user messages
src/components/observability/metrics/metrics_grid.tsx): Accepts onlygetUserMessages?: (metric: MetricField) => UserMessage[] | undefined. NouserMessagesprop. For each chart it passesuserMessages={getUserMessages ? getUserMessages(metric) : undefined}. The shared component no longer branches on metric type; the consumer decides what to pass.src/components/observability/metrics/metrics_experience_grid_content.tsx): PassesgetUserMessagesthat returnsLEGACY_HISTOGRAM_USER_MESSAGESwhenisLegacyHistogram(metric)is true, otherwiseundefined. So messages are shown only for legacy histogram metrics, and the decision lives in the consumer.User messages module
src/common/utils/user_messages.ts): New module that exportsLEGACY_HISTOGRAM_USER_MESSAGES(warning about T-Digest encoding). Re-exported fromsrc/common/utils/index.ts. Other message sets can be added to this module later.Tests
legacy_histogram.test.ts: Unit tests forisLegacyHistogram(true when type + instrument both histogram; false for histogram + other instrument, histogram + undefined, non-histogram type).create_aggregation.test.ts: Tests forgetAggregationTemplateincluding legacy histogram (returnsPERCENTILE(TO_TDIGEST(...), 95)) and non-legacy histogram (returnsAVG(...)). Existing tests forreplaceFunctionParamsandcreateTimeBucketAggregationremain.metrics_grid.test.tsx: Removed the test that expected auserMessagesprop. Kept the test that verifiesgetUserMessages(metric)is called per chart and its return value is passed to each chart.How to test
./forge --dataset histograms --count 5 --interval 10s --purgeScreen.Recording.2026-02-13.at.1.50.14.PM.mov