fix: Remove duplicate OTEL observability setup in imc-dispatcher#8885
Conversation
The imc-dispatcher was calling otel.SetupObservabilityOrDie in its NewController function, but sharedmain.MainWithContext already sets up observability before calling NewController. This caused Go runtime metrics to be registered twice, resulting in the error: "collected metric 'go_memory_allocations_total' was collected before with the same name and label values" This caused the metrics endpoint (/metrics) to fail with an error, preventing Prometheus from scraping metrics. Changes: - Use otel.GetMeterProvider() and otel.GetTracerProvider() to get the global providers already set up by sharedmain - Remove duplicate pprof server creation (sharedmain handles it) - Remove pprof config watch (sharedmain handles it) - Remove provider shutdown calls (sharedmain handles cleanup) - Clean up unused imports
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8885 +/- ##
==========================================
- Coverage 50.64% 50.63% -0.01%
==========================================
Files 409 409
Lines 21658 21650 -8
==========================================
- Hits 10968 10962 -6
+ Misses 9834 9833 -1
+ Partials 856 855 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Cali0707, creydr The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/cherry-pick release-1.20 |
|
@Cali0707: once the present PR merges, I will cherry-pick it on top of DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
/cherry-pick release-1.21 |
|
@Cali0707: once the present PR merges, I will cherry-pick it on top of DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
@Cali0707: new pull request created: #8886 DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
@Cali0707: new pull request created: #8887 DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
…tive#8885) The imc-dispatcher was calling otel.SetupObservabilityOrDie in its NewController function, but sharedmain.MainWithContext already sets up observability before calling NewController. This caused Go runtime metrics to be registered twice, resulting in the error: "collected metric 'go_memory_allocations_total' was collected before with the same name and label values" This caused the metrics endpoint (/metrics) to fail with an error, preventing Prometheus from scraping metrics. Changes: - Use otel.GetMeterProvider() and otel.GetTracerProvider() to get the global providers already set up by sharedmain - Remove duplicate pprof server creation (sharedmain handles it) - Remove pprof config watch (sharedmain handles it) - Remove provider shutdown calls (sharedmain handles cleanup) - Clean up unused imports
…tive#8885) (#1801) The imc-dispatcher was calling otel.SetupObservabilityOrDie in its NewController function, but sharedmain.MainWithContext already sets up observability before calling NewController. This caused Go runtime metrics to be registered twice, resulting in the error: "collected metric 'go_memory_allocations_total' was collected before with the same name and label values" This caused the metrics endpoint (/metrics) to fail with an error, preventing Prometheus from scraping metrics. Changes: - Use otel.GetMeterProvider() and otel.GetTracerProvider() to get the global providers already set up by sharedmain - Remove duplicate pprof server creation (sharedmain handles it) - Remove pprof config watch (sharedmain handles it) - Remove provider shutdown calls (sharedmain handles cleanup) - Clean up unused imports
The imc-dispatcher was calling
otel.SetupObservabilityOrDiein itsNewControllerfunction, butsharedmain.MainWithContextalready sets up observability before callingNewController. This caused Go runtime metrics to be registered twice, resulting in the error:This caused the metrics endpoint (/metrics) to fail with an error, preventing Prometheus from scraping metrics. This PR addresses it
otel.GetMeterProvider()andotel.GetTracerProvider()to get the global providers already set up by sharedmain