| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
The 4-arg and 5-arg constructors require callers to pre-compute expositionBaseName and originalName, leaking internal naming logic into every caller site. The new builder encapsulates that logic: - name(): base name (unit appended if absent) - unit(): appended to name when not already present - counterSuffix(true): sets expositionBaseName to name + "_total", so the exposition writer knows to preserve the suffix rather than double-append it (relevant for UTF-8 metric names) Existing callers (MetricMetadataSupport, MetricMetadata.escape) keep the deprecated constructors with @SuppressWarnings("deprecation"). Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
|
|
||
| /** Builder for {@link MetricMetadata}. */ | ||
| @StableApi | ||
| public static final class Builder { |
There was a problem hiding this comment.
will this solve the use cases in this repo that we now have the suppressions on? i'm not sure it allows us to actually fully deprecate the constructors as-is.
For example, for MetricWithFixedMetadata i think we'd need:
this.metadata = MetricMetadata.builder()
.name(name)
.expositionBaseName(expositionBaseName)
.originalName(originalName)
.help(builder.help)
.unit(builder.unit)
.build();It might be worth trying to migrate any of the ones where we suppress the deprecation warning, just to see if it's possible
Sorry, something went wrong.
There was a problem hiding this comment.
good idea - done
Sorry, something went wrong.
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
🤖 I have created a release *beep* *boop* --- ## [1.8.0](v1.7.0...v1.8.0) (2026-06-11) ### Features * Add custom labels to exemplars ([#2191](#2191)) ([fd1f3e8](fd1f3e8)) * add MetricMetadata.Builder, deprecate wide constructors ([#2202](#2202)) ([adeef32](adeef32)) ### Bug Fixes * Avoid unnuecessary exemplar allocations ([#2209](#2209)) ([0b6a91f](0b6a91f)) * **deps:** update spring boot to v4.1.0 ([#2213](#2213)) ([df25c08](df25c08)) ### Documentation * cover typed family descriptors and @stableAPI since v1.6.1 ([#2181](#2181)) ([7ca9f99](7ca9f99)) --- > [!IMPORTANT] > Close and reopen this PR to trigger CI checks. --------- Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
| Back | FazBrowse Home | New Git URL |
Summary
Motivation
The OTel exporter (opentelemetry/opentelemetry-java#8346) needs to express per-strategy counter intent without pre-computing expositionBaseName manually. The builder encapsulates that logic and provides a cleaner public API for any downstream adapter that constructs MetricMetadata directly.
Test plan