@lodestar/beacon-node
Version:
A Typescript implementation of the beacon chain
76 lines • 2.81 kB
TypeScript
import { Registry } from "prom-client";
import { JsonRecord, JsonType, MetricValue, RecordValue } from "./types.js";
type PropertyDefinition = {
/** Key of value to be sent to remote service */
jsonKey: string;
/** Description of the property */
description?: string;
};
type StaticPropertyDefinition<T extends RecordValue> = PropertyDefinition & {
/** Static value */
value: T;
};
type DynamicPropertyDefinition<T extends RecordValue> = PropertyDefinition & {
/** Value provider function */
provider: () => T;
};
type MetricPropertyDefinition<T extends RecordValue> = PropertyDefinition & {
/** Type of value to be sent to remote service */
jsonType: JsonType;
/** Name of the metric */
metricName: string;
/** Get value from metric with label */
withLabel?: {
name: string;
value: string;
};
/** Get value from label instead of metric value */
fromLabel?: string;
/** Range value to evaluate to true */
rangeValue?: number;
/** Evaluate to true if value is greater than or equal to threshold */
threshold?: number;
/** Function to format retrieved metric value */
formatter?: (value: MetricValue) => MetricValue;
/** Only fetch metric once and then use cached value */
cacheResult?: boolean;
/** Default value if metric does not exist */
defaultValue: T;
};
/**
* Interface to be implemented by client stats properties
*/
export interface ClientStatsProperty<T extends RecordValue> {
readonly definition: PropertyDefinition;
getRecord(register: Registry): JsonRecord<T> | Promise<JsonRecord<T>>;
}
/**
* Static property that can be used to define hard-coded values
*/
export declare class StaticProperty<T extends RecordValue> implements ClientStatsProperty<T> {
readonly definition: StaticPropertyDefinition<T>;
constructor(definition: StaticPropertyDefinition<T>);
getRecord(): JsonRecord<T>;
}
/**
* Dynamic property that can be used to get value from a provider function
*/
export declare class DynamicProperty<T extends RecordValue> implements ClientStatsProperty<T> {
readonly definition: DynamicPropertyDefinition<T>;
constructor(definition: DynamicPropertyDefinition<T>);
getRecord(): JsonRecord<T>;
}
/**
* Metric property that can be used to get value from an existing prometheus metric
*/
export declare class MetricProperty<T extends RecordValue> implements ClientStatsProperty<T> {
readonly definition: MetricPropertyDefinition<T>;
private cachedValue?;
constructor(definition: MetricPropertyDefinition<T>);
getRecord(register: Registry): Promise<JsonRecord<T>>;
private extractMetricValue;
private formatMetricValue;
private convertMetricValue;
}
export {};
//# sourceMappingURL=properties.d.ts.map