@Override protected ProducerConfig customizeConfig(final ProducerConfig config) { final Properties props = config.props().props(); props.setProperty("serializer.class", "kafka.serializer.DefaultEncoder"); return new ProducerConfig(props); }
@Override protected ProducerConfig customizeConfig(final ProducerConfig config) { final Properties props = config.props().props(); props.setProperty("serializer.class", "kafka.serializer.StringEncoder"); return new ProducerConfig(props); }
@Override public void init(VerifiableProperties props) { if (!initialized) { this.props = new Properties(); if (props.containsKey(CONFIG_POLLING_INTERVAL)) { this.pollingIntervalSeconds = props.getInt(CONFIG_POLLING_INTERVAL); } else { this.pollingIntervalSeconds = 10; } this.brokerId = Integer.parseInt(props.getProperty("broker.id")); log.info("Building ConsumerGroupReporter: polling.interval=" + pollingIntervalSeconds); Enumeration<Object> keys = props.props().keys(); while (keys.hasMoreElements()) { String key = keys.nextElement().toString(); if (key.startsWith("kafka.metrics.")) { String subKey = key.substring(14); this.props.put(subKey, props.props().get(key)); log.info("Building ConsumerGroupReporter: " + subKey + "=" + this.props.get(subKey)); } } initialized = true; this.underlying = new X(Metrics.defaultRegistry()); startReporter(pollingIntervalSeconds); } }
public void init(VerifiableProperties kafkaConfig) { if (!initialized) { initialized = true; this.config = kafkaConfig.props(); this.builder = forRegistry(Metrics.defaultRegistry()); builder.configure(config); underlying = builder.build(); startReporter(underlying.getPollingIntervaSeconds()); } }
@Override public synchronized void init(VerifiableProperties props) { if (!initialized) { KafkaMetricsConfig metricsConfig = new KafkaMetricsConfig(props); graphiteHost = props.getString("kafka.graphite.metrics.host", GRAPHITE_DEFAULT_HOST); graphitePort = props.getInt("kafka.graphite.metrics.port", GRAPHITE_DEFAULT_PORT); metricPrefix = props.getString("kafka.graphite.metrics.group", GRAPHITE_DEFAULT_PREFIX); String excludeRegex = props.getString("kafka.graphite.metrics.exclude.regex", null); metricDimensions = Dimension.fromProperties(props.props(), "kafka.graphite.dimension.enabled."); LOG.debug("Initialize GraphiteReporter [{},{},{}]", graphiteHost, graphitePort, metricPrefix); if (excludeRegex != null) { LOG.debug("Using regex [{}] for GraphiteReporter", excludeRegex); metricPredicate = new FilterMetricPredicate(excludeRegex); } reporter = buildGraphiteReporter(); if (props.getBoolean("kafka.graphite.metrics.reporter.enabled", false)) { initialized = true; startReporter(metricsConfig.pollingIntervalSecs()); LOG.debug("GraphiteReporter started."); } } }