Skip to content

GetLatestStatistics fetches 100 rows to return one #37

Description

@lludlow

Problem

NetworkService.GetLatestStatistics calls GetStatistics, which requests /vnet_monitor_stats_history_short with sort=-timestamp&limit=100, then returns only stats[0]. Every "latest" lookup transfers 100 rows to use one.

For consumers polling latest stats for many networks per scrape (e.g. the exporter's VNetCollector, verge-io/vergeos-exporter#53), that's 100x the necessary payload per network. The exporter bounds this with concurrency, but the per-request waste remains.

Request

Either:

  • Make GetLatestStatistics issue its own query with limit=1 (same filter/sort), or
  • Add a bulk variant, e.g. GetLatestStatisticsAll(ctx) (map[int]NetworkMonitorStats, error), that fetches the latest row per vnet in one request — this would let the exporter drop the per-network fan-out entirely.

The bulk variant is the more valuable of the two if the API can express it.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions