I'm working on a cloud app with three tiers
- Web - Controller
- DB - Repository
- BusinessLogic - Handler
Normally it's cut and dry where to put monitoring logic but in this case, when a use issues a Delete Rest operation, I need to track it before we call the Repository to delete the record (since I need to know what the state was before delete to issue metrics on it). I'm not certain where the best place for metrics work to live.
I could put it in the controller, just before I issue the delete operation to the repository. But this means that now my previously web only tier now would have to retrieve the record in order to issue a metric.
Doing it in the repository layer also feels odd, as my repository layer today doesn't do anything other than handle CRUD operations.
Where would you suggest putting it? We don't have an internal pattern yet for this project so I can kind of see the case for all of them.