Skip to content

Backport #24554 to 7.82.x: keep broker_timestamps in memory and persist every 5 minutes#24592

Merged
nubtron merged 1 commit into
7.82.xfrom
backport-24554-to-7.82.x
Jul 20, 2026
Merged

Backport #24554 to 7.82.x: keep broker_timestamps in memory and persist every 5 minutes#24592
nubtron merged 1 commit into
7.82.xfrom
backport-24554-to-7.82.x

Conversation

@piochelepiotr

Copy link
Copy Markdown
Contributor

What does this PR do?

Backports #24554 to the 7.82.x branch. Keeps the DSM broker_timestamps history in memory across check runs (loaded from the persistent cache only once, on the first run) and persists it back to disk at most once every 5 minutes, instead of loading and dumping the whole structure on every run.

Motivation

With Data Streams enabled, the broker_timestamps cache grows toward its per-cluster entry cap. Loading it from disk and re-dumping it on every run created a large transient allocation each cycle that scales with the cache size, fragmenting the heap and driving agent RSS up. Holding the structure in memory removes the per-run load/dump churn; periodic persistence (every 5 min) preserves restart durability while keeping write churn low. On agent restart at most a few minutes of timestamp history is lost, which is acceptable for lag-in-seconds interpolation.

See #incident-57455 for the impact on memory fragmentation.

Note: the 7.82.x branch still persists broker_timestamps via json.dumps/json.loads, since the switch to base64+marshal serialization landed on master in a separate, later commit not covered by #24554. This backport applies the same in-memory/periodic-persistence behavior on top of the existing json-based read/write, and does not pull in the marshal/base64 change.

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Add qa/required if this PR needs QA validation, or qa/skip-qa if it does not. Exactly one of the two is required.
  • If you need to backport this PR to another branch, you can add the backport/<branch-name> label to the PR and it will automatically open a backport PR once this one is merged

…minutes (#24554)

* kafka_consumer: keep broker_timestamps in memory and persist every 5 min

Loading and marshalling the whole broker_timestamps cache on every run created a
large, growing transient allocation each cycle (the cache grows toward its
per-cluster cap), which fragments the heap. Keep the cache in memory across runs
(loading from disk only once) and persist it to disk at most every 5 minutes,
so per-run allocation churn no longer scales with the cache size.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* Add changelog entry for periodic broker_timestamps persistence

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* Address review: drop leading underscores on new cache attributes, remove comments

Rename broker_timestamps / broker_timestamps_last_save without a leading
underscore per the repo naming convention (leading underscores are reserved for
Pydantic private attributes), and drop the explanatory comments.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
(cherry picked from commit 3c3a9fe)
@piochelepiotr piochelepiotr added qa/required QA is required for this PR and will generate a QA card integration/kafka_consumer team/agent-integrations labels Jul 17, 2026
@piochelepiotr
piochelepiotr marked this pull request as ready for review July 17, 2026 14:19
@piochelepiotr
piochelepiotr requested a review from a team as a code owner July 17, 2026 14:19
@temporal-github-worker-1

Copy link
Copy Markdown

Backport evaluation: View Slack thread

@datadog-prod-us1-5

Copy link
Copy Markdown

Tests  Code Coverage

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 91.81%

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 7410371 | Docs | Datadog PR Page | Give us feedback!

@dd-octo-sts

dd-octo-sts Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Validation Report

All 21 validations passed.

Show details
Validation Description Status
agent-reqs Verify check versions match the Agent requirements file
ci Validate CI configuration and code coverage settings
codeowners Validate every integration has a CODEOWNERS entry
config Validate default configuration files against spec.yaml
dep Verify dependency pins are consistent and Agent-compatible
http Validate integrations use the HTTP wrapper correctly
imports Validate check imports do not use deprecated modules
integration-style Validate check code style conventions
jmx-metrics Validate JMX metrics definition files and config
labeler Validate PR labeler config matches integration directories
legacy-signature Validate no integration uses the legacy Agent check signature
license-headers Validate Python files have proper license headers
licenses Validate third-party license attribution list
metadata Validate metadata.csv metric definitions
models Validate configuration data models match spec.yaml
openmetrics Validate OpenMetrics integrations disable the metric limit
package Validate Python package metadata and naming
qa-label Validate the pull request declares whether it needs QA for the next Agent release
readmes Validate README files have required sections
saved-views Validate saved view JSON file structure and fields
version Validate version consistency between package and changelog

View full run

@nubtron
nubtron merged commit f702d3b into 7.82.x Jul 20, 2026
48 of 50 checks passed
@nubtron
nubtron deleted the backport-24554-to-7.82.x branch July 20, 2026 12:45
@dd-octo-sts dd-octo-sts Bot added this to the 7.82.0 milestone Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants