[Exporter.Prometheus] Fix stack overflow

Merged
MA
4mo ago
+218-39

Changes

Fix stack overflow caused by recursion if EnterCollect() failed and then completed synchronously introduced by refactoring in #7371.

Merge requirement checklist

  • CONTRIBUTING guidelines followed (license requirements, nullable enabled, static analysis, etc.)
  • Unit tests added/updated
  • Appropriate CHANGELOG.md files updated for non-trivial changes
  • Changes in public API reviewed (if applicable)