Metric: {
    description: string;
    metadata: KeyValue[] | EmptyJsonArray;
    name: string;
    unit: string;
} & MetricData

📊 Defines a Metric which has one or more timeseries.

The core metric definition that includes metadata and the actual metric data. This is a discriminated union that can contain different types of metric data.

Type declaration

  • description: string

    Human-readable description of what this metric measures

  • metadata: KeyValue[] | EmptyJsonArray

    Additional metadata about this metric

  • name: string

    Unique name for this metric

  • unit: string

    Unit of measurement (e.g., "bytes", "seconds", "requests")

// Counter metric
const blocksMinedMetric: Metric = {
name: "blocks_mined_total",
description: "Total blocks mined by this turtle",
unit: "blocks",
sum: {
dataPoints: [
{
attributes: [
{ key: "block.type", value: { stringValue: "minecraft:diamond_ore" } }
],
startTimeUnixNano: "1640995200000000000",
timeUnixNano: "1640995260000000000",
asInt: 42,
exemplars: [],
flags: 0
}
],
aggregationTemporality: AggregationTemporality.CUMULATIVE,
isMonotonic: true
},
metadata: []
};

// Gauge metric
const fuelLevelMetric: Metric = {
name: "fuel_level",
description: "Current fuel level",
unit: "units",
gauge: {
dataPoints: [
{
attributes: [],
startTimeUnixNano: "1640995200000000000",
timeUnixNano: "1640995260000000000",
asInt: 15000,
exemplars: [],
flags: 0
}
]
},
metadata: []
};