/** * Builder a new {@link MetricContext}. * * <p> * See {@link Taggable#metricNamePrefix(boolean)} for the semantic of {@code includeTagKeys}. * </p> * * <p> * Note this builder may change the name of the built {@link MetricContext} if the parent context already has a child with * that name. If this is unacceptable, use {@link #buildStrict} instead. * </p> * * @return the newly built {@link MetricContext} */ public MetricContext build() { try { return buildStrict(); } catch (NameConflictException nce) { String uuid = UUID.randomUUID().toString(); LOG.warn("MetricContext with specified name already exists, appending UUID to the given name: " + uuid); this.name = this.name + "_" + uuid; try { return buildStrict(); } catch (NameConflictException nce2) { throw Throwables.propagate(nce2); } } }