Browse Source
* Fixes a bug in which all NamedCache instances in a process shared one parent metric. * Also fixes a bug which incorrectly computed the per-cache metric tag (which was undetected due to the former bug). * Drop the StreamsMetricsConventions#xLevelSensorName convention in favor of StreamsMetricsImpl#xLevelSensor to allow StreamsMetricsImpl to track thread- and cache-level metrics, so that they may be cleanly declared from anywhere but still unloaded at the appropriate time. This was necessary right now so that the NamedCache could register a thread-level parent sensor to be unloaded when the thread, not the cache, is closed. * The above changes made it mostly unnecessary for the StreamsMetricsImpl to expose a reference to the underlying Metrics registry, so I did a little extra work to remove that reference, including removing inconsistently-used and unnecessary calls to Metrics#close() in the tests. The existing tests should be sufficient to verify this change. Reviewers: Bill Bejeck <bill@confluent.io>, Guozhang Wang <wangguoz@gmail.com>pull/4937/head
John Roesler
7 years ago
committed by
Guozhang Wang
32 changed files with 258 additions and 214 deletions
@ -1,39 +0,0 @@
@@ -1,39 +0,0 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.apache.kafka.streams.processor.internals.metrics; |
||||
|
||||
import java.util.LinkedHashMap; |
||||
import java.util.Map; |
||||
|
||||
public final class StreamsMetricsConventions { |
||||
private StreamsMetricsConventions() { |
||||
} |
||||
|
||||
public static String threadLevelSensorName(final String threadName, final String sensorName) { |
||||
return "thread." + threadName + "." + sensorName; |
||||
} |
||||
|
||||
static Map<String, String> threadLevelTags(final String threadName, final Map<String, String> tags) { |
||||
if (tags.containsKey("client-id")) { |
||||
return tags; |
||||
} else { |
||||
final LinkedHashMap<String, String> newTags = new LinkedHashMap<>(tags); |
||||
newTags.put("client-id", threadName); |
||||
return newTags; |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue