Skip to content

Commit

Permalink
KAFKA-18078 Fix failed MetricsTest.testJMXFilter (apache#17924)
Browse files Browse the repository at this point in the history
Reviewers: Chia-Ping Tsai <[email protected]>
  • Loading branch information
brandboat authored and chiacyu committed Nov 30, 2024
1 parent 085ff6c commit b41e1e4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 1 addition & 5 deletions core/src/main/scala/kafka/server/KafkaRaftServer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ package kafka.server
import java.io.File
import java.util.concurrent.CompletableFuture
import kafka.log.UnifiedLog
import kafka.metrics.KafkaMetricsReporter
import kafka.utils.{CoreUtils, Logging, Mx4jLoader, VerifiableProperties}
import kafka.utils.{CoreUtils, Logging, Mx4jLoader}
import org.apache.kafka.common.config.{ConfigDef, ConfigResource}
import org.apache.kafka.common.internals.Topic
import org.apache.kafka.common.utils.{AppInfoParser, Time}
Expand All @@ -32,7 +31,6 @@ import org.apache.kafka.metadata.properties.{MetaProperties, MetaPropertiesEnsem
import org.apache.kafka.raft.QuorumConfig
import org.apache.kafka.server.{ProcessRole, ServerSocketFactory}
import org.apache.kafka.server.config.ServerTopicConfigSynonyms
import org.apache.kafka.server.metrics.KafkaYammerMetrics
import org.apache.kafka.storage.internals.log.LogConfig
import org.slf4j.Logger

Expand All @@ -53,8 +51,6 @@ class KafkaRaftServer(
) extends Server with Logging {

this.logIdent = s"[KafkaRaftServer nodeId=${config.nodeId}] "
KafkaMetricsReporter.startReporters(VerifiableProperties(config.originals))
KafkaYammerMetrics.INSTANCE.configure(config.originals)

private val (metaPropsEnsemble, bootstrapMetadata) =
KafkaRaftServer.initializeLogDirs(config, this.logger.underlying, this.logIdent)
Expand Down
6 changes: 5 additions & 1 deletion core/src/main/scala/kafka/server/SharedServer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@

package kafka.server

import kafka.metrics.KafkaMetricsReporter
import kafka.raft.KafkaRaftManager
import kafka.server.Server.MetricsPrefix
import kafka.utils.{CoreUtils, Logging}
import kafka.utils.{CoreUtils, Logging, VerifiableProperties}
import org.apache.kafka.common.metrics.Metrics
import org.apache.kafka.common.network.ListenerName
import org.apache.kafka.common.utils.{AppInfoParser, LogContext, Time, Utils}
Expand Down Expand Up @@ -101,6 +102,9 @@ class SharedServer(
val faultHandlerFactory: FaultHandlerFactory,
val socketFactory: ServerSocketFactory
) extends Logging {
KafkaMetricsReporter.startReporters(VerifiableProperties(sharedServerConfig.originals))
KafkaYammerMetrics.INSTANCE.configure(sharedServerConfig.originals)

private val logContext: LogContext = new LogContext(s"[SharedServer id=${sharedServerConfig.nodeId}] ")
this.logIdent = logContext.logPrefix
private var started = false
Expand Down

0 comments on commit b41e1e4

Please sign in to comment.