Catalog of metrics and the accompanying data providers to fetch data for them.

MetricCatalog is the central class for dealing with metrics. It stores the definitions of all known metrics and can be used to fetch data for them as needed.

Hierarchy

  • MetricCatalog

Constructors

Properties

dataFetchesCount: number = 0

Count of times that the MetricCatalog has had to fetch data from one or more data providers (e.g. any of the fetchData() methods were called, or a useData() hook was called with new metrics / regions).

Used for debugging / testing.

dataProvidersById: {
    [id: string]: MetricDataProvider;
}

All metric data providers registered with the catalog.

Type declaration

metrics: Metric[]

All metrics in the catalog.

metricsById: {
    [id: string]: Metric;
}

Type declaration

Options associated with the MetricCatalog.

Methods

  • Fetch data for a given region and metric.

    Returns

    The metric data.

    Parameters

    • region: Region

      The region to get data for.

    • metric: string | Metric

      The metric to get data for as either a string or Metric object.

    • includeTimeseries: boolean = false

      Whether to fetch timeseries data or not (default false).

    Returns Promise<MetricData<unknown>>

  • Fetch data for a given region and multiple metrics.

    Returns

    The metric data.

    Parameters

    • region: Region

      The region to get data for.

    • metrics: (string | Metric)[]

      The metrics to get data for as either strings or Metric objects.

    • includeTimeseries: boolean = false

      Whether to fetch timeseries data or not (default false).

    Returns Promise<MultiMetricDataStore<unknown>>

  • Get a metric from the catalog.

    If the ID does not exist in the catalog, an error will be thrown.

    For convenience this method also accepts Metric objects and will just return them as-is.

    Returns

    The metric.

    Parameters

    • metricOrId: string | Metric

      The metric ID (or an existing Metric object). See id.

    Returns Metric

Generated using TypeDoc