private static Set<String> getUniquePathsToRegister(Collection<? extends WorkUnitState> states) {
   Set<String> paths = Sets.newHashSet();
   for (State state : states) {
     if (state.contains(ConfigurationKeys.PUBLISHER_DIRS)) {
       paths.addAll(state.getPropAsList(ConfigurationKeys.PUBLISHER_DIRS));
     }
   }
   return paths;
 }
 public String getDefaultEventBusId() {
   State destinationCfg = getDestination().getProperties();
   String eventBusIdKey =
       ForkOperatorUtils.getPathForBranch(
           destinationCfg, FULL_EVENTBUSID_KEY, getBranches(), getBranch());
   if (destinationCfg.contains(eventBusIdKey)) {
     return destinationCfg.getProp(eventBusIdKey);
   } else {
     return WriterUtils.getWriterOutputDir(destinationCfg, getBranches(), getBranch())
         .toString();
   }
 }
  /**
   * Creates {@link 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 gobblin.metrics.MetricContext} registry (the parent context must be registered).
   *
   * <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>class: the specific class of the object that generated this instance of Instrumented
   * </ul>
   */
  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();
  }