Skip to content

Commit

Permalink
KAFKA-18077 Remove deprecated JmxReporter(String) (apache#17923)
Browse files Browse the repository at this point in the history
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
  • Loading branch information
clarkwtc authored Nov 25, 2024
1 parent 3268435 commit 54843e6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,7 @@ public class JmxReporter implements MetricsReporter {
private Predicate<String> mbeanPredicate = s -> true;

public JmxReporter() {
this("");
}

/**
* Create a JMX reporter that prefixes all metrics with the given string.
* @deprecated Since 2.6.0. Use {@link JmxReporter#JmxReporter()}
* Initialize JmxReporter with {@link JmxReporter#contextChange(MetricsContext)}
* Populate prefix by adding _namespace/prefix key value pair to {@link MetricsContext}
*/
@Deprecated
public JmxReporter(String prefix) {
this.prefix = prefix != null ? prefix : "";
this.prefix = "";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,23 +177,4 @@ public void testJmxPrefix() throws Exception {
metrics.close();
}
}

@Test
public void testDeprecatedJmxPrefixWithDefaultMetrics() throws Exception {
@SuppressWarnings("deprecation")
JmxReporter reporter = new JmxReporter("my-prefix");

// for backwards compatibility, ensure prefix does not get overridden by the default empty namespace in metricscontext
MetricConfig metricConfig = new MetricConfig();
Metrics metrics = new Metrics(metricConfig, new ArrayList<>(Collections.singletonList(reporter)), Time.SYSTEM);

MBeanServer server = ManagementFactory.getPlatformMBeanServer();
try {
Sensor sensor = metrics.sensor("my-sensor");
sensor.add(metrics.metricName("pack.bean1.avg", "grp1"), new Avg());
assertEquals("my-prefix", server.getObjectInstance(new ObjectName("my-prefix:type=grp1")).getObjectName().getDomain());
} finally {
metrics.close();
}
}
}
5 changes: 4 additions & 1 deletion docs/upgrade.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ <h5><a id="upgrade_400_notable" href="#upgrade_400_notable">Notable changes in 4
<li>The <code>auto.include.jmx.reporter</code> configuration was removed. The <code>metric.reporters</code> configuration
is now set to <code>org.apache.kafka.common.metrics.JmxReporter</code> by default.
</li>
<li>The constructor <code>org.apache.kafka.common.metrics.JmxReporter</code> with string argument was removed.
See <a href="https://cwiki.apache.org/confluence/display/KAFKA/KIP-606%3A+Add+Metadata+Context+to+MetricsReporter">KIP-606</a> for details.
</li>
<li>The <code>bufferpool-wait-time-total</code>, <code>io-waittime-total</code>, and <code>iotime-total</code> metrics were removed.
Please use <code>bufferpool-wait-time-ns-total</code>, <code>io-wait-time-ns-total</code>, and <code>io-time-ns-total</code> metrics as replacements, respectively.
</li>
Expand All @@ -53,7 +56,7 @@ <h5><a id="upgrade_400_notable" href="#upgrade_400_notable">Notable changes in 4
<li>The original MirrorMaker (MM1) and related classes were removed. Please use the Connect-based
MirrorMaker (MM2), as described in the <a href="/{{version}}/documentation/#georeplication">Geo-Replication section.</a>.
</li>
<li>The <code>use.incremental.alter.configs</code> configuration was removedfrom <code>MirrorSourceConnector</code>.
<li>The <code>use.incremental.alter.configs</code> configuration was removed from <code>MirrorSourceConnector</code>.
The modified behavior is identical to the previous <code>required</code> configuration, therefore users should ensure that brokers in the target cluster are at least running 2.3.0.
</li>
<li>The <code>add.source.alias.to.metrics</code> configuration was removed from <code>MirrorSourceConnector</code>.
Expand Down

0 comments on commit 54843e6

Please sign in to comment.