iohk-monitoring-framework
iohk-monitoring-framework copied to clipboard
Making it easier to write `ToObject` instances
Is your feature request related to a problem? Please describe.
While I was integrating iohk-monitoring into the Plutus Application Backend I found myself writing the same field names as string literals in several different places. For example, there are a number of log messages that include a value of Tx (transaction). Whenever that value was needed in the log object I would write ("tx", toJSON tx). So the label "tx" was repeated in several places. It should be possible to use the type (in this case Tx) to infer the name of the field. This would make the structured log output more consistent.
Describe the solution you'd like Something like this: https://github.com/input-output-hk/plutus/commit/c434c00c581121d90a16658e6c56c9914cb8fafa
Describe alternatives you've considered
Implementing ToObject without it resulted in the problems described above. I'm not aware of any alternatives (if a better way of doing this already exists in iohk-monitoring please let me know)
Additional context I am happy to turn this into a PR if you want.
interesting. yes, something like this could simplify it. let's come back to it when we have more time.