I've been looking at examples in the Java and C++ client libs, and it doesn't mirror my understanding of label rules:
I thought:
- each metric could have zero or more named labels
- each label must have a pre-determined set of allowed values
- when setting a metric value, all label dimensions must be specified from these allowed values
But the examples don't work that way:
Counter calculationsCounter = Counter.build()
.name("my_library_calculations_total").help("Total calls.")
.labelNames("key").register();
...
void processThatCalculates(String key) {
calculationsCounter.labels(key).inc();
// Run calculations.
}
}
In this example, I don't see where "key" allowed values are enumerated. I also don't see how labels(key) knows which label it is referring to. I might have multiple labels.
I wish I could find a non-trivial example which shows what the output scrape would look like. Can anyone help?