private static void testLatencyStats( final LatencyStats.Granularity granularity, final Consumer<List<Tuple2<String, Histogram>>> verifier) { final AbstractMetricGroup<?> dummyGroup = UnregisteredMetricGroups.createUnregisteredOperatorMetricGroup(); final TestMetricRegistry registry = new TestMetricRegistry(); final MetricGroup parentGroup = new GenericMetricGroup(registry, dummyGroup, PARENT_GROUP_NAME); final LatencyStats latencyStats = new LatencyStats( parentGroup, MetricOptions.LATENCY_HISTORY_SIZE.defaultValue(), OPERATOR_SUBTASK_INDEX, OPERATOR_ID, granularity); latencyStats.reportLatency(new LatencyMarker(0L, SOURCE_ID_1, 0)); latencyStats.reportLatency(new LatencyMarker(0L, SOURCE_ID_1, 0)); latencyStats.reportLatency(new LatencyMarker(0L, SOURCE_ID_1, 1)); latencyStats.reportLatency(new LatencyMarker(0L, SOURCE_ID_2, 2)); latencyStats.reportLatency(new LatencyMarker(0L, SOURCE_ID_2, 3)); verifier.accept(registry.latencyHistograms); }
public GenericMetricGroup(MetricRegistry registry, AbstractMetricGroup parent, String name) { super(registry, makeScopeComponents(parent, name), parent); this.name = name; }
AbstractMetricGroup newGroup = new GenericMetricGroup(registry, this, name); AbstractMetricGroup prior = groups.put(name, newGroup); if (prior == null) { 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; } } }
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; } } }
protected GenericMetricGroup createChildGroup(String name, ChildType childType) { switch (childType) { case KEY: return new GenericKeyMetricGroup(registry, this, name); default: return new GenericMetricGroup(registry, this, name); } }
public GenericMetricGroup(MetricRegistry registry, AbstractMetricGroup parent, String name) { super(registry, makeScopeComponents(parent, name), parent); this.name = name; }
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; } } }
protected GenericMetricGroup createChildGroup(String name, ChildType childType) { switch (childType) { case KEY: return new GenericKeyMetricGroup(registry, this, name); default: return new GenericMetricGroup(registry, this, name); } }
public GenericMetricGroup(MetricRegistry registry, AbstractMetricGroup parent, String name) { super(registry, makeScopeComponents(parent, name), parent); this.name = name; }
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; } } }
protected GenericMetricGroup createChildGroup(String name, ChildType childType) { switch (childType) { case KEY: return new GenericKeyMetricGroup(registry, this, name); default: return new GenericMetricGroup(registry, this, name); } }
public GenericMetricGroup(MetricRegistry registry, AbstractMetricGroup parent, String name) { super(registry, makeScopeComponents(parent, name), parent); this.name = name; }
@Override protected GenericMetricGroup createChildGroup(String name, ChildType childType) { switch (childType) { case VALUE: return new GenericValueMetricGroup(registry, this, name); default: return new GenericMetricGroup(registry, this, name); } } }
@Override protected GenericMetricGroup createChildGroup(String name, ChildType childType) { switch (childType) { case VALUE: return new GenericValueMetricGroup(registry, this, name); default: return new GenericMetricGroup(registry, this, name); } } }
@Override protected GenericMetricGroup createChildGroup(String name, ChildType childType) { switch (childType) { case VALUE: return new GenericValueMetricGroup(registry, this, name); default: return new GenericMetricGroup(registry, this, name); } } }
protected GenericMetricGroup createChildGroup(String name, ChildType childType) { switch (childType) { case KEY: return new GenericKeyMetricGroup(registry, this, name); default: return new GenericMetricGroup(registry, this, name); } }