Currently I'm writing a program that can estimate the costs of an Azure application. For this I have the idea to intercept all the methods that will do (indirectly) a call to the (Azure) server. And for each of the methods decide to which aspect of the costs it belongs to (for example (storage-transactions, servicebus-transactions, token-requests etc.))
One of the difficulties of this is that I also want to intercept a method call when the class/method is mocked, so the program can also be used in (unit-)tests during the development of an Azure application.
So I was wondering if there is a way to 'subscribe' on a method of a class. And when this method is called an event will be fired. Or are there other (better) solutions to intercept storage-transactions, servicebus-transactions, token-request etc. also for classes that send for example a storage-transactions but are mocked?
Thanks in advance
EDIT 1: Does anyone know if there are some (helper) classes/libraries or references that contains/knows all the classes/methods that influences the Costs of an Azure application?
EDIT 2 Is this a good approach to achieve above problem? Or are there alternatives?