code: public MetricContext getMetricContext(State state, Class<?> klazz, List<Tag<?>> tags) {
      int randomId = new Random().nextInt(Integer.MAX_VALUE);
  
      List<Tag<?>> generatedTags = Lists.newArrayList();
  
      if (!klazz.isAnonymousClass()) {
        generatedTags.add(new Tag<>("class", klazz.getCanonicalName()));
      }
  
      Optional<GobblinMetrics> gobblinMetrics = state.contains(ConfigurationKeys.METRIC_CONTEXT_NAME_KEY)
          ? GobblinMetricsRegistry.getInstance().get(state.getProp(ConfigurationKeys.METRIC_CONTEXT_NAME_KEY))
          : Optional.<GobblinMetrics> absent();
  
      MetricContext.Builder builder = gobblinMetrics.isPresent()
          ? gobblinMetrics.get().getMetricContext().childBuilder(klazz.getCanonicalName() + "." + randomId)
          : MetricContext.builder(klazz.getCanonicalName() + "." + randomId);
      return builder.addTags(generatedTags).addTags(tags).build();
    }
docs: <p>
  Creates {@link org.apache.gobblin.metrics.MetricContext}. Tries to read the name of the parent context
  from key "metrics.context.name" at state, and tries to get the parent context by name from
  the {@link org.apache.gobblin.metrics.MetricContext} registry (the parent context must be registered).
  </p>
  
  <p>
  Automatically adds two tags to the inner context:
  <ul>
  <li> component: attempts to determine which component type within gobblin-api generated this instance. </li>
  <li> class: the specific class of the object that generated this instance of Instrumented </li>
  </ul>
  </p>