@Test
  public void testInstrumentation() {
    try (IScope scope = new ExecutionScope()) {
      Instrumentation.setPolicyAsyncInstrumentation(false); // execute actions synchronously

      final E2<DummyLogger, DummyRemoteInstrumentationLogger> loggers = setupLoggers("fewi");
      final DummyLogger localLogger = loggers.getE0();
      final DummyRemoteInstrumentationLogger remoteLogger = loggers.getE1();

      if (true) {
        Instrumentation.publishExecutionSummary();
        checkInstrumentationListener(remoteLogger, 1, 0, 0, 0);
        checkLogger(localLogger, 0, 0, 0, 1, 0, 0);
        checkLogger(remoteLogger, 0, 0, 0, 0, 0, 0);
      }

      if (true) {
        final String name = "timelyOperation";
        Instrumentation.execute(
            name,
            200,
            () -> {
              HcUtil.pause(10);
            },
            name);

        Instrumentation.publishExecutionSummary();
        checkInstrumentationListener(remoteLogger, 2, 0, 0, 0);
        checkLogger(localLogger, 0, 0, 0, 2, 0, 0);
        checkLogger(remoteLogger, 0, 0, 0, 0, 0, 0);
      }

      if (true) {
        final String name = "slowOperation";
        Instrumentation.execute(
            name,
            10,
            () -> {
              HcUtil.pause(100);
            },
            name);

        Instrumentation.publishExecutionSummary();
        checkInstrumentationListener(remoteLogger, 3, 1, 1, 0);
        checkLogger(localLogger, 0, 0, 2, 3, 0, 0);
        checkLogger(remoteLogger, 0, 0, 0, 0, 0, 0);
      }

      if (true) {
        try {
          final String name = "failedTimelyOperation";
          Instrumentation.execute(
              name,
              200,
              () -> {
                HcUtil.pause(10);
                ThreadContext.assertFaultNotNull(null);
              },
              name);
        } catch (final Exception e) {
        }

        Instrumentation.publishExecutionSummary();
        checkInstrumentationListener(remoteLogger, 4, 1, 1, 1);
        checkLogger(localLogger, 2, 0, 2, 4, 0, 0);
        checkLogger(remoteLogger, 1, 0, 0, 0, 0, 0);
      }

      if (true) {
        try {
          final String name = "failedTimelyOperationException";
          Instrumentation.execute(
              name,
              200,
              () -> {
                HcUtil.pause(10);
                throw new RuntimeException("Ooops");
              },
              name);
        } catch (final Exception e) {
        }

        Instrumentation.publishExecutionSummary();
        checkInstrumentationListener(remoteLogger, 5, 1, 1, 2);
        checkLogger(localLogger, 4, 0, 2, 5, 0, 0);
        checkLogger(remoteLogger, 2, 0, 0, 0, 0, 0);
      }
    }
  }