uber / rxdogtag Goto Github PK
View Code? Open in Web Editor NEWAutomatic tagging of RxJava 2+ originating subscribe points for onError() investigation.
Home Page: https://uber.github.io/RxDogTag
License: Apache License 2.0
Automatic tagging of RxJava 2+ originating subscribe points for onError() investigation.
Home Page: https://uber.github.io/RxDogTag
License: Apache License 2.0
These should result in no decorating observers being added
In certain cases like OAuth you do need to set onError handler, so some helper function would be nice.
For now, I created helper function handleOnError that I attach to every onError thus mimicking RxDogTag.
RxJava throws these, we should add a test to capture behavior changes
Stacktrace:
2019-09-18 08:46:44.148 13557-13557/com.example.moshisample E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.moshisample, PID: 13557
io.reactivex.exceptions.OnErrorNotImplementedException: Non-null value 'person' was null at $.person
Caused by: com.squareup.moshi.JsonDataException: Non-null value 'person' was null at $.person
at com.example.moshisample.MainActivity.button1Clicked(MainActivity.kt:54)
at [[ ↑↑ Inferred subscribe point ↑↑ ]].(:0)
at [[ ↓↓ Original trace ↓↓ ]].(:0)
at com.example.moshisample.PersonJsonAdapter.fromJson(PersonJsonAdapter.kt:25)
at com.example.moshisample.PersonJsonAdapter.fromJson(PersonJsonAdapter.kt:12)
at com.squareup.moshi.JsonAdapter$2.fromJson(JsonAdapter.java:137)
at retrofit2.converter.moshi.MoshiResponseBodyConverter.convert(MoshiResponseBodyConverter.java:45)
at retrofit2.converter.moshi.MoshiResponseBodyConverter.convert(MoshiResponseBodyConverter.java:27)
at retrofit2.OkHttpCall.parseResponse(OkHttpCall.java:225)
at retrofit2.OkHttpCall.execute(OkHttpCall.java:188)
at retrofit2.adapter.rxjava2.CallExecuteObservable.subscribeActual(CallExecuteObservable.java:45)
at io.reactivex.Observable.subscribe(Observable.java:12267)
at io.reactivex.internal.operators.observable.ObservableSubscribeOn$SubscribeTask.run(ObservableSubscribeOn.java:96)
at io.reactivex.Scheduler$DisposeTask.run(Scheduler.java:578)
at io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:66)
at io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:57)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
Android app build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 29
defaultConfig {
applicationId "com.example.moshisample"
minSdkVersion 23
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
targetCompatibility = "8"
sourceCompatibility = "8"
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.core:core-ktx:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.squareup.retrofit2:retrofit:2.6.1'
implementation 'com.squareup.retrofit2:converter-moshi:2.6.1'
kapt 'com.squareup.moshi:moshi-kotlin-codegen:1.8.0'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.6.1'
implementation "io.reactivex.rxjava2:rxjava:2.2.8"
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
implementation("com.uber.rxdogtag:rxdogtag:0.2.0")
}
MainActivity.kt
import android.os.Bundle
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.squareup.moshi.JsonClass
import com.uber.rxdogtag.RxDogTag
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import kotlinx.android.synthetic.main.activity_main.*
import okhttp3.OkHttpClient
import retrofit2.Response
import retrofit2.Retrofit
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
import retrofit2.converter.moshi.MoshiConverterFactory
import retrofit2.http.GET
class MainActivity : AppCompatActivity() {
lateinit var client: OkHttpClient
lateinit var retrofit: Retrofit
lateinit var service: MyService
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
RxDogTag.install()
client = OkHttpClient.Builder()
.build()
retrofit = Retrofit.Builder()
.baseUrl("http://www.mocky.io/v2/")
.client(client)
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.addConverterFactory(MoshiConverterFactory.create())
.build()
service = retrofit.create(MyService::class.java)
button1.setOnClickListener { button1Clicked() }
}
fun button1Clicked() {
val call = service.getPersonExplicitNull()
call.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({ t: Response<Person>? ->
Toast.makeText(this@MainActivity, "Success", Toast.LENGTH_LONG).show()
})
}
}
interface MyService {
//JSON:
// {
// "person": null
// }
@GET("5d4da01d3300004b4433793d?mocky-delay=1000ms")
fun getPersonExplicitNull(): Observable<Response<Person>>
}
@JsonClass(generateAdapter = true)
data class Person(
val person: String = ""
)
https://github.com/uber/RxDogTag/runs/578529637
@ShaishavGandhi did Uber rotate login credentials?
There is no information about it in README.
I looked at android-benchmark, but it was unclear to me.
For example, it mentions guardedDelegateEnabled, which I do not see mentioned in README.
Can do this before #28 so that we can move our documentation under the website.
And link it from the README
Wiki page should have raw results as well as instructions on how to run them and context around how to read them (i.e. 800% diff but then look at it in ms)
Right now we've hardcoded AutoDispose support directly in. We should make an API that allows for provisioning of separate handlers to extract observers.
Let's start with something simple: accept a list of handlers, first one to consume it wins, otherwise built-in implementation takes over.
We can look later at doing something more Retrofit-style with delegating/forwarding if need be.
Ran into this with R8 usage in our app where RDT's helper methods are entirely inlined, which confuses it when it walks up the stacktrace.
We should package better rules for this. Namely, something like -dontshrink class rxdogtag2.** { *; }
Based on prior discussion with Bugsnag folks as well as our internal crash reporter, it may be better to have a synthetic chained exception that crash reporters natively understand and can unwrap.
https://docs.oracle.com/javase/tutorial/essential/exceptions/chained.html
We can also consider making this behavior configurable.
Requires #17 to be done to add some benchmarking for comparison. If it's expensive, consider putting behind a config
Things like the guardedDelegateCall
are great candidates for inlining. Worth benchmarking too once #17 is done
Anecdotal evidence from uber internal is ok, but it would be nicer to have a benchmark project we could point. Maybe we could reuse RxJava's jmh tests, or the classic reactive streams shakespeare/scrabble benchmark?
Other considerations:
When trying to compile I get this error:
"Default interface methods are only supported starting with Android N (--min-api 24): io.reactivex.CompletableObserver com.uber.rxdogtag.ObserverHandler.handle(io.reactivex.Completable, io.reactivex.CompletableObserver)"
Is this expected?
My setup:
minSdkVersion 21
targetSdkVersion 29
multiDexEnabled true
This case should just be passed directly to the parent handler
Someone was asking about this, would be good to have an example of this in the wiki and maybe even a test
Should result in StackTraceElement("Unknown", "unknown", "unknown", 0)
Checklist
rxdogtag2
rxdogtag2
https://uber.github.io/RxDogTag/1.x/rxdogtag/com.uber.rxdogtag/-rx-dog-tag/-builder/
Updated Dokka should have the fix
Makes updating that doc easier
This way, if someone supplies their own LambdaConsumerIntrospection
, they could control this behavior if they want (such as if theirs just logs an error)
We recently encountered a weird issue after upgrading to the Android Gradle Plugin 7.0.2. When running our release build and therefore Proguard, the application crashes right at the start of the application with an ExceptionInInitializerError
when RxDogTag.install()
is called.
Stacktrace:
java.lang.ExceptionInInitializerError
at com.uber.rxdogtag.RxDogTag$Builder.install(:483)
at com.uber.rxdogtag.RxDogTag.install(:103)
at com.mikef.rxdogtagissue.DogTagApplication.onCreate(:12)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1192)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6712)
at android.app.ActivityThread.access$1300(ActivityThread.java:237)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1913)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Package.getName()' on a null object reference
at com.uber.rxdogtag.RxDogTag$Configuration.<clinit>
After investigating this issue a little bit I found the root cause in our Proguard configuration:
-repackageclasses ''
When this is set the aforementioned issue occurs. When going back to AGP 4.2.2 there is no issue, same thing when we remove this flag. I can't tell exactly why exactly this happens and whether it is the fault of RxDogTag or the Android Gradle Plugin.
For we now we removed this Proguard flag in order to solve the issue.
I've also created a super simple sample repository in order to reproduce this issue.
Library version:
1.0.1
After some more discussions with folks offline, let's add a couple options for configuring how traces are set up. These are to help improve grouping for crash processors that might otherwise index on the annotations in the stacktrace
Library version:
Repro steps or stacktrace:
Hi, dear devloper,
I wonder how could I make a jar file of rxdogtag. Since our workplace is offline. All dependence is jar file, including rxjava2. Is there a way to package this to jar file? I notice there are some maven dependence, like these:
id 'ru.vyarus.animalsniffer'
id 'me.champeau.gradle.jmh'
id 'org.jetbrains.dokka'
What role do they play. Is it nessary package all of them to jar file?
RxDogTag has had some time to incubate and we'd like to propose going 1.0. There aren't any major breaking API changes that we anticipate so we'd be planning to go to 1.0 soon.
If you have any concerns or things you want to get added before 1.0, now is the time!
If things go fine, we plan on doing 1.0 that targets RxJava 2 and a quick 2.0 which targets RxJava 3.
Observed missing in code coverage
Library version: 2.0.1
Repro steps or stacktrace:
Crash 1:
Caused by java.lang.NumberFormatException: For input string: ""
at rxdogtag2.-$$Lambda$RxDogTag$YP26HIb1nhHqbV4QlRgnyBuwHqU.apply(-.java:6)
at [[ ↑↑ Inferred subscribe point ↑↑ ]].([[ ↑↑ Inferred subscribe point ↑↑ ]].java)
at [[ Originating callback: onNext ]].([[ Originating callback: onNext ]].java)
at [[ ↓↓ Original trace ↓↓ ]].([[ ↓↓ Original trace ↓↓ ]].java)
at java.lang.Integer.parseInt(Integer.java:627)
at java.lang.Integer.parseInt(Integer.java:650)
at .....
Crash 2:
Caused by java.lang.IllegalArgumentException: No enum constant x.y.z.ECONOMY
at rxdogtag2.-$$Lambda$RxDogTag$YP26HIb1nhHqbV4QlRgnyBuwHqU.apply(-.java:6)
at [[ ↑↑ Inferred subscribe point ↑↑ ]].([[ ↑↑ Inferred subscribe point ↑↑ ]].java)
at [[ Originating callback: onNext ]].([[ Originating callback: onNext ]].java)
at [[ ↓↓ Original trace ↓↓ ]].([[ ↓↓ Original trace ↓↓ ]].java)
at java.lang.Enum.valueOf(Enum.java:257)
both have the common line
at rxdogtag2.-$$Lambda$RxDogTag$YP26HIb1nhHqbV4QlRgnyBuwHqU.apply(-.java:6)
which is causing all crashes to merge under a single report
Library version: 0.2.0
Repro steps or stacktrace:
Getting an ANR, and while I can't really pinpoint that RxDogTag is the issue, it does show up in the stacktrace in my bugsnag logs. Feel free to close if it's not an issue with RxDogTag.
ANR: Application did not respond for at least 5000 ms
at android.os.BinderProxy.transactNative(Binder.java:-2)
at android.os.BinderProxy.transact(Binder.java:1140)
at android.app.IActivityManager$Stub$Proxy.handleApplicationCrash(IActivityManager.java:3560)
at com.android.internal.os.RuntimeInit$KillApplicationHandler.uncaughtException(RuntimeInit.java:143)
at com.bugsnag.android.ExceptionHandler.uncaughtException(ExceptionHandler.java:91)
at com.mixpanel.android.mpmetrics.ExceptionHandler.uncaughtException(ExceptionHandler.java:53)
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1068)
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1063)
at io.reactivex.plugins.RxJavaPlugins.uncaught(RxJavaPlugins.java:429)
at io.reactivex.plugins.RxJavaPlugins.onError(RxJavaPlugins.java:383)
at com.uber.rxdogtag.RxDogTag.reportError(RxDogTag.java:309)
at com.uber.rxdogtag.DogTagObserver.onError(DogTagObserver.java:61)
at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.checkTerminated(ObservableObserveOn.java:281)
at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.drainNormal(ObservableObserveOn.java:172)
at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.run(ObservableObserveOn.java:255)
at io.reactivex.android.schedulers.HandlerScheduler$ScheduledRunnable.run(HandlerScheduler.java:124)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:6981)
at java.lang.reflect.Method.invoke(Method.java:-2)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1445)
Right now, RxDogTag is implemented via throwing an exception and capturing the stack frame at that point. While we haven't seen any measurable performance impact at a macro level, it's certainly not free either. This issue exists to capture possible alternative implementation ideas.
Recognizes certain subscribe()
signatures and re-weaves them to have the hardcoded subscribe tag present with a custom tagging observer. Cost is just a string then.
Recognizes certain subscribe()
signatures and re-weaves them to have the hardcoded subscribe tag present with a custom tagging observer. Cost is just a string then.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.