-
Notifications
You must be signed in to change notification settings - Fork 107
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
Inspect Elixir exception module name in record_exception
#804
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #804 +/- ##
==========================================
+ Coverage 17.32% 20.18% +2.86%
==========================================
Files 24 26 +2
Lines 710 738 +28
==========================================
+ Hits 123 149 +26
- Misses 587 589 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
report_exception
record_exception
Heh, I missed that there were already some higher-level tests at the top level of the git repo until I saw it failing in CI. 🤦 |
Does this risk changing what you'd see for an Erlang-provided exception when using the Elixir macros compared to what happened prior to this fix? |
It's technically a change regardless since it's intentionally formatting the exception differently, but I'd argue it's fixing a bug compared to what would be expected on the Elixir side. But the only change in this PR is when you call the Elixir version of the API ( The Erlang version of the API does something different in terms of formatting, and I'd argue that maybe we should figure out how to converge them, given that libraries could end up calling one or the other depending on how they integrate, and IMO it's really more about how you want to format exceptions / stacktraces, perhaps based on a configuration option, even. Maybe if your app is mostly in Erlang, but has some Elixir code, you'd prefer to see your Elixir exceptions still formatted as Erlang, for example. |
Yeah to be clear my concern here was whether dropping |
Don't know if you saw this @GregMefford but I have an implementation in Erlang in the cowboy instrumentation. |
Nice, I did see that my Cowboy error spans had a different error formatting in prod, but hadn't dug into how it's working yet. That'll be a good starting point for converging on a standard format. |
The main change in this PR is to change the way we report the
exception.type
attribute whenOpenTelemetry.Span.record_exception
is called. Currently, it is usingto_string
, which results in the struct name having anElixir.
prefix on it, which is technically correct, but not what an Elixir developer would expect, since Elixir hides that most of the time. By usinginspect
instead, we get that functionality here as well.The bulk of the PR, though, is adding some testing infrastructure that allows me to be able to assert that we're doing the right thing there, since this change is in the
opentelemetry_api
package, which does not depend on theopentelemetry
SDK, where all the span-processing happens, leaving us with onlyotel_tracer_noop
, which just ignores the data we want to assert on. I tried to make it so that it'll be compatible with Erlang tests as well in the future, but I'm not really familiar with how to organize the code there. In Elixir, there's a convention to put this kind of module that's only used in tests in thetest/support
directory and configure the compiler paths (which I've also done in this PR even though I didn't end up using it because it doesn't "just work" for Erlang files) when we're running in test mode so that it can find them. That way, they're not included in the distributed Hex package because they're not in the main library code. I wasn't sure how to do the same thing for Erlang.