X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fwrite_kafka.c;h=10ae5a578c7f651bba423100b8a5924ee9d8b6ee;hb=42ca41a0798e3a2b742f7da3bacc03fbaf6175fa;hp=2c3296db221eda6cdd2a8223bca1113950f9d5c5;hpb=1eaf573c8724b2b97d670863c0f8cb7afa9ecbf8;p=collectd.git diff --git a/src/write_kafka.c b/src/write_kafka.c index 2c3296db..10ae5a57 100644 --- a/src/write_kafka.c +++ b/src/write_kafka.c @@ -115,7 +115,6 @@ static int kafka_handle(struct kafka_topic_context *ctx) /* {{{ */ INFO ("write_kafka plugin: created KAFKA handle : %s", rd_kafka_name(ctx->kafka)); #if defined(HAVE_LIBRDKAFKA_LOGGER) && !defined(HAVE_LIBRDKAFKA_LOG_CB) - if rd_kafka_set_logger(ctx->kafka, kafka_log); #endif } @@ -203,6 +202,8 @@ static int kafka_write(const data_set_t *ds, /* {{{ */ key = ctx->key; if (key != NULL) keylen = strlen (key); + else + keylen = 0; rd_kafka_produce(ctx->topic, RD_KAFKA_PARTITION_UA, RD_KAFKA_MSG_F_COPY, buffer, blen, @@ -253,6 +254,7 @@ static void kafka_config_topic(rd_kafka_conf_t *conf, oconfig_item_t *ci) /* {{{ tctx->escape_char = '.'; tctx->store_rates = 1; tctx->format = KAFKA_FORMAT_JSON; + tctx->key = NULL; if ((tctx->kafka_conf = rd_kafka_conf_dup(conf)) == NULL) { sfree(tctx); @@ -316,6 +318,7 @@ static void kafka_config_topic(rd_kafka_conf_t *conf, oconfig_item_t *ci) /* {{{ } else if (strcasecmp ("Key", child->key) == 0) { cf_util_get_string (child, &tctx->key); + assert (tctx->key != NULL); } else if (strcasecmp ("Format", child->key) == 0) { status = cf_util_get_string(child, &key); if (status != 0)