effect-io-ai

Package: effect
Module: Metric

Metric.isMetric

Returns true if the specified value is a Metric, otherwise returns false.

When to use

Use when you need runtime type checking and ensuring that a value conforms to the Metric interface before performing metric operations.

Example (Checking metric values)

import { Metric } from "effect"

const counter = Metric.counter("requests")
const gauge = Metric.gauge("temperature")
const notAMetric = { name: "fake-metric" }

console.log(Metric.isMetric(counter)) // true
console.log(Metric.isMetric(gauge)) // true
console.log(Metric.isMetric(notAMetric)) // false
console.log(Metric.isMetric(null)) // false

Signature

declare const isMetric: (u: unknown) => u is Metric<unknown, never>

Source

Since v4.0.0