On Wed, 26 Sep 2018 at 23:17, Douglas Reid <
dougla...@gmail.com> wrote:
>
> pl := promLabels(val.Dimensions)
> vec.With(pl).Observe(amt)
> ...
>
> func promLabels(l map[string]interface{}) prometheus.Labels {...}
>
> And, `prometheus.Labels` is defined in the codebase as follows:
>
> type Labels map[string]string
>
> So, the metric takes a *map* of label values when observations are being recorded.
>
> Shouldn't this make duplication of labels impossible?
>
> Is there some other way in which labels could be duplicated? Has anyone ever seen such behavior before?
If you only use the direct instrumentation parts of the library, it
will not be possible to ever create inconsistent label dimensions. The
Prometheus registry will reject inconsistent metrics at registration
time.
However, there are various ways of creating inconsistent metrics, e.g.
by writing a custom Collector implementation (which Istio might do in
its codebase, but I didn't check the code) or by merging various
registries (see
https://godoc.org/github.com/prometheus/client_golang/prometheus#Gatherers).
However (2nd order... ;), recently we decided to allow inconsistent
label dimensions in those cases. see
https://github.com/prometheus/client_golang/commit/c06fb788be8a05442219295095ee0e51523802f0
. I would recommend to pin the vendoring to the current master (which
is planned to be released as v0.9.0 as soon as my day job leaves me
with a few minutes of spare time.)
--
Björn Rabenstein, Engineer
http://soundcloud.com/brabenstein
SoundCloud Ltd. | Rheinsberger Str. 76/77, 10115 Berlin, Germany
Managing Director: Alexander Ljung | Incorporated in England & Wales
with Company No. 6343600 | Local Branch Office | AG Charlottenburg |
HRB 110657B