Make Telemetry API log record type generic #1098
Open
+65
−24
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.
📬 Issue #, if available: #977
✍️ Description of changes:
This adds a generic type parameter to
LambdaTelemetryRecordfor logs to support structured JSON logs. I initially tried to implement theRawValuenewtype based solution suggested in #977, but it turns out you can't useRawValuewithin#[serde(flatten)].This is a breaking change given it introduces a new generic parameter, but IMO it's better than introducing a whole new set of duplicate types, especially given supporting managed instances may already require breakage soon.
Unlike suggested in #977, this doesn't lock users into either supporting text or JSON logs at compile time, since they can just use an untagged enum:
I also opted against adding a new struct for JSON logs since they don't have a fixed schema, some extension authors might want to use
serde_json::Value, some might want a more specialized type.🔏 By submitting this pull request
cargo +nightly fmt.cargo clippy --fix.