KAFKA-9960: implement KIP-606 to add metadata context to MetricsReporter#8691
Conversation
add changes to connect as part of KIP 606 implementation
386a5da to
6005c9a
Compare
rhauch
left a comment
There was a problem hiding this comment.
Thanks, @xiaodongdu. I'm only part way through the Connect portion, but I already have some comments/suggestions.
I'll continue to review over the next day or two.
|
ok to test |
|
Since MetricsReporter instances are the ultimate consumers of the MetadataContext instance I would like to propose moving construction MetricsContext there. This would allow each reporter to manage its own set of labels increasing encapsulation and extensibility. |
| */ | ||
| public KafkaMetricsContext(String namespace, Map<String, ?> metadata) { | ||
| this.metadata.put(MetricsContext.NAMESPACE, namespace); | ||
| metadata.forEach((key, value) -> this.metadata.put(key, value.toString())); |
There was a problem hiding this comment.
Use putIfAbsent to avoid silently overwriting over labels set upstream.
There was a problem hiding this comment.
I think we it's ok for the component that owns the reporter to take precedence over the labels passed from upstream. We did not specify the behavior in the KIP, so implementations should use namespacing of labels to avoid this. If in practice we find this behavior is less desirable, we can file a follow-on KIP, since the interface is till evolving.
There was a problem hiding this comment.
Mostly I'm concerned about the case where some composite may share similar labels to the underlying client it manages. If we allow the downstream client to overwrite such a label we will lose a portion of the upstream components context.
There was a problem hiding this comment.
the client currently only injects the labels passed in via client properties, so that wouldn't happen
| public final class ConnectUtils { | ||
| private static final Logger log = LoggerFactory.getLogger(ConnectUtils.class); | ||
| public static final String CONNECT_KAFKA_CLUSTER_ID = "connect.kafka.cluster.id"; | ||
| public static final String CONNECT_GROUP_ID = "connect.group.id"; |
There was a problem hiding this comment.
Maybe it would be helpful to add CONNECT_VERSION as well.
There was a problem hiding this comment.
Version is added in ce-kafka.
| * @param metricsContext the metric context | ||
| */ | ||
| @InterfaceStability.Evolving | ||
| default void contextChange(MetricsContext metricsContext) { |
There was a problem hiding this comment.
It would also be good to identify when this is called relative to other methods. For example, it is always called before init(...) is called. But can it be called again, or is that the only time this method is called?
|
ok to test |
|
@xiaodongdu please address the conflicts. |
rhauch
left a comment
There was a problem hiding this comment.
It'd be nice to get clarification on the call pattern for MetricsReporter.contextChange(..) method to potentially update the JavaDoc. Otherwise, this looks good for the general code and Connect-related code.
|
ok to test |
rhauch
left a comment
There was a problem hiding this comment.
I've reviewed the common code, Connect, and MirrorMaker2. Those parts LGTM, pending a green build.
|
ok to test |
|
retest this please |
1 similar comment
|
retest this please |
|
ok to test |
|
retest this please |
|
ok to test |
|
retest this please |
2 similar comments
|
retest this please |
|
retest this please |
|
ok to test |
|
retest this please |
|
One seemingly unrelated failure on JDK11 with a known flaky test: |
Implement KIP-606, add metadata context to MetricsReporter:
Committer Checklist (excluded from commit message)