decide: flatten the JSON log layer, or keep documenting the | json trap #27
Labels
No labels
blocked
waiting-on-julian
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
jlxq0/caldav-mcp#27
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Documented at
2089525as a trap to work around. This issue exists so the alternative, removing the trap, is a decision with a state rather than a thing nobody raised.The trap
src/main.rs:289builds the JSON layer asfmt::layer().json(). That nests every event field underfields, so a line reads:Loki's
| jsonparser flattens that tofields_user_hash. A query filtering onuser_hashtherefore returns empty against lines that demonstrably exist, and an identity that never authenticated returns the identical empty set. The parser being unable to see the field and the field never having been written are the same result.That cost an hour tonight and was recovered only by switching to
regexp:The one-line alternative
tracing_subscriber::fmt::format::Json::flatten_eventexists (0.3.23,src/fmt/format/json.rs:100) and is reachable as:Fields move to the top level,
| jsonworks directly, and the trap stops existing rather than being documented.The trade, which is why this is an issue and not a commit
Against flattening:
fields_*breaks silently on the next deploy. Silently is the operative word: a broken query returns empty, which is the exact failure this change is meant to remove, arriving once during the cutover.messagemoves to the top level and can collide with any field namedmessage. Nothing here emits one, but nothing stops it either.For flattening:
regexpthey have to know to reach for, and the documentation only helps someone who already suspects the zero is wrong.What would make this safe
Not the change on its own. Whoever takes it should find every
fields_*query in Loki, Grafana and the alert rules first, since the failure mode of missing one is an empty result rather than an error. That is an operations sweep rather than a code edit, which is the actual size of this and the reason it is not a one-line PR.Related:
#20's observability work, which added theuser_hashthis was first noticed on.