Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

recordException should unwrap SomeException #162

Open
michaelpj opened this issue Nov 21, 2024 · 2 comments
Open

recordException should unwrap SomeException #162

michaelpj opened this issue Nov 21, 2024 · 2 comments

Comments

@michaelpj
Copy link
Collaborator

If you call recordException on an exception caught with catchAny or similar, you will get an uhelpful exception.type, namely SomeException itself. What you really want is the type of the inner exception. We can get this, we just have to unwrap it.

We do this ouselves in the codebase: https://github.com/iand675/hs-opentelemetry/blob/main/api/src/OpenTelemetry/Trace/Core.hs#L395

I think we should just teach recordException to do this itself. Perhaps just call cast to see if it's a SomeException, and if so unwrap it?

@iand675
Copy link
Owner

iand675 commented Nov 21, 2024

In general, I'd like to add support for the TracerProvider to register exception enrichment functions that can do unwrapping, add attributes to the exception events, etc. In particular, we use annotated-exceptions, which is yet another one of these wrappers.

I do agree with teaching registerException what to do there, but ideally it would be somewhat extensible instead of hardcoding to the lowest common denominator in the extensible exception hierarchy.

@michaelpj
Copy link
Collaborator Author

That sounds like it's going to require quite a bit more design work. I think at least handling SomeException would be useful for users in the short term. I don't tremendously mind - if we want to do it properly I'll just write the wrapper in my work codebase!

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

No branches or pull requests

2 participants