eliot
eliot copied to clipboard
Bring back addFailureFields or a way to log information only when an action (or sub-action) fails
Eliot used to have addFailureFields
- https://github.com/ClusterHQ/eliot/blob/0.3.0/eliot/_action.py#L274
But it was removed for want of a use case. Here's one:
In Flocker we'd like to be able to log the entire configuration and cluster state seen by a Flocker agent when it is converging on that configuration from that cluster state.
But in large clusters the with large state and configuration structures, it becomes prohibitively expensive to serialise and log those structures.
- https://github.com/ClusterHQ/flocker/pull/2729
We'd also like to be able to log the entire response body of every request serviced by our control services, but that too is prohibitively expensive so we removed the logging:
- https://github.com/ClusterHQ/flocker/pull/2729
But without that information it'll be difficult to understand the situation that led to the exception.
So perhaps we can add that configuration and state in the parent Action:
- https://github.com/ClusterHQ/flocker/blob/c2e49b5cf95b31708751076a5989c211d0b776ce/flocker/node/_loop.py#L524
And have that logged only if, for example, the CreateFileSystem action fails:
- https://github.com/ClusterHQ/flocker/blob/c2e49b5cf95b31708751076a5989c211d0b776ce/flocker/node/agents/blockdevice.py#L533
The API might look something like the addDetail
feature in testtools.
- https://testtools.readthedocs.org/en/latest/for-test-authors.html#details
I've started just using a raw Message.log(...)
to add more details to a started action. I'm not sure if this is awesome or not but it at least gets the information capture in the right place.