GeezerVison is showing github.com — Allow customization for context of LogEntry instances created by LoggingHandler · Issue #1329 · googleapis/google-cloud-java
Allow customization for context of LogEntry instances created by LoggingHandler #1329DescriptionThe https://github.com/GoogleCloudPlatform/jetty-runtime needs to be able to generate stackdriver log messages with the label traceid set the the value obtained from the x-cloud-trace-context HTTP header.
However, the LoggingHandler#getLogEntry method does not allow for easy extension to support traceid as the method is private rather than protected, thus to change behaviour more methods on the class need to be replaced to customize the LogEntry.
If this method could be made protected, then it would be easy to extend the handler to use a threadlocal label map to set additional labels (eg traceid).
Better yet, such a threadlocal context could be implemented as a standard feature of the LogHandler? Activitymziccard commented on Oct 21, 2016
If this method could be made protected, then it would be easy to extend the handler to use a threadlocal label map to set additional labels (eg traceid).
This sounds good to me.
Better yet, such a threadlocal context could be implemented as a standard feature of the LogHandler?
I am not sure this is a feature that a lot of users would use/need. gregw commented on Oct 21, 2016 @mziccard Do you want a PR for the change to protected?
With regards to a threadlocal mechanism, I agree it is not entirely widely applicable, but neither does it have a zero use-case. Other logging mechanisms (Eg logback MDC) do provide this feature and indeed the stackdrive log API has the map of labels as an extensible mechanism for such logging that is essentially hidden by the JUL handler.
If there is zero interest from you guys for this feature, I'll drop it. But if there is a hint of interest I'm happy to create a PR to show how it may be done with minimal cost to users that do not use it. mziccard commented on Oct 24, 2016
If there is zero interest from you guys for this feature, I'll drop it. But if there is a hint of interest I'm happy to create a PR to show how it may be done with minimal cost to users that do not use it.
@gregw I'd be happy to have such a PR. If we can make its cost close-to-zero it'd be nice to have.
@mziccard Do you want a PR for the change to protected?
Should we put this on hold while we evaluate the threadlocal mechanism? gregw commented on Nov 10, 2016 @mziccard I considered a few ways to do the ThreadLocal, and I'm not sure there is a one size fits all approach. The PR #1385 is a minimal approach to at least allow me to progress on https://github.com/GoogleCloudPlatform/jetty-runtime without needing to copy over the entire LoggingHandler.
The down side of using inheritance rather than pluggability is that the one external impl cannot work for both AsyncLoggingHandler and LoggingHandler, but at least an external impl is possible. garrettjonesgoogle commented on Nov 18, 2016 gregw commented on Nov 22, 2016 Is there an ETA on a 6.1 release with this change? garrettjonesgoogle commented on Nov 22, 2016 I'm aiming to do a release by EOD tomorrow - I have a couple more things to include.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|