-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
Proposed improvement on OnNextValue stacktrace rendition #2468
Comments
I'm okay with exploring improvements to this (and anything else to improve debugging). The marker interface could work, but it is intrusive to the public API and the types being used by libraries. It seems the plugin model would be the most powerful and would work on any types without forcing them to conform to the RxJava marker interface, which is important if the types are 3rd party and can't be changed, or they live somewhere that should not have dependency on RxJava. One drawback of how the plugin registration works right now is that it assumes and enforces only 1 registration at startup, so if 2 libraries both tried, one would fail. Perhaps for this use case we want to allow many plugin registrations? It could be that @ReactiveX/rxjava-committers Do you have preferences on how this is pursued? |
I don't want another public <T> Subscription registerErrorValueRenderer(
Class<T> clazz, Func1<? super T, String> tostring);
public <T> boolean hasErrorValueRenderer(Class<T> clazz); But what should happen if the same class was registered multiple times? I'd throw an |
I was thinking about doing it the plugin way on the existing plugin but that breaks a committed interface doesn't it? So thinking about doing a separate plugin, and one that supports chaining (composite pattern?) :) |
Chaining has some issues: in worst case it would take N steps to reach a value renderer. You'd need some cooperation mechanisms to see who is interested in giving an answer and not ask anyone else (such as Swing's KeyEvent.consume() or something). |
Ah right it's abstract!
The renderer internally checks for relevant types and return a string value if it can manage the object, The stack rendering code would then check for primitive types (as it does now), then call Example renderer implementation:
what do you think? |
I suggest you post a PR so we have a more complete picture how things can work. |
sure, I think I may be able to find time tomorrow (CET) 👍 |
submitted a PR, had some problems during CI that seem unrelated to my work, any clue?
edit: nevermind the issue has disappeared |
Looks completed in #2632 |
Hi,
I was looking at a stacktrace with
OnNextValue
in it and saw that the last emitted item, causing the Exception, was indeed logged in the stacktrace as just aclassName
, as per #1401. (see also the rendering code).But in some contexts, like for the Couchbase SDK or some other framework using Rx, I think it is acceptable to say that we can identify more types that it makes sense to stringify. We can check that these types have a sufficiently performant, safe and slim
toString()
implementation to be fully rendered byOnNextValue
.Offering a mean to let RxJava know about such types would allow the String rendering to be activated in a cross-cutting manner, without reworking every single stream produced by the framework/library to induce additional logging behavior.
I see two broad ways of achieving such a thing:
toString()
)toString()
,toShortString()
?, to be used byOnNextValue
for rendering)RxJavaErrorHandler
?)What do you think about this idea? If we can agree on a way of doing this, I'd be happy to contribute it!
The text was updated successfully, but these errors were encountered: