Access instances of sub projects of class InputModule in a global sensor

(Dietmar Menges) #1


In a global sensor in the execute method I retrieve from the SensorContext the root module (instance of InputModule).
If I use the injected ProjectDefinition I can also access the ProjectDefinition of the sub-modules (projectDefinition.getSubProjects()).

Is it possible to access/create instances of InputModule for all sub-modules?
This way I could add metrics/issues also for all sub-modules in only 1 sensor execution.

Something like this:

public void describe(final SensorDescriptor descriptor)

public void execute(final SensorContext context)
    final InputModule inputModule = context.module();
    //Process root module

    //Get sub modules from injected project definition
    for (final ProjectDefinition nextProjectDefinition : projectDefinition.getSubProjects())
        final InputModule nextInputModule = nextProjectDefinition.module();//This method does not exist - only to explain my specific question
        //TODO process sub modules


Kind regards.


(Julien Henry) #2

Hi Dietmar,

I don’t think it is possible, and even if it was, I don’t think this is a good idea. Global Sensors are intended to be used when the concept of module is meaningless. Note that we are starting to talk about dropping entirely the module concept, so in the end all Sensors will have to be converted to global Sensors.
So having a global Sensor, but still trying to deal with submodules, is kind of weird.

If you have measures to save on modules, please use a normal Sensor for that.



(Dietmar Menges) #3

Thank you very much for your answer.