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

Refactor metrics to simplify updating the values #187

Merged
merged 11 commits into from
Feb 12, 2024
Merged

Commits on Feb 12, 2024

  1. Refactor metrics to only add callbacks once.

    Use a private data structure to track per-network metrics, then use that data
    structure as data source for the metrics callbacks.  The once-added callbacks
    can then serve the metrics for registered definitions.
    
    In addition to that, when a definition ends, we deregister it from the per-
    network metrics data structure, so we stop serving metrics about it.
    
    We are no longer using Tokio mutexes since this would require async closures
    for the callbacks, and async closures are unstable.  std::sync::Mutex works
    perfectly OK for this use and, in fact, Tokio documentation states that
    standard mutexes can work fine with Tokio code, and should be preferred
    in most cases.
    
    https://docs.rs/tokio/1.24.2/tokio/sync/struct.Mutex.html#which-kind-of-mutex-should-you-use
    indicates we should use the standard mutex when we are not going to hold the
    lock across await points.  Since that is exactly what we are doing (there are
    no awaits involved in the set() and get() code for the data structure being
    locked), then we can simply use the simple blocking mutex, which is what we
    have done here.
    DFINITYManu committed Feb 12, 2024
    Configuration menu
    Copy the full SHA
    4e2ef5c View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    2a6e09b View commit details
    Browse the repository at this point in the history
  3. Update fixme note.

    DFINITYManu committed Feb 12, 2024
    Configuration menu
    Copy the full SHA
    d8549b2 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    6f3dfbf View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    41e6424 View commit details
    Browse the repository at this point in the history
  6. Clippy suggestion.

    DFINITYManu committed Feb 12, 2024
    Configuration menu
    Copy the full SHA
    224b398 View commit details
    Browse the repository at this point in the history
  7. Add a couple of fixmes.

    DFINITYManu committed Feb 12, 2024
    Configuration menu
    Copy the full SHA
    0c39df0 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    eb7ccb3 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    537c34d View commit details
    Browse the repository at this point in the history
  10. Simplify a bit more.

    DFINITYManu committed Feb 12, 2024
    Configuration menu
    Copy the full SHA
    466e8ef View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    f980ec1 View commit details
    Browse the repository at this point in the history