[Fix] Render datalayer.Model and ScoredModel in structured logs - #281
davidbreitgand wants to merge 2 commits into
Conversation
…red logs Signed-off-by: David Breitgand <davidbreitgand@users.noreply.github.com>
|
/cc @nirrozenbaum |
nirrozenbaum
left a comment
There was a problem hiding this comment.
thanks @davidbreitgand,
what are your thoughts about implementing String() instead of MarshalJSON?
Thanks @nirrozenbaum. Actually, I considered It goes like The problem also shows up when MarshalJSON also preserves the structured shape ({"name":"..."}, {"name":"...","score":...}), which stays greppable and "jq-able" in log tooling. String() blob inside a JSON field would be actually clumsy for that. Does this make sense to you? Having said that, I'm happy to add |
Signed-off-by: David Breitgand <davidbreitgand@users.noreply.github.com>
|
@nirrozenbaum can you please take another look? |
|
This PR is marked as stale after 21d of inactivity. After an additional 14d of inactivity (7d to become rotten, then 7d more), it will be closed. To prevent this PR from being closed, add a comment or remove the |
/kind bug
What this PR does / why we need it:
Fixes rendering Model and ScoredModel in structured logs.
datalayer.ModelandScoredModelserialized to{}and{"Score":X}with the name dropped in DEBUG log lines because theconcrete types have only unexported / embedded-interface fields.
This PR adds
MarshalJSONon*modelprojecting name, and on*ScoredModelprojectingname + score so the promoted embedded method does not silently drop
scores.
Attributes are intentionally not projected because AttributeMap is itself an
interface backed by an unexported
sync.Mapand would recurse into thesame
{}problem.Fixes #280