MetricsEnvironment { public static @Nullable MetricsContainer getCurrentContainer() { MetricsContainer container = CONTAINER_FOR_THREAD.get(); if (container == null && REPORTED_MISSING_CONTAINER.compareAndSet(false, true)) { if (isMetricsSupported()) { LOG.error( "Unable to update metrics on the current thread. " + "Most likely caused by using metrics outside the managed work-execution thread."); } else { LOG.warn("Reporting metrics are not supported in the current execution environment."); } } return container; }  static @Nullable MetricsContainer setCurrentContainer(
      @Nullable MetricsContainer container); static void setMetricsSupported(boolean supported); static boolean isMetricsSupported(); static Closeable scopedMetricsContainer(MetricsContainer container); static @Nullable MetricsContainer getCurrentContainer();  }
@Test public void testBehavesWithoutMetricsContainer() { assertNull(MetricsEnvironment.getCurrentContainer()); }