'In the context o f prometheus instrumentation, should I use all prometheus labels when updating a metrics value

I have a prometheus metric with labels declared like

errors_total = prometheus_client.Counter("errors_total", "Total errors", ["source", "code])
errors_total.labels("source"="initialization", code="100")
errors_total.labels("source"="shutingdown", code="200")  

When I increment the metric in the place in the monitored code where the error happens, can I just use it as:

errors_total.labels(source="initialization").inc()

or

errors_total.labels(code="200").inc()

My question is can I just use one label when incrementing the metric?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source