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

Function hook

packages/effect/src/Metric.ts:1686–1703  ·  view source on GitHub ↗
(context: Context.Context<never>)

Source from the content-addressed store, hash-verified

1684 abstract createHooks(): Metric.Hooks<Input, State>
1685
1686 hook(context: Context.Context<never>): Metric.Hooks<Input, State> {
1687 const extraAttributes = Context.get(context, CurrentMetricAttributes)
1688 if (Object.keys(extraAttributes).length === 0) {
1689 if (Predicate.isNotUndefined(this.#metadata)) {
1690 return this.#metadata.hooks
1691 }
1692 this.#metadata = this.getOrCreate(context, this.attributes)
1693 return this.#metadata.hooks
1694 }
1695 const mergedAttributes = mergeAttributes(this.attributes, extraAttributes)
1696 let metadata = this.#metadataCache.get(mergedAttributes)
1697 if (Predicate.isNotUndefined(metadata)) {
1698 return metadata.hooks
1699 }
1700 metadata = this.getOrCreate(context, mergedAttributes)
1701 this.#metadataCache.set(mergedAttributes, metadata)
1702 return metadata.hooks
1703 }
1704
1705 getOrCreate(
1706 context: Context.Context<never>,

Callers

nothing calls this directly

Calls 3

mergeAttributesFunction · 0.85
getMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected