feat: ingest structured logs using stdout in LoggingHandler#812
Merged
minherz merged 12 commits intominherz/structured_loggingfrom Jan 1, 2022
Merged
feat: ingest structured logs using stdout in LoggingHandler#812minherz merged 12 commits intominherz/structured_loggingfrom
minherz merged 12 commits intominherz/structured_loggingfrom
Conversation
resolve warnings change type for trace an spanId to be strings create more realistic and visual test data: - timestamp with more recent date - json payload with various data types
refactor setAutoPopulateMetadata() to avoid setting flag to null
implement populateMetadata() API. change write() to use the new API. refactor SourceLocation.fromCurrentContext() to use a list of exclusion prefixes instead of depth level as parameter. change relevant unit tests to support the refactored changes.
modify publish() method to print structured logging if configured instead of calling to Logging.write(). populate created LogEntry instance with metadata separately instead of adding WriteOption.AUTO_POPULATE_METADATA. refactor LoggingHandler to remove getLogging() method. refactor unit tests to reflect the change in LoggingHandler.publish() implementation.
refactor LoggingHandlerTest.
fixes testFromCurrentContextWithVeryLargeLevel by excluding classes from OS JDK
losalex
reviewed
Dec 30, 2021
Contributor
losalex
left a comment
There was a problem hiding this comment.
Thanks for your effort - good job! I left some comments, PTAL and let me know if those makes sense
google-cloud-logging/src/main/java/com/google/cloud/logging/LogEntry.java
Show resolved
Hide resolved
google-cloud-logging/src/main/java/com/google/cloud/logging/LogEntry.java
Show resolved
Hide resolved
google-cloud-logging/src/main/java/com/google/cloud/logging/LogEntry.java
Show resolved
Hide resolved
google-cloud-logging/src/main/java/com/google/cloud/logging/LogEntry.java
Show resolved
Hide resolved
google-cloud-logging/src/main/java/com/google/cloud/logging/LogEntry.java
Show resolved
Hide resolved
google-cloud-logging/src/main/java/com/google/cloud/logging/LogEntry.java
Outdated
Show resolved
Hide resolved
google-cloud-logging/src/main/java/com/google/cloud/logging/LoggingHandler.java
Outdated
Show resolved
Hide resolved
google-cloud-logging/src/main/java/com/google/cloud/logging/LoggingImpl.java
Show resolved
Hide resolved
google-cloud-logging/src/main/java/com/google/cloud/logging/LoggingImpl.java
Outdated
Show resolved
Hide resolved
google-cloud-logging/src/main/java/com/google/cloud/logging/LoggingImpl.java
Outdated
Show resolved
Hide resolved
losalex
approved these changes
Jan 1, 2022
Contributor
losalex
left a comment
There was a problem hiding this comment.
Overall looks good - just fix whatever we agreed in comments. Also left some clarification regarding incomplete comment, hope it make sense
google-cloud-logging/src/main/java/com/google/cloud/logging/LogEntry.java
Show resolved
Hide resolved
| } | ||
|
|
||
| /** | ||
| * Adds a collection of Json fields that {@code value} parameter is serialized to to the current |
Contributor
There was a problem hiding this comment.
Yes, I think name change like appendDictionary will be fine then
| } else if (payload.getType() == Type.JSON) { | ||
| Payload.JsonPayload jsonPayload = (Payload.JsonPayload) payload; | ||
| formatter.appendJson(jsonPayload.getDataAsMap(), true); | ||
| } else if (payload.getType() == Type.PROTO) { |
4 tasks
minherz
added a commit
that referenced
this pull request
Jan 4, 2022
#812) Implements populateMetadata() API. Changes Logging.write() API to populate the provided list of log entries using the new API. Refactors SourceLocation.fromCurrentContext() to use a list of exclusion instead of the call stack depth level as parameter. Adds configuration `populateToStdout` to `LoggingConfig`. Use the new configuration within `LoggingHandler` to print to STDOUT instead of ingesting the log by calling Logging.write(). Refactor LoggingImpl, LoggingHandler and unit tests.
minherz
added a commit
that referenced
this pull request
Jan 5, 2022
#812) Implements populateMetadata() API. Changes Logging.write() API to populate the provided list of log entries using the new API. Refactors SourceLocation.fromCurrentContext() to use a list of exclusion instead of the call stack depth level as parameter. Adds configuration `populateToStdout` to `LoggingConfig`. Use the new configuration within `LoggingHandler` to print to STDOUT instead of ingesting the log by calling Logging.write(). Refactor LoggingImpl, LoggingHandler and unit tests.
minherz
added a commit
that referenced
this pull request
Jan 7, 2022
…ogs redirection to stdout in JUL handler (#808) Aggregates the following work: - #821 - #812 - #807 - #803 - #798 Fixes #689, #691, #799 and #800 * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
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.
Add configuration (edited:)
redirectoToStdouttouseStructuredLoggingLoggingHandlerclass to support an option to print logs to STDOUT formatted as a one line Json and following the structured logging guidelines.Implement Jsonification of the
LogEntryobject following the structured logging format.Move metadata population to a standalone API to be used by
LoggingHandlerexplicitly.