Github user srdo commented on the issue:
https://github.com/apache/storm/pull/2783
@zd-project You are right that if someone wants to add metrics to a
component, they will have to figure out how to get the registry injected. I
can't say up front how hard that will be, except to note that it wasn't too bad
to make these changes.
For the specific case of the Container, I put the metrics in the
ContainerMemoryTracker next to the fields they're gauges for. This is primarily
because Container gets created a lot of times, and I didn't want to call the
`gauge` method every time the constructor is invoked. In this case I chose to
move the gauges to a different class with a different lifecycle from Container,
but since the `gauge` method uses `getOrAdd` there probably wouldn't be
anything wrong with registering the metrics every time a Container is created
instead.
If I were adding new metrics to Container, I would either make a metrics
container object like SlotMetrics that is common to all Containers and pass
that in, or pass in the registry and just invoke the registration every time
the constructor is invoked. Unless there's a big performance penalty to using
`getOrAdd`, I would think that there wouldn't be much difference.
---