Skip to content

fix: Remove duplicate OTEL observability setup in imc-dispatcher#8885

Merged
knative-prow[bot] merged 1 commit intoknative:mainfrom
creydr:fix-imc-dispatcher-metric-registration
Feb 24, 2026
Merged

fix: Remove duplicate OTEL observability setup in imc-dispatcher#8885
knative-prow[bot] merged 1 commit intoknative:mainfrom
creydr:fix-imc-dispatcher-metric-registration

Conversation

@creydr
Copy link
Member

@creydr creydr commented Feb 24, 2026

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. This PR addresses it

  • 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)

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
@creydr creydr requested a review from Cali0707 February 24, 2026 12:45
@knative-prow knative-prow bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Feb 24, 2026
@knative-prow knative-prow bot requested a review from aslom February 24, 2026 12:46
@knative-prow knative-prow bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 24, 2026
@codecov
Copy link

codecov bot commented Feb 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 50.63%. Comparing base (8f777f5) to head (1b0235d).
⚠️ Report is 7 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@Cali0707 Cali0707 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
/approve

Thanks for catching this @creydr

@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Feb 24, 2026
@knative-prow
Copy link

knative-prow bot commented Feb 24, 2026

[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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@Cali0707
Copy link
Member

/cherry-pick release-1.20

@knative-prow-robot
Copy link
Contributor

@Cali0707: once the present PR merges, I will cherry-pick it on top of release-1.20 in a new PR and assign it to you.

Details

In response to this:

/cherry-pick release-1.20

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
Copy link
Member

/cherry-pick release-1.21

@knative-prow-robot
Copy link
Contributor

@Cali0707: once the present PR merges, I will cherry-pick it on top of release-1.21 in a new PR and assign it to you.

Details

In response to this:

/cherry-pick release-1.21

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.

@knative-prow knative-prow bot merged commit ac3281f into knative:main Feb 24, 2026
37 of 40 checks passed
@knative-prow-robot
Copy link
Contributor

@Cali0707: new pull request created: #8886

Details

In response to this:

/cherry-pick release-1.20

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.

@knative-prow-robot
Copy link
Contributor

@Cali0707: new pull request created: #8887

Details

In response to this:

/cherry-pick release-1.21

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.

creydr added a commit to creydr/knative-eventing that referenced this pull request Feb 24, 2026
…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
openshift-merge-bot bot pushed a commit to openshift-knative/eventing that referenced this pull request Feb 25, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants