Skip to content

refactor(metrics): extract error.type resolver to a shared utility#32

Merged
jstojiljkovic merged 1 commit into
tracewayapp:masterfrom
srekcud:refactor/error-type-resolver
May 10, 2026
Merged

refactor(metrics): extract error.type resolver to a shared utility#32
jstojiljkovic merged 1 commit into
tracewayapp:masterfrom
srekcud:refactor/error-type-resolver

Conversation

@srekcud

@srekcud srekcud commented May 4, 2026

Copy link
Copy Markdown
Contributor

Pure cleanup. Removes the inline resolveErrorType() helper that #27 introduced in
OpenTelemetryMetricsMiddleware and replaces it with a shared
Util\ErrorTypeResolver::resolve().

Why

The same FQCN-with-anonymous-class fallback shows up identically in the parallel metrics
PRs:

This PR is mostly useful once at least one of those lands: it consolidates the
duplication into one place so the next contributor doesn't have to choose which copy to
call. If none of the metrics-* PRs are accepted, this refactor is harmless but loses most of
its motivation.

Behaviour

No semantic change. The resolver is byte-equivalent to the inline implementation: returns
$exception::class, falls back to get_parent_class($exception) ?: \Throwable::class when
the FQCN contains @anonymous.

Tests

  • Util\ErrorTypeResolverTest covers root-namespace, namespaced,
    anonymous-extends-RuntimeException and anonymous-extends-Exception cases.
  • The existing messenger middleware tests continue to assert the same error.type values,
    untouched.

Conflict handling

Whichever metrics-* PR merges first lands Util\ErrorTypeResolver on master. After that,
this PR rebases and the file-introduction commit drops automatically (Git detects identical
content). If this PR merges first instead, the metrics-* PRs do the same on rebase.

Replaces the inline anonymous-class fallback in OpenTelemetryMetricsMiddleware
with a reusable Util\ErrorTypeResolver, deduplicating logic that the parallel
metrics-http-client / metrics-http-server / metrics-doctrine PRs introduce
under the same name.
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@jstojiljkovic
jstojiljkovic merged commit 81ed7b1 into tracewayapp:master May 10, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants