Skip to content

Added configurable stats update interval#506

Open
OA6DXV wants to merge 1 commit intortl-airband:unstablefrom
OA6DXV:update-stats-frequency
Open

Added configurable stats update interval#506
OA6DXV wants to merge 1 commit intortl-airband:unstablefrom
OA6DXV:update-stats-frequency

Conversation

@OA6DXV
Copy link
Copy Markdown

@OA6DXV OA6DXV commented Mar 16, 2025

As I mentioned in #505, I am proposing the ability to modify the update interval of the statistics file. Despite the compilation error due to issues in the unstable branch, I am submitting this PR to showcase the necessary code changes to declare the update-stats-frequency variable, which is an integer that defines how many seconds will pass before the file is updated. This file will then be read by Prometheus.

Now, it would only be necessary to add the global variable update-stats-frequency = x; in the configuration file (rtl_airband.conf) so that each user can control the frequency at which the statistics are updated. The modified code still maintains the default 15-second interval if this global variable is not specified, just like the original code does.

The reason for proposing this change is that having the option to configure a shorter update interval and allowing Prometheus to read these values more frequently enables more precise statistics, especially for analyzing signal and noise levels, for example.

Thank you, and I apologize for any mistakes that may exist. I'm not very experienced with Git and pull requests.

char *stats_filepath = NULL;
size_t fft_size_log = DEFAULT_FFT_SIZE_LOG;
size_t fft_size = 1 << fft_size_log;
int stats_update_interval = 15; // Stats update every 15 seconf by default
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
int stats_update_interval = 15; // Stats update every 15 seconf by default
int stats_update_interval = 15; // Stats update every 15 seconds by default

if(root.exists("stats_filepath"))
stats_filepath = strdup(root["stats_filepath"]);
if (root.exists("stats_update_interval")) {
stats_update_interval = (int)root["stats_update_interval"];
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Any validation we should do on the value? Ie, >0?

@charlie-foxtrot
Copy link
Copy Markdown
Collaborator

Note to self - exposing this as a config option can be done along with #515 once config unit tests have been added

@charlie-foxtrot
Copy link
Copy Markdown
Collaborator

Second note to self, consider doing this along with #528

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