Skip to content

KAFKA-9960: implement KIP-606 to add metadata context to MetricsReporter#8691

Merged
rhauch merged 34 commits into
apache:trunkfrom
xiaodongdu:kafka-9960-kip-606
May 28, 2020
Merged

KAFKA-9960: implement KIP-606 to add metadata context to MetricsReporter#8691
rhauch merged 34 commits into
apache:trunkfrom
xiaodongdu:kafka-9960-kip-606

Conversation

@xiaodongdu

@xiaodongdu xiaodongdu commented May 18, 2020

Copy link
Copy Markdown
Contributor

Implement KIP-606, add metadata context to MetricsReporter:

  • Added a new api to MetricsReporter to allow client to expose additional metadata fields to reporter plugin. Added an interface MetricsContext to encapsulate metadata.
  • Deprecated JmexReporter(String prefix) constructor. The prefix will be passed to the reporter via MetricsContext.
  • Replaced existing usage of JmxReporter with the default ImxReporter and pass JMX prefix to MetricsContext using _namespace as key.
  • From Kafka broker, populate MetricsContext with: kafka.cluster.id and kafka.nroker.id
  • From Connect, populate MetricsContext with: connect.kafka.cluster.id, connect.group.id

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

@xiaodongdu

Copy link
Copy Markdown
Contributor Author

@xvrl @rhauch @ijuma Could you review this PR for KIP-606. Thanks,

add changes to connect as part of KIP 606 implementation
@xiaodongdu
xiaodongdu force-pushed the kafka-9960-kip-606 branch from 386a5da to 6005c9a Compare May 19, 2020 16:37

@rhauch rhauch left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread connect/mirror/src/main/java/org/apache/kafka/connect/mirror/MirrorMaker.java Outdated
Comment thread connect/mirror/src/main/java/org/apache/kafka/connect/mirror/MirrorMaker.java Outdated
Comment thread connect/mirror/src/main/java/org/apache/kafka/connect/mirror/MirrorMaker.java Outdated
Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/cli/ConnectStandalone.java Outdated
Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/runtime/Worker.java Outdated
@rhauch

rhauch commented May 19, 2020

Copy link
Copy Markdown
Contributor

ok to test

@rnpridgeon

Copy link
Copy Markdown
Contributor

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.

@xiaodongdu
xiaodongdu requested a review from rhauch May 20, 2020 18:01
*/
public KafkaMetricsContext(String namespace, Map<String, ?> metadata) {
this.metadata.put(MetricsContext.NAMESPACE, namespace);
metadata.forEach((key, value) -> this.metadata.put(key, value.toString()));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use putIfAbsent to avoid silently overwriting over labels set upstream.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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";

@rnpridgeon rnpridgeon May 22, 2020

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it would be helpful to add CONNECT_VERSION as well.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Version is added in ce-kafka.

* @param metricsContext the metric context
*/
@InterfaceStability.Evolving
default void contextChange(MetricsContext metricsContext) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@rhauch

rhauch commented May 26, 2020

Copy link
Copy Markdown
Contributor

ok to test

@xiaodongdu
xiaodongdu requested a review from rhauch May 27, 2020 00:43
@rhauch

rhauch commented May 27, 2020

Copy link
Copy Markdown
Contributor

@xiaodongdu please address the conflicts.

@rhauch rhauch left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@xiaodongdu
xiaodongdu requested a review from rhauch May 27, 2020 16:12
@rhauch

rhauch commented May 27, 2020

Copy link
Copy Markdown
Contributor

ok to test

@rhauch rhauch left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've reviewed the common code, Connect, and MirrorMaker2. Those parts LGTM, pending a green build.

@rhauch

rhauch commented May 27, 2020

Copy link
Copy Markdown
Contributor

ok to test

@rhauch

rhauch commented May 27, 2020

Copy link
Copy Markdown
Contributor

retest this please

1 similar comment
@rhauch

rhauch commented May 27, 2020

Copy link
Copy Markdown
Contributor

retest this please

@kkonstantine

Copy link
Copy Markdown
Contributor

ok to test

@kkonstantine

Copy link
Copy Markdown
Contributor

retest this please

@rhauch rhauch closed this May 27, 2020
@rhauch rhauch reopened this May 27, 2020
@rhauch

rhauch commented May 27, 2020

Copy link
Copy Markdown
Contributor

ok to test

@rhauch

rhauch commented May 27, 2020

Copy link
Copy Markdown
Contributor

retest this please

2 similar comments
@rhauch

rhauch commented May 27, 2020

Copy link
Copy Markdown
Contributor

retest this please

@rhauch

rhauch commented May 27, 2020

Copy link
Copy Markdown
Contributor

retest this please

@rhauch

rhauch commented May 27, 2020

Copy link
Copy Markdown
Contributor

ok to test

@rhauch

rhauch commented May 27, 2020

Copy link
Copy Markdown
Contributor

retest this please

@rhauch

rhauch commented May 27, 2020

Copy link
Copy Markdown
Contributor

One seemingly unrelated failure on JDK11 with a known flaky test:

kafka.api.PlaintextProducerSendTest.testNonBlockingProducer
    java.util.concurrent.TimeoutException: Timeout after waiting for 10000 ms.

@mumrah mumrah left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rhauch
rhauch merged commit 9c833f6 into apache:trunk May 28, 2020
@mjsax mjsax added the kip Requires or implements a KIP label Jun 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

connect core Kafka Broker kip Requires or implements a KIP streams

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants