prometheus: Unable to export data after restarting the exporter #4032
Labels
area:metrics
Part of OpenTelemetry Metrics
pkg:exporter:prometheus
Related to the Prometheus exporter package
Milestone
I'm implementing an application that uses otel to export metrics to Prometheus. The user should be able to "stop" and "start" the metrics collection. Unfortunately, I'm running into an issue with the Prometheus exporter, when the metrics are started a second time they stop working and the
collected metric xxxx was collected before with the same name and label values
error is reported. I checked and it seems I shutdown all components in the right way. The following is a minimal reproducer:I run the program in one terminal:
In another terminal, I query the metrics endpoint:
Now, I hit ctrl+c on the first terminal to force this to restart the metrics collection
Now the metrics don't work anymore:
and the fist terminal prints
I tried the stdout exporter instead of Prometheus and it seems to work fine.
After asking on Slack, @Aneurysm9 suggested to use an explicit register:
With this modification the program works as expected. However, it's not clear if the behavior described above is the correct one.
ref https://cloud-native.slack.com/archives/C01NPAXACKT/p1682013380206509
The text was updated successfully, but these errors were encountered: