riemann/riemann

Unexpected behavior regarding events with missing fields specified in by macro

Closed this issue · 2 comments

The by macro uses by-fn under the hood. by-fn maintains a map from each combination of fields it has encountered in any of the events it has seen to distinct copies of the child streams passed to by. Events with a given combination of fields get sent to the appropriate child stream by doing a lookup in the dictionary. If the key does not exist, a new key is created for that combination of fields and a reference to another copy of the child streams is saved as the corresponding value. An undefined behavior, as far as the documentation of the function is concerned, is what happens when an event lacks any of the fields. The most sane behavior to me would be to ignore any such event, however, what actually happens is that a key/val paired is instantiated under a key such as [nil "spaghetti"].

Proposed solutions:

  1. This behavior is documented and users concerned are encouraged to implement the most obvious workaround: (where #(contains? % fields) (by fields children)).
  2. The behavior is changed to ignore events missing the specified fields and this behavior is documented.
  3. An option to by/by-fn is added to implement 2, or a new, separate macro which enforces the behavior in 2 is implemented.

In my opinion, the current behavior is correct, so i am voting for 1.

Ditto on 1 - would welcome a docs update.