@libp2p/interface-metrics
Advanced tools
Comparing version 1.0.3 to 2.0.0
@@ -97,8 +97,58 @@ import type { PeerId } from '@libp2p/interface-peer-id'; | ||
} | ||
/** | ||
* Used to update a tracked metric. Value can either be a number, an object containing | ||
* key/value pairs or an (optionally async) function to return a number or an object of | ||
* key/value pairs. | ||
*/ | ||
export interface ComponentMetricsUpdate { | ||
/** | ||
* Name of the system, e.g. libp2p, ipfs, etc | ||
*/ | ||
system: string; | ||
/** | ||
* Name of the system component that contains the metric | ||
*/ | ||
component: string; | ||
/** | ||
* Name of the metric being tracked | ||
*/ | ||
metric: string; | ||
value: number; | ||
/** | ||
* The value or function to calculate the value | ||
*/ | ||
value: ComponentMetric | CalculateComponentMetric; | ||
/** | ||
* Optional label for the metric | ||
*/ | ||
label?: string; | ||
/** | ||
* Optional help for the metric | ||
*/ | ||
help?: string; | ||
} | ||
export declare type ComponentMetric = number | ComponentMetricsGroup; | ||
/** | ||
* Used to group related metrics together by label and value | ||
*/ | ||
export declare type ComponentMetricsGroup = Record<string, number>; | ||
/** | ||
* Used to calculate metric values dynamically | ||
*/ | ||
export interface CalculateComponentMetric { | ||
(): Promise<ComponentMetric> | ComponentMetric; | ||
} | ||
export interface TrackedMetric { | ||
/** | ||
* In systems that support them, this label can help make graphs more interpretable | ||
*/ | ||
label?: string; | ||
/** | ||
* In systems that support them, this help text can help make graphs more interpretable | ||
*/ | ||
help?: string; | ||
/** | ||
* A function that returns a value or a group of values | ||
*/ | ||
calculate: CalculateComponentMetric; | ||
} | ||
export interface ComponentMetricsTracker { | ||
@@ -108,3 +158,3 @@ /** | ||
*/ | ||
getComponentMetrics: () => Map<string, Map<string, Map<string, number>>>; | ||
getComponentMetrics: () => Map<string, Map<string, Map<string, TrackedMetric>>>; | ||
/** | ||
@@ -111,0 +161,0 @@ * Update the stored metric value for the given system and component |
{ | ||
"name": "@libp2p/interface-metrics", | ||
"version": "1.0.3", | ||
"version": "2.0.0", | ||
"description": "Metrics interface for libp2p", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0 OR MIT", |
@@ -117,9 +117,68 @@ import type { PeerId } from '@libp2p/interface-peer-id' | ||
/** | ||
* Used to update a tracked metric. Value can either be a number, an object containing | ||
* key/value pairs or an (optionally async) function to return a number or an object of | ||
* key/value pairs. | ||
*/ | ||
export interface ComponentMetricsUpdate { | ||
/** | ||
* Name of the system, e.g. libp2p, ipfs, etc | ||
*/ | ||
system: string | ||
/** | ||
* Name of the system component that contains the metric | ||
*/ | ||
component: string | ||
/** | ||
* Name of the metric being tracked | ||
*/ | ||
metric: string | ||
value: number | ||
/** | ||
* The value or function to calculate the value | ||
*/ | ||
value: ComponentMetric | CalculateComponentMetric | ||
/** | ||
* Optional label for the metric | ||
*/ | ||
label?: string | ||
/** | ||
* Optional help for the metric | ||
*/ | ||
help?: string | ||
} | ||
export type ComponentMetric = number | ComponentMetricsGroup | ||
/** | ||
* Used to group related metrics together by label and value | ||
*/ | ||
export type ComponentMetricsGroup = Record<string, number> | ||
/** | ||
* Used to calculate metric values dynamically | ||
*/ | ||
export interface CalculateComponentMetric { (): Promise<ComponentMetric> | ComponentMetric } | ||
export interface TrackedMetric { | ||
/** | ||
* In systems that support them, this label can help make graphs more interpretable | ||
*/ | ||
label?: string | ||
/** | ||
* In systems that support them, this help text can help make graphs more interpretable | ||
*/ | ||
help?: string | ||
/** | ||
* A function that returns a value or a group of values | ||
*/ | ||
calculate: CalculateComponentMetric | ||
} | ||
export interface ComponentMetricsTracker { | ||
@@ -129,3 +188,3 @@ /** | ||
*/ | ||
getComponentMetrics: () => Map<string, Map<string, Map<string, number>>> | ||
getComponentMetrics: () => Map<string, Map<string, Map<string, TrackedMetric>>> | ||
@@ -132,0 +191,0 @@ /** |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17890
327