feat(collector/receiver): support extra fields in structured JSON function logs#2251
Open
tomsobpl wants to merge 5 commits intoopen-telemetry:mainfrom
Open
feat(collector/receiver): support extra fields in structured JSON function logs#2251tomsobpl wants to merge 5 commits intoopen-telemetry:mainfrom
tomsobpl wants to merge 5 commits intoopen-telemetry:mainfrom
Conversation
…port-in-json-logging
…port-in-json-logging
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.
Summary
When a Lambda function emits structured JSON logs (i.e., a log line with a
messagefield), thetelemetryapireceivernow extracts any additional fields from the JSON object and maps them to log record attributes.Previously, only the
messagefield was captured from structured JSON log records. Any extra fields present in the JSON object (e.g.,userId,orderId, custom business data) were silently discarded.{ "message": "order processed", "orderId": "123", "userId": "abc", "level": "info" }Before:
→ Log record body: "order processed", no extra attributes.
After:
→ Log record body: "order processed", attributes: orderId = "123", userId = "abc".
Changes
receiver.go: After setting the log record body from the message field, iterate over all remaining keys in the parsed JSON record and add them as log record attributes. The well-known fields (level, message, requestId, timestamp) are skipped since they are already handled separately.receiver_test.go: Extended test coverage for JSON logs containing extra fields, covering nested values, arrays, and numeric types.Notes: