[ 
https://issues.apache.org/jira/browse/KAFKA-517?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16256991#comment-16256991
 ] 

Sönke Liebau commented on KAFKA-517:
------------------------------------

A recent 
[commit|https://github.com/apache/kafka/commit/9be71f7bdcd147aee7a360a4ccf400acb858a056]
 introduced a jmxSanitizer to properly quote jmx strings if necessary. This is 
currently being applied to tags and mbean strings, but not to the name.
This is probably not really a problem, as I couldn't find any occurrences where 
there are dynamic metric names, so any exceptions should occur during testing 
when adding new metrics, however it is a potential exception that can be 
avoided by sanitizing names as well.

We could apply the transformation 
[here|https://github.com/apache/kafka/blob/7672e9ec3def7af6797bc0ecf254ac694efdfad5/core/src/main/scala/kafka/metrics/KafkaMetricsGroup.scala#L64].
 As far as I can tell (and I am by no means an expert on jmx) this should not 
change anything for properly named metrics (which currently is all of them) but 
in case someone ever adds one with an illegal name it would not cause an 
exception. 

I am unsure if this is a useful addition or if we'd rather new metrics fail so 
that the author can change the name to something valid. Maybe someone can 
comment on my musings, happy to create a small pull request if we deem this 
useful. If not, I believe we can close the issue.

> Ensure that we escape the metric names if they include user strings
> -------------------------------------------------------------------
>
>                 Key: KAFKA-517
>                 URL: https://issues.apache.org/jira/browse/KAFKA-517
>             Project: Kafka
>          Issue Type: Bug
>    Affects Versions: 0.8.0
>            Reporter: Jay Kreps
>              Labels: bugs
>
> JMX has limits on valid strings. We need to check validity before blindly 
> creating a metric that includes a given topic name. If we fail to do this we 
> will get an exception like this:
> javax.management.MalformedObjectNameException: Unterminated key property part
>       at javax.management.ObjectName.construct(ObjectName.java:540)
>       at javax.management.ObjectName.<init>(ObjectName.java:1403)
>       at 
> com.yammer.metrics.reporting.JmxReporter.onMetricAdded(JmxReporter.java:395)
>       at 
> com.yammer.metrics.core.MetricsRegistry.notifyMetricAdded(MetricsRegistry.java:516)
>       at 
> com.yammer.metrics.core.MetricsRegistry.getOrAdd(MetricsRegistry.java:491)
>       at 
> com.yammer.metrics.core.MetricsRegistry.newMeter(MetricsRegistry.java:240)
>       at com.yammer.metrics.Metrics.newMeter(Metrics.java:245)
>       at 
> kafka.metrics.KafkaMetricsGroup$class.newMeter(KafkaMetricsGroup.scala:46)
>       at kafka.server.FetcherStat.newMeter(AbstractFetcherThread.scala:180)
>       at kafka.server.FetcherStat.<init>(AbstractFetcherThread.scala:182)
>       at 
> kafka.server.FetcherStat$$anonfun$2.apply(AbstractFetcherThread.scala:186)
>       at 
> kafka.server.FetcherStat$$anonfun$2.apply(AbstractFetcherThread.scala:186)
>       at kafka.utils.Pool.getAndMaybePut(Pool.scala:60)
>       at 
> kafka.server.FetcherStat$.getFetcherStat(AbstractFetcherThread.scala:190)



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to