onInitialize method

  1. @override
bool onInitialize()
override

Callback when this executor is initialized. Returns true if succesfully initialized, false othervise.

Note that this is a non-async method and should hence be 'light-weight' and not block execution for a long duration.

Implementation

@override
bool onInitialize() {
  for (Measure measure in task.measures) {
    // create a new probe for each measure - this ensures that we can have
    // multiple measures of the same type, each using its own probe instance
    Probe? probe = SamplingPackageRegistry().create(measure.type);
    if (probe != null) {
      executors.add(probe);
      group.add(probe.data);
      probe.initialize(measure, deployment!);
    } else {
      warning(
          'A probe for measure type ${measure.type} could not be created. '
          'This may be because this probe is not available on this operating system. '
          'Or it may be because the sampling package containing this probe has not '
          'been registered in the SamplingPackageRegistry.');
    }
  }
  return true;
}