class MetricsEnvironment {

  public static @Nullable MetricsContainer setCurrentContainer(
      @Nullable MetricsContainer container) {
    MetricsContainer previous = CONTAINER_FOR_THREAD.get();
    if (container == null) {
      CONTAINER_FOR_THREAD.remove();
    } else {
      CONTAINER_FOR_THREAD.set(container);
    }
    return previous;
  }

}