private AbstractMetricGroup<?> addGroup(String name, ChildType childType) { synchronized (this) { if (!closed) { // adding a group with the same name as a metric creates problems in many reporters/dashboards // we warn here, rather than failing, because metrics are tools that should not fail the // program when used incorrectly if (metrics.containsKey(name)) { LOG.warn("Name collision: Adding a metric subgroup with the same name as an existing metric: '" + name + "'. Metric might not get properly reported. " + Arrays.toString(scopeComponents)); } AbstractMetricGroup newGroup = createChildGroup(name, childType); AbstractMetricGroup prior = groups.put(name, newGroup); if (prior == null) { // no prior group with that name return newGroup; } else { // had a prior group with that name, add the prior group back groups.put(name, prior); return prior; } } else { // return a non-registered group that is immediately closed already GenericMetricGroup closedGroup = new GenericMetricGroup(registry, this, name); closedGroup.close(); return closedGroup; } } }
private AbstractMetricGroup<?> addGroup(String name, ChildType childType) { synchronized (this) { if (!closed) { // adding a group with the same name as a metric creates problems in many reporters/dashboards // we warn here, rather than failing, because metrics are tools that should not fail the // program when used incorrectly if (metrics.containsKey(name)) { LOG.warn("Name collision: Adding a metric subgroup with the same name as an existing metric: '" + name + "'. Metric might not get properly reported. " + Arrays.toString(scopeComponents)); } AbstractMetricGroup newGroup = createChildGroup(name, childType); AbstractMetricGroup prior = groups.put(name, newGroup); if (prior == null) { // no prior group with that name return newGroup; } else { // had a prior group with that name, add the prior group back groups.put(name, prior); return prior; } } else { // return a non-registered group that is immediately closed already GenericMetricGroup closedGroup = new GenericMetricGroup(registry, this, name); closedGroup.close(); return closedGroup; } } }
closedGroup.close(); return closedGroup;
private AbstractMetricGroup<?> addGroup(String name, ChildType childType) { synchronized (this) { if (!closed) { // adding a group with the same name as a metric creates problems in many reporters/dashboards // we warn here, rather than failing, because metrics are tools that should not fail the // program when used incorrectly if (metrics.containsKey(name)) { LOG.warn("Name collision: Adding a metric subgroup with the same name as an existing metric: '" + name + "'. Metric might not get properly reported. " + Arrays.toString(scopeComponents)); } AbstractMetricGroup newGroup = createChildGroup(name, childType); AbstractMetricGroup prior = groups.put(name, newGroup); if (prior == null) { // no prior group with that name return newGroup; } else { // had a prior group with that name, add the prior group back groups.put(name, prior); return prior; } } else { // return a non-registered group that is immediately closed already GenericMetricGroup closedGroup = new GenericMetricGroup(registry, this, name); closedGroup.close(); return closedGroup; } } }
private AbstractMetricGroup<?> addGroup(String name, ChildType childType) { synchronized (this) { if (!closed) { // adding a group with the same name as a metric creates problems in many reporters/dashboards // we warn here, rather than failing, because metrics are tools that should not fail the // program when used incorrectly if (metrics.containsKey(name)) { LOG.warn("Name collision: Adding a metric subgroup with the same name as an existing metric: '" + name + "'. Metric might not get properly reported. " + Arrays.toString(scopeComponents)); } AbstractMetricGroup newGroup = createChildGroup(name, childType); AbstractMetricGroup prior = groups.put(name, newGroup); if (prior == null) { // no prior group with that name return newGroup; } else { // had a prior group with that name, add the prior group back groups.put(name, prior); return prior; } } else { // return a non-registered group that is immediately closed already GenericMetricGroup closedGroup = new GenericMetricGroup(registry, this, name); closedGroup.close(); return closedGroup; } } }