-
Notifications
You must be signed in to change notification settings - Fork 202
use regular thread for to expose errors in appengine #1955
use regular thread for to expose errors in appengine #1955
Conversation
@@ -39,7 +39,9 @@ | |||
|
|||
private IntervalMetricReader(Worker worker) { | |||
this.worker = worker; | |||
this.workerThread = new DaemonThreadFactory().newThread(worker); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this change? It looks to me nothing changed for JDK 8+. The previous approach only restricts JDK 7.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previous approach created thread using MoreExecutors.platformThreadFactory() for all JDK. We just need regular thread for logging to work.
try { | ||
thread.setName(threadPrefix + threadIdGen.getAndIncrement()); | ||
thread.setDaemon(true); | ||
} catch (SecurityException e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it safe to remove this try-catch clause?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The constraints on thread renaming is from AppEngine threads. Since we are not using them it should be okay. But let me put it back as it doesn't hurt to have try-catch clause.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Appveyor failure is not related to this change: FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all files for configuration ':opencensus-contrib-log-correlation-log4j2:compileClasspath'.
> Could not resolve org.apache.logging.log4j:log4j-core:2.11.1.
Required by:
project :opencensus-contrib-log-correlation-log4j2
> Could not resolve org.apache.logging.log4j:log4j-core:2.11.1.
> Could not get resource 'https://repo.maven.apache.org/maven2/org/apache/logging/log4j/log4j-core/2.11.1/log4j-core-2.11.1.pom'.
> Could not GET 'https://repo.maven.apache.org/maven2/org/apache/logging/log4j/log4j-core/2.11.1/log4j-core-2.11.1.pom'.
> Connect to repo.maven.apache.org:443 [repo.maven.apache.org/151.101.184.215] failed: Connection timed out: connect |
This fixes #1954 for OC+GAE (jdk8/jdk11).
Solution
Use normal thread for GAE with jdk8/jdk11. Logs generated by any thread not associated with any request are stored in memory. These logs are flushed when a next request is served.
Caveat
If no request is served or if the request is serve long after the message is logged then the message may not appear in the appengine logs. In most practical scenario, the QPS will be sufficient enough to flush these pending log messages.