stats: flush stats based on application lifecycle#717
Merged
Conversation
Adds functionality built on top of the upstream Envoy changes in envoyproxy/envoy#10097 which will allow the bridging layers to manually flush stats based on lifecycle changes in the mobile application. Follow-up PRs will call these functions from Java/Objective-C. Part of #573. Signed-off-by: Michael Rebello <me@michaelrebello.com>
Signed-off-by: Michael Rebello <me@michaelrebello.com>
Signed-off-by: Michael Rebello <me@michaelrebello.com>
683f34b to
2999f6e
Compare
Adding the following stats to the allow-list based on [these Envoy docs](https://www.envoyproxy.io/docs/envoy/latest/configuration/upstream/cluster_manager/cluster_stats): - `upstream_rq_retry` - `upstream_rq_retry_overflow` - `upstream_rq_retry_success` Also re-alphabetized the stats list. Signed-off-by: Michael Rebello <me@michaelrebello.com>
Adds functionality built on top of the upstream Envoy changes in envoyproxy/envoy#10097 which will allow the bridging layers to manually flush stats based on lifecycle changes in the mobile application. Note: Stats must be flushed from the main Envoy thread, as validated by the following assertion failure that occurs when attempting to flush from another thread: ``` [2020-02-27 14:38:43.181][4716580][critical][assert] [external/envoy/source/common/thread_local/thread_local_impl.cc:190] assert failure: std::this_thread::get_id() == main_thread_id_. ``` Follow-up PRs will call these functions from Java/Objective-C. Part of #573. Signed-off-by: Michael Rebello <me@michaelrebello.com>
Signed-off-by: Michael Rebello <me@michaelrebello.com>
2999f6e to
50f7aaf
Compare
Signed-off-by: Michael Rebello <me@michaelrebello.com>
Signed-off-by: Michael Rebello <me@michaelrebello.com>
Signed-off-by: Michael Rebello <me@michaelrebello.com>
buildbreaker
reviewed
Mar 3, 2020
library/java/src/io/envoyproxy/envoymobile/engine/AndroidEngineImpl.java
Show resolved
Hide resolved
buildbreaker
reviewed
Mar 3, 2020
library/java/src/io/envoyproxy/envoymobile/engine/AndroidEngineImpl.java
Show resolved
Hide resolved
buildbreaker
reviewed
Mar 3, 2020
library/java/src/io/envoyproxy/envoymobile/engine/AndroidEngineImpl.java
Show resolved
Hide resolved
buildbreaker
reviewed
Mar 3, 2020
library/java/src/io/envoyproxy/envoymobile/engine/AndroidEngineImpl.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Michael Rebello <me@michaelrebello.com> Signed-off-by: Alan Chiu <achiu@lyft.com>
0996414 to
995c206
Compare
buildbreaker
previously approved these changes
Mar 3, 2020
buildbreaker
approved these changes
Mar 3, 2020
This was referenced Mar 13, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This change adds the ability to automatically flush stats based on application lifecycle changes (in addition to the scheduled flushing interval).
Enabling this flushing system is done automatically when the iOS/Android clients are instantiated.
On iOS, this is done by observing
NSNotificationCenter.Android requires an
Applicationcontext to use for registering lifecycle callbacks. To accommodate this, theApplicationis now passed in to the Android builder instead of theContext.Right now this new stats flushing behavior is enabled by default. In the future, we would like to investigate making it optional using the builder pattern. For example:
AndroidEnvoyClientBuilder(baseContext) .addAppLifecycleHandling(getApplication()) .build()#721 will track this work.
As part of this PR, I also updated some documentation to better reflect the differences between Android/Java interfaces and those present on iOS.
Testing
Risk Level
Low, this is an additive change.
Issues
Resolves #573
Signed-off-by: Michael Rebello me@michaelrebello.com