Commit 6176ea1
kafka_consumer: reuse AdminClient and Consumer connections across runs (DataDog#24552)
* kafka_consumer: reuse AdminClient and Consumer across runs
Recreating the librdkafka AdminClient (close_admin_client defaulted to true) and
opening/closing a Consumer on every run tore down and respawned librdkafka's
per-broker threads each collection. On high-core hosts that spreads allocations
across many glibc arenas whose freed memory is never reused or returned, so agent
RSS climbs unbounded. Keep both clients alive (default close_admin_client to
false, make open_consumer idempotent, and stop closing the consumer used for
cluster-id detection) so the same threads and arenas are reused each run.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Add changelog entry for connection reuse
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Drop inline rationale comments (kept in PR/changelog)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Guard consumer reuse under close_admin_client flag
close_admin_client now controls reuse of both clients: when false (default) the
AdminClient and Consumer are both reused across runs; when true, both are closed
each run (previous behavior).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Drop explanatory comment on consumer close guard
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Keep close_admin_client default unchanged (true)
Reuse of both clients is opt-in via close_admin_client: false; the default
behavior (closing clients each run) is unchanged.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Reword changelog: reuse is opt-in via close_admin_client
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 433b81a commit 6176ea1
3 files changed
Lines changed: 9 additions & 1 deletion
File tree
- kafka_consumer
- changelog.d
- datadog_checks/kafka_consumer
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
45 | 48 | | |
46 | 49 | | |
47 | 50 | | |
| |||
55 | 58 | | |
56 | 59 | | |
57 | 60 | | |
| 61 | + | |
| 62 | + | |
58 | 63 | | |
59 | 64 | | |
| 65 | + | |
60 | 66 | | |
61 | 67 | | |
62 | 68 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
543 | 543 | | |
544 | 544 | | |
545 | 545 | | |
546 | | - | |
| 546 | + | |
| 547 | + | |
547 | 548 | | |
548 | 549 | | |
549 | 550 | | |
| |||
0 commit comments