Skip to content

feat(collector/receiver): support extra fields in structured JSON function logs#2251

Open
tomsobpl wants to merge 5 commits intoopen-telemetry:mainfrom
tomsobpl:feat/extra-fields-support-in-json-logging
Open

feat(collector/receiver): support extra fields in structured JSON function logs#2251
tomsobpl wants to merge 5 commits intoopen-telemetry:mainfrom
tomsobpl:feat/extra-fields-support-in-json-logging

Conversation

@tomsobpl
Copy link
Copy Markdown

Summary

When a Lambda function emits structured JSON logs (i.e., a log line with a message field), the telemetryapireceiver now extracts any additional fields from the JSON object and maps them to log record attributes.

Previously, only the message field 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:

  • The attribute key names are taken as-is from the JSON log (no prefix added), keeping the mapping straightforward.
  • Values that cannot be converted via pcommon.Value.FromRaw emit a warning and are skipped rather than failing the entire record.

@tomsobpl tomsobpl requested a review from a team as a code owner April 14, 2026 06:24
@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla bot commented Apr 14, 2026

CLA Signed
The committers listed above are authorized under a signed CLA.

@wpessers wpessers added bug Something isn't working go Pull requests that update Go code labels Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working go Pull requests that update Go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants