[Fix] Render datalayer.Model and ScoredModel in structured logs - #281
[Fix] Render datalayer.Model and ScoredModel in structured logs#281davidbreitgand 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? |
/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