Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow customization for context of LogEntry instances created by LoggingHandler #1329

Closed
gregw opened this issue Oct 21, 2016 · 7 comments
Closed
Assignees
Labels
api: logging Issues related to the Cloud Logging API.

Comments

@gregw
Copy link

gregw commented Oct 21, 2016

The 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?

@mziccard mziccard added the api: logging Issues related to the Cloud Logging API. label Oct 21, 2016
@mziccard
Copy link
Contributor

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
Copy link
Author

gregw commented 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
Copy link
Contributor

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 added a commit to jetty-project/google-cloud-java that referenced this issue Nov 10, 2016
Allow extended classes to access the LogEntry building, so that
additional information may be encoded in each log entry (eg traceid).

Use addLabel rather than setLabels as it avoids the creation and copy
of a HashMap per log entry.

Signed-off-by: Greg Wilkins <gregw@webtide.com>
@gregw gregw mentioned this issue Nov 10, 2016
@gregw
Copy link
Author

gregw commented 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.

gregw added a commit to jetty-project/google-cloud-java that referenced this issue Nov 17, 2016
removed extra protected
improved extension signature
gregw added a commit to jetty-project/google-cloud-java that referenced this issue Nov 17, 2016
Removed buildEntryFor
gregw added a commit to jetty-project/google-cloud-java that referenced this issue Nov 17, 2016
Cleanedup imports
garrettjonesgoogle pushed a commit that referenced this issue Nov 18, 2016
* Issue #1329

Allow extended classes to access the LogEntry building, so that
additional information may be encoded in each log entry (eg traceid).

Use addLabel rather than setLabels as it avoids the creation and copy
of a HashMap per log entry.

Signed-off-by: Greg Wilkins <gregw@webtide.com>
@garrettjonesgoogle
Copy link
Member

Resolved in #1385

@gregw
Copy link
Author

gregw commented Nov 22, 2016

Is there an ETA on a 6.1 release with this change?

@garrettjonesgoogle
Copy link
Member

I'm aiming to do a release by EOD tomorrow - I have a couple more things to include.

github-actions bot pushed a commit that referenced this issue Sep 15, 2022
…ator_java versions (#1329)

- [ ] Regenerate this pull request now.

PiperOrigin-RevId: 472750037

Source-Link: googleapis/googleapis@88f2ea3

Source-Link: https://github.com/googleapis/googleapis-gen/commit/230a5588306aae18fe8f2a57f14d4039ad72c901
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMjMwYTU1ODgzMDZhYWUxOGZlOGYyYTU3ZjE0ZDQwMzlhZDcyYzkwMSJ9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: logging Issues related to the Cloud Logging API.
Projects
None yet
Development

No branches or pull requests

3 participants