This validation is called only once per Metric—i.e., when it is declared.  The Java client has the feature that when declaring a metric, all label names need to be declared up-front.  This provides further in-process validations that all code paths have provided the required label names with associated values once and only once and with each of the required labels.

This example will help you: https://github.com/prometheus/client_java/blob/master/client/src/main/java/io/prometheus/client/metrics/Gauge.java#L60.