Skip to content

Add lazy sampling buffer for lifetime/delta metrics for outputs - #54553

Merged
blakerouse merged 3 commits into
elastic:mainfrom
blakerouse:libbeat-lazy-latency-sample
Nov 16, 2026
Merged

blakerouse merged 3 commits into
elastic:mainfrom
blakerouse:libbeat-lazy-latency-sample

Conversation

@blakerouse

@blakerouse blakerouse commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Proposed commit message

Adds lazySample, a metrics.Sample that creates its backing uniform sample on the first Update. Until then, read-only accessors answer from an empty snapshot and Clear is a no-op. NewStats now uses it for both latency samples.

Running as an OTel receiver does not publish through a libbeat output that calls Stats.ReportLatency, so for every receiver instance that memory is allocated but un-used.

Saves 16KiB per receiver that was always allocated, but never used.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • [ ] I have made corresponding changes to the documentation
  • [ ] I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works. Where relevant, I have used the stresstest.sh script to run them under stress conditions and race detector to verify their stability.
  • I have added an entry in ./changelog/fragments using the changelog tool.

Disruptive User Impact

None

@blakerouse blakerouse self-assigned this Nov 6, 2026
@blakerouse blakerouse added the Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team label Nov 6, 2026
@blakerouse
blakerouse requested a review from a team as a code owner November 6, 2026 22:13
@blakerouse blakerouse added the backport-9.6 Automated backport to the 9.6 branch label Nov 6, 2026
@botelastic botelastic Bot added the needs_team Indicates that the issue/PR needs a Team:* label label Nov 6, 2026
@infra-vault-gh-plugin-prod

Copy link
Copy Markdown

Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane)

@botelastic botelastic Bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Nov 6, 2026
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

🤖 GitHub comments

Just comment with:

  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)
  • /test : Run the Buildkite pipeline.

@mergify

mergify Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

This pull request is merged.

@blakerouse
blakerouse merged commit ae2b45b into elastic:main Nov 16, 2026
220 checks passed
blakerouse added a commit that referenced this pull request Nov 16, 2026
…) (#54726)

Adds lazySample, a metrics.Sample that creates its backing uniform sample on the first Update. Until then, read-only accessors answer from an empty snapshot and Clear is a no-op. NewStats now uses it for both latency samples.

Running as an OTel receiver does not publish through a libbeat output that calls Stats.ReportLatency, so for every receiver instance that memory is allocated but un-used.

Saves 16KiB per receiver that was always allocated, but never used.

(cherry picked from commit ae2b45b)

Co-authored-by: Blake Rouse <blake.rouse@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-9.6 Automated backport to the 9.6 branch Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants