Skip to content

Commit 21d89e1

Browse files
committed
Set client.software.name and .version (KIP-511)
1 parent eb616e7 commit 21d89e1

File tree

2 files changed

+35
-5
lines changed

2 files changed

+35
-5
lines changed

confluent_kafka/src/confluent_kafka.c

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,6 +1672,24 @@ static int common_conf_set_special(PyObject *confdict, rd_kafka_conf_t *conf,
16721672
return 1;
16731673
}
16741674

1675+
1676+
/**
1677+
* @brief KIP-511: Set client.software.name and .version which is reported
1678+
* to the broker.
1679+
* Errors are ignored here since this is best-effort.
1680+
*/
1681+
static void common_conf_set_software (rd_kafka_conf_t *conf) {
1682+
char version[128];
1683+
1684+
rd_kafka_conf_set(conf, "client.software.name",
1685+
"confluent-kafka-python", NULL, 0);
1686+
1687+
snprintf(version, sizeof(version), "%s-rdkafka-%s",
1688+
CFL_VERSION_STR, rd_kafka_version_str(), NULL, 0);
1689+
rd_kafka_conf_set(conf, "client.software.version", version, NULL, 0);
1690+
}
1691+
1692+
16751693
/**
16761694
* Common config setup for Kafka client handles.
16771695
*
@@ -1745,6 +1763,10 @@ rd_kafka_conf_t *common_conf_setup (rd_kafka_type_t ktype,
17451763

17461764
conf = rd_kafka_conf_new();
17471765

1766+
/* Set software name and verison prior to applying the confdict to
1767+
* allow even higher-level clients to override it. */
1768+
common_conf_set_software(conf);
1769+
17481770
/*
17491771
* Set debug contexts first to capture all events including plugin loading
17501772
*/
@@ -2288,13 +2310,11 @@ static PyObject *libversion (PyObject *self, PyObject *args) {
22882310
rd_kafka_version());
22892311
}
22902312

2291-
/*
2292-
* Version hex representation
2293-
* 0xMMmmRRPP
2294-
* MM=major, mm=minor, RR=revision, PP=patchlevel (not used)
2313+
/**
2314+
* @brief confluent-kafka-python version.
22952315
*/
22962316
static PyObject *version (PyObject *self, PyObject *args) {
2297-
return Py_BuildValue("si", "1.3.0", 0x01030000);
2317+
return Py_BuildValue("si", CFL_VERSION_STR, CFL_VERSION);
22982318
}
22992319

23002320
static PyMethodDef cimpl_methods[] = {

confluent_kafka/src/confluent_kafka.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@
3434
#endif
3535

3636

37+
/**
38+
* @brief confluent-kafka-python version, must match that of setup.py.
39+
*
40+
* Hex version representation:
41+
* 0xMMmmRRPP
42+
* MM=major, mm=minor, RR=revision, PP=patchlevel (not used)
43+
*/
44+
#define CFL_VERSION 0x01040000
45+
#define CFL_VERSION_STR "1.4.0"
46+
3747
/**
3848
* Minimum required librdkafka version. This is checked both during
3949
* build-time (just below) and runtime (see confluent_kafka.c).

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy