|
Hi all,
Flink 版本1.11.1, 在TaskMetricGroup 这个类中,限制了operator name作为metric的最大长度是80,并且不可以用户自定义配置。
我们往往在为一个operator命名的时候,会加入更多的信息,在任务提交到flink集群中,可以在Flink Web UI界面上看到完整的task信息。但是在metrics exporter上,这个name被截取到80个字符,这样在Prometheus在收集metrics的时候,就会信息缺失。
提供相关源码如下:
public class TaskMetricGroup extends ComponentMetricGroup<TaskManagerJobMetricGroup> {
private final Map<String, OperatorMetricGroup> operators = new HashMap<>();
static final int METRICS_OPERATOR_NAME_MAX_LENGTH = 80;
private final TaskIOMetricGroup ioMetrics;
…….
public OperatorMetricGroup getOrAddOperator(OperatorID operatorID, String name) {
final String metricName;
if (name != null && name.length() > METRICS_OPERATOR_NAME_MAX_LENGTH) {
LOG.warn("The operator name {} exceeded the {} characters length limit and was truncated.", name, METRICS_OPERATOR_NAME_MAX_LENGTH);
metricName = name.substring(0, METRICS_OPERATOR_NAME_MAX_LENGTH);
} else {
metricName = name;
}
// unique OperatorIDs only exist in streaming, so we have to rely on the name for batch operators
final String key = operatorID + metricName;
synchronized (this) {
return operators.computeIfAbsent(key, operator -> new OperatorMetricGroup(this.registry, this, operatorID, metricName));
}
}
谢谢
王剑
|