code: public static MetricsContext getContext(String refName, String contextName) {
      MetricsContext metricsContext;
      try {
        metricsContext =
          ContextFactory.getFactory().getContext(refName, contextName);
        if (!metricsContext.isMonitoring()) {
          metricsContext.startMonitoring();
        }
      } catch (Exception ex) {
        LOG.error("Unable to create metrics context " + contextName, ex);
        metricsContext = ContextFactory.getNullContext(contextName);
      }
      return metricsContext;
    }
docs: Utility method to return the named context.
  If the desired context cannot be created for any reason, the exception
  is logged, and a null context is returned.