Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic metrics reporting to the memqueue #31703

Merged
merged 8 commits into from
May 31, 2022

Conversation

fearful-symmetry
Copy link
Contributor

What does this PR do?

First step towards #31113

This adds the basic framework for reporting queue metrics to the memqueue in libbeat. Right now this only adds the two most basic metrics, as I wanted to get feedback from @faec and make sure I was on the right track before I got into anything more in-depth.

This also appends a somewhat simplistic change to an existing test, which should probably be broken into a separate test on its own later.

Why is it important?

This helps address the queue metrics defined in #31113

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
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

@fearful-symmetry fearful-symmetry added enhancement Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team labels May 20, 2022
@fearful-symmetry fearful-symmetry requested a review from faec May 20, 2022 22:44
@fearful-symmetry fearful-symmetry self-assigned this May 20, 2022
@botelastic botelastic bot added needs_team Indicates that the issue/PR needs a Team:* label and removed needs_team Indicates that the issue/PR needs a Team:* label labels May 20, 2022
@fearful-symmetry fearful-symmetry changed the title Memqueue metrics Add basic metrics reporting to the memqueue May 20, 2022
@elasticmachine
Copy link
Collaborator

elasticmachine commented May 20, 2022

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2022-05-31T17:38:50.772+0000

  • Duration: 74 min 27 sec

Test stats 🧪

Test Results
Failed 0
Passed 22256
Skipped 1935
Total 24191

💚 Flaky test report

Tests succeeded.

🤖 GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • /package : Generate the packages and run the E2E tests.

  • /beats-tester : Run the installation tests with beats-tester.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@fearful-symmetry fearful-symmetry marked this pull request as ready for review May 23, 2022 20:29
@fearful-symmetry fearful-symmetry requested a review from a team as a code owner May 23, 2022 20:29
@fearful-symmetry fearful-symmetry requested review from cmacknz and removed request for a team May 23, 2022 20:29
@elasticmachine
Copy link
Collaborator

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

@mergify
Copy link
Contributor

mergify bot commented May 26, 2022

This pull request is now in conflicts. Could you fix it? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b memqueue-metrics upstream/memqueue-metrics
git merge upstream/main
git push upstream memqueue-metrics

case schedACKs <- l.pendingACKs:
// on send complete list of pending batches has been forwarded -> clear list
l.pendingACKs = chanList{}
}
}
}

func (l *directEventLoop) handleMetricsRequest(req *metricsRequest) {
req.responseChan <- memQueueMetrics{currentQueueSize: len(l.buf.entries)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

len(l.buf.entries) returns the total capacity of the queue, not its current number of events. The current event count (including events that have been read by consumers but not yet acked/removed from the queue) would be l.buf.regA.size + l.buf.regB.size (it probably makes sense to make this a helper function on ringBuffer since it's not obvious).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is indeed not obvious, thanks. :D

@cmacknz
Copy link
Member

cmacknz commented May 31, 2022

Update or rebase with main to fix the CI build errors.

@fearful-symmetry fearful-symmetry merged commit a160e52 into elastic:main May 31, 2022
chrisberkhout pushed a commit that referenced this pull request Jun 1, 2023
* first pass at having the memqueue report metrics

* add sort of a test

* format

* fix length for ring buffer, clean up tests

* add tests, occupiedRead

* change field names, separate tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement 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.

4 participants