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

[pull] master from netdata:master #286

Merged
merged 4 commits into from
Jan 10, 2025
Merged

Conversation

pull[bot]
Copy link

@pull pull bot commented Jan 10, 2025

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.1)

Can you help keep this open source service alive? 💖 Please sponsor : )

Summary by Sourcery

Update the metrics cardinality API and improve cache handling.

New Features:

  • Add "group" parameter to the /api/v1/metrics_cardinality endpoint to allow grouping metrics by context or node.

Tests:

  • Update tests to reflect changes in /api/v1/metrics_cardinality API.

ktsaou and others added 4 commits January 10, 2025 15:17
* added percentages

* added grouping by context and by node
fix for wanted_cache_size getting to zero
libunwind does not work well after fork, so we disable stack traces on forked processes
@pull pull bot added the ⤵️ pull label Jan 10, 2025
@pull pull bot merged commit f9512b1 into webfutureiorepo:master Jan 10, 2025
Copy link

sourcery-ai bot commented Jan 10, 2025

Reviewer's Guide by Sourcery

This pull request introduces several enhancements to Netdata's metrics cardinality function and addresses a few issues related to logging and caching.

Class diagram for updated metrics cardinality structure

classDiagram
    class counts {
        +size_t nodes
        +size_t instances
        +size_t metrics
        +size_t online_nodes
        +size_t offline_nodes
        +size_t online_instances
        +size_t offline_instances
        +size_t online_metrics
        +size_t offline_metrics
    }
    note for counts "Renamed from context_counts"
Loading

State diagram for stack trace handling

stateDiagram-v2
    [*] --> CheckFork
    CheckFork --> Disabled: Forked
    CheckFork --> CheckRecursion: Not Forked
    CheckRecursion --> Error: In Stack Trace
    CheckRecursion --> Trace: Not in Stack Trace
    Trace --> Cleanup
    Error --> [*]
    Disabled --> [*]
    Cleanup --> [*]
Loading

Flow diagram for metrics cardinality function

flowchart TD
    A[Start] --> B[Parse function parameters]
    B --> C{Group by node?}
    C -->|Yes| D[Use hostname as key]
    C -->|No| E[Use context as key]
    D --> F[Collect stats]
    E --> F
    F --> G[Calculate percentages]
    G --> H[Generate JSON output]
    H --> I[End]

    note[Update every 10s instead of 1s]
Loading

File-Level Changes

Change Details Files
Added grouping functionality to the metrics cardinality function. This allows users to group metrics by context or by node.
  • Added new parameters to the API to support grouping by context or node.
  • Updated the function to handle the new grouping parameters.
  • Added percentage calculations for instances and metrics based on the grouping selection.
  • Added more fields to the output table to display the percentage information.
  • Adjusted the update frequency from 1 second to 10 seconds.
src/web/api/functions/function-metrics-cardinality.c
Disabled stack trace generation after a fork to prevent libunwind from freezing.
  • Added a flag to indicate whether the process has been forked.
  • Modified the stack trace formatter to check the forked flag and return early if set.
  • Set the forked flag in the nd_log_reopen_log_files_for_spawn_server function.
  • Added necessary declarations and definitions for the forked flag.
src/libnetdata/log/nd_log-libunwind.c
src/libnetdata/log/nd_log-init.c
src/libnetdata/log/nd_log-internals.h
Fixed a bug in the metadata handling where the iterator was not reset correctly after deleting an alarm entry.
  • Corrected the value of the first variable in the after_metadata_hosts function to ensure proper iteration after deletion.
src/database/sqlite/sqlite_metadata.c
Added a lower bound to the wanted cache size to prevent issues when the cache is empty.
  • Added a check to ensure the wanted cache size is not less than 64KB. If it is, set it to 64KB.
src/database/engine/cache.c
Added a null check for the server parameter in the spawn_server_exec function.
  • Added a null check for the server parameter to prevent potential crashes if the server is null.
src/libnetdata/spawn_server/spawn_server_nofork.c

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

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