Repository navigation
context: log severe warning if ancestry chain > 1000 - #3459
Conversation
codefromthecrypt
left a comment
There was a problem hiding this comment.
seems ok though sometimes people do create tons of trace spans (which relate to context forks). Also not sure the combinatory effect (ex scoping metrics then later scoping deadlin, tracing etc). This sort of practice would get to a good default number which 200 likely is
cc @bogdandrutu
|
would be nice to show the max ancestry in a "typical" grpc app, configured with metrics and tracing, just for comparison's sake |
| // The threshold and interval are arbitrarily chosen. | ||
| // VisibleForTesting | ||
| static final int CONTEXT_DEPTH_WARN_THRESH = 200; | ||
| private static final int CONTEXT_WARN_INTERVAL = 20; |
There was a problem hiding this comment.
Let's not do the interval warning at this point. Since we've not been warning before, let's start slow.
| // Long chains of contexts are suspicious and usually indicate a misuse of Context. | ||
| // The threshold and interval are arbitrarily chosen. | ||
| // VisibleForTesting | ||
| static final int CONTEXT_DEPTH_WARN_THRESH = 200; |
There was a problem hiding this comment.
@adriancole, I'm okay with bumping this higher. If you're concerned about 200, do you have a suggestion on where to start, like 1000 or 5000?
The main concern at the moment is infinite mutation, because finding those in real life applications can be hard.
|
1000 feels safer starting point thanks!
|
If a context has an unreasonable number of ancestors, then
chances are this is an application error. Log the stack trace to
notify the user and aid in debugging.