Refactor Reporter to not know about implementations
WHAT is this pull request doing?
The Reporter class is an odd bird and only used for debugging purposes. It knows too much about classes (even accessing instance variables) which prevents refactoring.
This PR refactors Reporter to not know anything about any implementation; instead "reportable" entities must include the Reportable module and specify their reportable objects with the reportables macro.
The macro may look scary at a first glance, but it will generate a __report method that will report all specified "reportables" to the Reporter instance. This makes the Reporter only responsible for the output, while each entity is responsible for what to report.
HOW can this pull request be tested?
Run lavinmq and send USR1 to observe output.
What's the benefit? "Prevents refactoring"? You have to change your reportables just the same way as you have to change the Reporter today. With this PR a lot of debugging code is scattered around in individual classes.
IMO changing the internals of a class shouldn't affect other classes. I encountered this when I was abstracting client/channel/consumer.
This makes sense. Could be used for general instrumentation and not only debugging?
The current approach doesn't work very well if you start to abstract things, like making Client an abstract class to introduce amqp clients and mqtt client, since these different client classes may have different internals.
Sure but question is if this is useful at all?
On Wed, 7 Aug 2024, 09:48 Jon Börjesson, @.***> wrote:
The current approach doesn't work very well if you start to abstract things, like making Client an abstract class to introduce amqp clients and mqtt client, since these different client classes may have different internals.
— Reply to this email directly, view it on GitHub https://github.com/cloudamqp/lavinmq/pull/676#issuecomment-2272838906, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABL6TSH6MNMA4D44HJE4QDZQHGNLAVCNFSM6AAAAABHVRNE6WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENZSHAZTQOJQGY . You are receiving this because your review was requested.Message ID: @.***>