001package io.prometheus.metrics.model.snapshots; 002 003/** 004 * Thrown when a collector tries to create a {@link MetricSnapshot} where multiple data points have 005 * the same labels (same label names and label values). 006 */ 007public class DuplicateLabelsException extends IllegalArgumentException { 008 009 private static final long serialVersionUID = 0L; 010 011 private final MetricMetadata metadata; 012 private final Labels labels; 013 014 public DuplicateLabelsException(MetricMetadata metadata, Labels labels) { 015 super("Duplicate labels for metric \"" + metadata.getName() + "\": " + labels); 016 this.metadata = metadata; 017 this.labels = labels; 018 } 019 020 public MetricMetadata getMetadata() { 021 return metadata; 022 } 023 024 public Labels getLabels() { 025 return labels; 026 } 027}