Hyperlinkv0.8.0-beta.28

Metric

Metric.isMetricconsteffect/Metric.ts:2113
(u: unknown): u is Metric<unknown, never>

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
guards
Source effect/Metric.ts:21132 lines
export const isMetric = (u: unknown): u is Metric<unknown, never> =>
  Predicate.hasProperty(u, "~effect/Metric") && u["~effect/Metric"] === "~effect/Metric"