docs/docs/en/api/telemetry/metric.md
constructor()Constructor to create a Metric instance.
constructor(options?: MetricOptions)export type MetricOptions = {
meterName?: string;
version?: string;
readerName?: string | string[];
};
| Property | Type | Description | Default Value |
|---|---|---|---|
meterName | string | Meter identifier | nocobase-meter |
version | string | Current version of NocoBase | |
readerName | string | string[] | Identifier(s) of registered MetricReader to use | - |
init()Initializes MetricProvider.
init(): voidregisterReader()Registers a MetricReader.
registerReader(name: string, reader: GetMetricReader)import { MetricReader } from '@opentelemetry/sdk-metrics';
type GetMetricReader = () => MetricReader;
| Parameter | Type | Description |
|---|---|---|
name | string | Unique identifier for MetricReader |
reader | () => MetricReader | Function to get MetricReader |
addView()Adds a View. Refer to Configure Metric Views.
addView(...view: View[])import { View } from '@opentelemetry/sdk-metrics';
getMeter()Gets the Meter.
getMeter(name?: string, version?: string)| Parameter | Type | Description | Default Value |
|---|---|---|---|
name | string | Meter identifier | nocobase-meter |
version | string | Current version of NocoBase |
start()Starts the MetricReader.
start(): voidshutdown()Stops the MetricReader.
shutdown(): Promise<void>