Class MetricMetadata.Builder

java.lang.Object
io.prometheus.metrics.model.snapshots.MetricMetadata.Builder
Enclosing class:
MetricMetadata

public static final class MetricMetadata.Builder extends Object
Builder for MetricMetadata.
  • Method Details

    • name

      @StableApi public MetricMetadata.Builder name(String name)
      Required. The base metric name (without type suffix like _total).
    • expositionBaseName

      public MetricMetadata.Builder expositionBaseName(String expositionBaseName)
      Internal use only. Not part of the stable API.

      Allows internal callers to preserve a separate exposition base name.

    • originalName

      public MetricMetadata.Builder originalName(String originalName)
      Internal use only. Not part of the stable API.

      Allows internal callers to preserve the raw name before normalization.

    • help

      @StableApi public MetricMetadata.Builder help(@Nullable String help)
      Optional. Human-readable description of the metric.
    • unit

      @StableApi public MetricMetadata.Builder unit(@Nullable Unit unit)
      Optional. The unit of measurement. Appended to the name if not already present.
    • counterSuffix

      @StableApi public MetricMetadata.Builder counterSuffix(boolean counterSuffix)
      Optional. When true, the writer appends _total to the exposition name. Use this for counter metrics, especially UTF-8 names where the writer cannot infer it from the snapshot type alone.
    • build

      @StableApi public MetricMetadata build()
      Builds the MetricMetadata. Throws if name was not set.