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

Function getOrCreate

packages/effect/src/Metric.ts:1705–1724  ·  view source on GitHub ↗
(
    context: Context.Context<never>,
    attributes: Metric.Attributes | undefined
  )

Source from the content-addressed store, hash-verified

1703 }
1704
1705 getOrCreate(
1706 context: Context.Context<never>,
1707 attributes: Metric.Attributes | undefined
1708 ): Metric.Metadata<Input, State> {
1709 const key = makeKey(this, attributes)
1710 const registry = Context.get(context, MetricRegistry)
1711 if (registry.has(key)) {
1712 return registry.get(key)!
1713 }
1714 const hooks = this.createHooks()
1715 const meta: Metric.Metadata<Input, State> = {
1716 id: this.id,
1717 type: this.type,
1718 description: this.description,
1719 attributes: attributesToRecord(attributes),
1720 hooks
1721 }
1722 registry.set(key, meta)
1723 return meta
1724 }
1725
1726 pipe() {
1727 return pipeArguments(this, arguments)

Callers

nothing calls this directly

Calls 6

makeKeyFunction · 0.85
attributesToRecordFunction · 0.85
getMethod · 0.65
setMethod · 0.65
hasMethod · 0.45
createHooksMethod · 0.45

Tested by

no test coverage detected