MCPcopy Create free account
hub / github.com/Effect-TS/effect / timer

Function timer

packages/effect/src/Metric.ts:2531–2542  ·  view source on GitHub ↗
(name: string, options?: {
  readonly description?: string | undefined
  readonly attributes?: Metric.Attributes | undefined
  readonly boundaries?: ReadonlyArray<number>
})

Source from the content-addressed store, hash-verified

2529 * @since 2.0.0
2530 */
2531export const timer = (name: string, options?: {
2532 readonly description?: string | undefined
2533 readonly attributes?: Metric.Attributes | undefined
2534 readonly boundaries?: ReadonlyArray<number>
2535}): Histogram<Duration.Duration> => {
2536 const boundaries = Predicate.isNotUndefined(options?.boundaries)
2537 ? options.boundaries
2538 : exponentialBoundaries({ start: 0.5, factor: 2, count: 35 })
2539 const attributes = mergeAttributes(options?.attributes, { time_unit: "milliseconds" })
2540 const metric = new HistogramMetric(name, { ...options, boundaries, attributes })
2541 return mapInput(metric, Duration.toMillis)
2542}
2543
2544/**
2545 * Retrieves the current state of the specified `Metric`.

Callers

nothing calls this directly

Calls 2

exponentialBoundariesFunction · 0.85
mergeAttributesFunction · 0.85

Tested by

no test coverage detected