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

Make separate goroutines for metrics collection method calls #66

Closed

Conversation

panigs7
Copy link
Contributor

@panigs7 panigs7 commented Nov 7, 2023

Description

Currently, if there is delay in collection of metrics, then the time interval set for metrics collection is not honored.
Made the metrics collection method as separate goroutines which which shoot new method call in spite of delayed metrics collection response.

GitHub Issues

List the GitHub issues impacted by this PR:

GitHub Issue #
dell/csm#1012

Checklist:

  • I have performed a self-review of my own code to ensure there are no formatting, vetting, linting, or security issues
  • I have verified that new and existing unit tests pass locally with my changes
  • I have not allowed coverage numbers to degenerate
  • I have maintained at least 90% code coverage
  • I have inspected the Grafana dashboards to verify the data is displayed properly
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • I have maintained backward compatibility

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Please also list any relevant details for your test configuration

-Unit tests:
image

  • Added a time delay > time interval set for metrics collection. For example, volumePollFrequencySeconds: 20
    and time delay introduced in the respective method is 30s. Observation is calls to metric collection is made after every 20s.
    image

@csmbot
Copy link
Collaborator

csmbot commented Nov 7, 2023

Can one of the admins verify this patch?

Copy link
Contributor

@donatwork donatwork left a comment

Choose a reason for hiding this comment

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

This may not be the correct approach.

  1. You now have new WaitGroups every time a timer event fires. I don't see where wg.Wait() sis being called. Do you really need the WaitGroup?
  2. Also you will end up having lots of goroutines in the case of volume collection, if the volume collection takes longer than the interval.
  3. Each goroutine will/could run in parallel and hence exceed the concurrency limit as the semaphore is implemented as a channel, and each metrics export method has its own private channel. You want a single semaphore for all goroutines so that all methods, if run in parallel will not exceed the concurrency limit. Take a look at how the concurrency is designed in the Export* methods to understand.

Please explain the intent of your implementation.

A better approach is to run each Export method in its own goroutine with the timer in their respective goroutine. Each goroutine uses the same semaphore for concurrent connections.

@panigs7 panigs7 closed this Nov 7, 2023
@panigs7 panigs7 reopened this Nov 7, 2023
@panigs7
Copy link
Contributor Author

panigs7 commented Nov 7, 2023

Closed the PR by mistake. Reopened it

@panigs7 panigs7 closed this Nov 10, 2023
@anandrajak1 anandrajak1 deleted the bugfix-honour-time-intervals-of-metrics-collection branch October 17, 2024 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants