Erster Docker-Stand

This commit is contained in:
Ali
2026-02-20 16:06:40 +09:00
commit f31e2e8ed3
8818 changed files with 1605323 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
import * as Arr from "../../Array.js";
import * as Chunk from "../../Chunk.js";
import * as Equal from "../../Equal.js";
import { pipe } from "../../Function.js";
import * as Hash from "../../Hash.js";
import { pipeArguments } from "../../Pipeable.js";
import { hasProperty } from "../../Predicate.js";
/** @internal */
const MetricBoundariesSymbolKey = "effect/MetricBoundaries";
/** @internal */
export const MetricBoundariesTypeId = /*#__PURE__*/Symbol.for(MetricBoundariesSymbolKey);
/** @internal */
class MetricBoundariesImpl {
values;
[MetricBoundariesTypeId] = MetricBoundariesTypeId;
constructor(values) {
this.values = values;
this._hash = pipe(Hash.string(MetricBoundariesSymbolKey), Hash.combine(Hash.array(this.values)));
}
_hash;
[Hash.symbol]() {
return this._hash;
}
[Equal.symbol](u) {
return isMetricBoundaries(u) && Equal.equals(this.values, u.values);
}
pipe() {
return pipeArguments(this, arguments);
}
}
/** @internal */
export const isMetricBoundaries = u => hasProperty(u, MetricBoundariesTypeId);
/** @internal */
export const fromIterable = iterable => {
const values = pipe(iterable, Arr.appendAll(Chunk.of(Number.POSITIVE_INFINITY)), Arr.dedupe);
return new MetricBoundariesImpl(values);
};
/** @internal */
export const linear = options => pipe(Arr.makeBy(options.count - 1, i => options.start + i * options.width), Chunk.unsafeFromArray, fromIterable);
/** @internal */
export const exponential = options => pipe(Arr.makeBy(options.count - 1, i => options.start * Math.pow(options.factor, i)), Chunk.unsafeFromArray, fromIterable);
//# sourceMappingURL=boundaries.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"boundaries.js","names":["Arr","Chunk","Equal","pipe","Hash","pipeArguments","hasProperty","MetricBoundariesSymbolKey","MetricBoundariesTypeId","Symbol","for","MetricBoundariesImpl","values","constructor","_hash","string","combine","array","symbol","u","isMetricBoundaries","equals","arguments","fromIterable","iterable","appendAll","of","Number","POSITIVE_INFINITY","dedupe","linear","options","makeBy","count","i","start","width","unsafeFromArray","exponential","Math","pow","factor"],"sources":["../../../../src/internal/metric/boundaries.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAO,KAAKA,GAAG,MAAM,gBAAgB;AACrC,OAAO,KAAKC,KAAK,MAAM,gBAAgB;AACvC,OAAO,KAAKC,KAAK,MAAM,gBAAgB;AACvC,SAASC,IAAI,QAAQ,mBAAmB;AACxC,OAAO,KAAKC,IAAI,MAAM,eAAe;AAErC,SAASC,aAAa,QAAQ,mBAAmB;AACjD,SAASC,WAAW,QAAQ,oBAAoB;AAEhD;AACA,MAAMC,yBAAyB,GAAG,yBAAyB;AAE3D;AACA,OAAO,MAAMC,sBAAsB,gBAA4CC,MAAM,CAACC,GAAG,CACvFH,yBAAyB,CACiB;AAE5C;AACA,MAAMI,oBAAoB;EAEHC,MAAA;EADZ,CAACJ,sBAAsB,IAA6CA,sBAAsB;EACnGK,YAAqBD,MAA6B;IAA7B,KAAAA,MAAM,GAANA,MAAM;IACzB,IAAI,CAACE,KAAK,GAAGX,IAAI,CACfC,IAAI,CAACW,MAAM,CAACR,yBAAyB,CAAC,EACtCH,IAAI,CAACY,OAAO,CAACZ,IAAI,CAACa,KAAK,CAAC,IAAI,CAACL,MAAM,CAAC,CAAC,CACtC;EACH;EACSE,KAAK;EACd,CAACV,IAAI,CAACc,MAAM,IAAC;IACX,OAAO,IAAI,CAACJ,KAAK;EACnB;EACA,CAACZ,KAAK,CAACgB,MAAM,EAAEC,CAAU;IACvB,OAAOC,kBAAkB,CAACD,CAAC,CAAC,IAAIjB,KAAK,CAACmB,MAAM,CAAC,IAAI,CAACT,MAAM,EAAEO,CAAC,CAACP,MAAM,CAAC;EACrE;EACAT,IAAIA,CAAA;IACF,OAAOE,aAAa,CAAC,IAAI,EAAEiB,SAAS,CAAC;EACvC;;AAGF;AACA,OAAO,MAAMF,kBAAkB,GAAID,CAAU,IAC3Cb,WAAW,CAACa,CAAC,EAAEX,sBAAsB,CAAC;AAExC;AACA,OAAO,MAAMe,YAAY,GAAIC,QAA0B,IAAuC;EAC5F,MAAMZ,MAAM,GAAGT,IAAI,CACjBqB,QAAQ,EACRxB,GAAG,CAACyB,SAAS,CAACxB,KAAK,CAACyB,EAAE,CAACC,MAAM,CAACC,iBAAiB,CAAC,CAAC,EACjD5B,GAAG,CAAC6B,MAAM,CACX;EACD,OAAO,IAAIlB,oBAAoB,CAACC,MAAM,CAAC;AACzC,CAAC;AAED;AACA,OAAO,MAAMkB,MAAM,GAAIC,OAItB,IACC5B,IAAI,CACFH,GAAG,CAACgC,MAAM,CAACD,OAAO,CAACE,KAAK,GAAG,CAAC,EAAGC,CAAC,IAAKH,OAAO,CAACI,KAAK,GAAGD,CAAC,GAAGH,OAAO,CAACK,KAAK,CAAC,EACvEnC,KAAK,CAACoC,eAAe,EACrBd,YAAY,CACb;AAEH;AACA,OAAO,MAAMe,WAAW,GAAIP,OAI3B,IACC5B,IAAI,CACFH,GAAG,CAACgC,MAAM,CAACD,OAAO,CAACE,KAAK,GAAG,CAAC,EAAGC,CAAC,IAAKH,OAAO,CAACI,KAAK,GAAGI,IAAI,CAACC,GAAG,CAACT,OAAO,CAACU,MAAM,EAAEP,CAAC,CAAC,CAAC,EACjFjC,KAAK,CAACoC,eAAe,EACrBd,YAAY,CACb","ignoreList":[]}

375
_node_modules/effect/dist/esm/internal/metric/hook.js generated vendored Normal file
View File

@@ -0,0 +1,375 @@
import * as Arr from "../../Array.js";
import * as Duration from "../../Duration.js";
import { dual, pipe } from "../../Function.js";
import * as number from "../../Number.js";
import * as Option from "../../Option.js";
import { pipeArguments } from "../../Pipeable.js";
import * as metricState from "./state.js";
/** @internal */
const MetricHookSymbolKey = "effect/MetricHook";
/** @internal */
export const MetricHookTypeId = /*#__PURE__*/Symbol.for(MetricHookSymbolKey);
const metricHookVariance = {
/* c8 ignore next */
_In: _ => _,
/* c8 ignore next */
_Out: _ => _
};
/** @internal */
export const make = options => ({
[MetricHookTypeId]: metricHookVariance,
pipe() {
return pipeArguments(this, arguments);
},
...options
});
/** @internal */
export const onModify = /*#__PURE__*/dual(2, (self, f) => ({
[MetricHookTypeId]: metricHookVariance,
pipe() {
return pipeArguments(this, arguments);
},
get: self.get,
update: self.update,
modify: input => {
self.modify(input);
return f(input);
}
}));
/** @internal */
export const onUpdate = /*#__PURE__*/dual(2, (self, f) => ({
[MetricHookTypeId]: metricHookVariance,
pipe() {
return pipeArguments(this, arguments);
},
get: self.get,
update: input => {
self.update(input);
return f(input);
},
modify: self.modify
}));
const bigint0 = /*#__PURE__*/BigInt(0);
/** @internal */
export const counter = key => {
let sum = key.keyType.bigint ? bigint0 : 0;
const canUpdate = key.keyType.incremental ? key.keyType.bigint ? value => value >= bigint0 : value => value >= 0 : _value => true;
const update = value => {
if (canUpdate(value)) {
sum = sum + value;
}
};
return make({
get: () => metricState.counter(sum),
update,
modify: update
});
};
/** @internal */
export const frequency = key => {
const values = new Map();
for (const word of key.keyType.preregisteredWords) {
values.set(word, 0);
}
const update = word => {
const slotCount = values.get(word) ?? 0;
values.set(word, slotCount + 1);
};
return make({
get: () => metricState.frequency(values),
update,
modify: update
});
};
/** @internal */
export const gauge = (_key, startAt) => {
let value = startAt;
return make({
get: () => metricState.gauge(value),
update: v => {
value = v;
},
modify: v => {
value = value + v;
}
});
};
/** @internal */
export const histogram = key => {
const bounds = key.keyType.boundaries.values;
const size = bounds.length;
const values = new Uint32Array(size + 1);
// NOTE: while 64-bit floating point precision shoule be enough for any
// practical histogram boundary values, there is still a small chance that
// precision will be lost with very large / very small numbers. If we find
// that is the case, a more complex approach storing the histogram boundary
// values as a tuple of `[original: string, numeric: number]` may be warranted
const boundaries = new Float64Array(size);
let count = 0;
let sum = 0;
let min = Number.MAX_VALUE;
let max = Number.MIN_VALUE;
pipe(bounds, Arr.sort(number.Order), Arr.map((n, i) => {
boundaries[i] = n;
}));
// Insert the value into the right bucket with a binary search
const update = value => {
let from = 0;
let to = size;
while (from !== to) {
const mid = Math.floor(from + (to - from) / 2);
const boundary = boundaries[mid];
if (value <= boundary) {
to = mid;
} else {
from = mid;
}
// The special case when to / from have a distance of one
if (to === from + 1) {
if (value <= boundaries[from]) {
to = from;
} else {
from = to;
}
}
}
values[from] = values[from] + 1;
count = count + 1;
sum = sum + value;
if (value < min) {
min = value;
}
if (value > max) {
max = value;
}
};
const getBuckets = () => {
const builder = Arr.allocate(size);
let cumulated = 0;
for (let i = 0; i < size; i++) {
const boundary = boundaries[i];
const value = values[i];
cumulated = cumulated + value;
builder[i] = [boundary, cumulated];
}
return builder;
};
return make({
get: () => metricState.histogram({
buckets: getBuckets(),
count,
min,
max,
sum
}),
update,
modify: update
});
};
/** @internal */
export const summary = key => {
const {
error,
maxAge,
maxSize,
quantiles
} = key.keyType;
const sortedQuantiles = pipe(quantiles, Arr.sort(number.Order));
const values = Arr.allocate(maxSize);
let head = 0;
let count = 0;
let sum = 0;
let min = 0;
let max = 0;
// Just before the snapshot we filter out all values older than maxAge
const snapshot = now => {
const builder = [];
// If the buffer is not full yet it contains valid items at the 0..last
// indices and null values at the rest of the positions.
//
// If the buffer is already full then all elements contains a valid
// measurement with timestamp.
//
// At any given point in time we can enumerate all the non-null elements in
// the buffer and filter them by timestamp to get a valid view of a time
// window.
//
// The order does not matter because it gets sorted before passing to
// `calculateQuantiles`.
let i = 0;
while (i !== maxSize - 1) {
const item = values[i];
if (item != null) {
const [t, v] = item;
const age = Duration.millis(now - t);
if (Duration.greaterThanOrEqualTo(age, Duration.zero) && Duration.lessThanOrEqualTo(age, maxAge)) {
builder.push(v);
}
}
i = i + 1;
}
return calculateQuantiles(error, sortedQuantiles, Arr.sort(builder, number.Order));
};
const observe = (value, timestamp) => {
if (maxSize > 0) {
head = head + 1;
const target = head % maxSize;
values[target] = [timestamp, value];
}
min = count === 0 ? value : Math.min(min, value);
max = count === 0 ? value : Math.max(max, value);
count = count + 1;
sum = sum + value;
};
return make({
get: () => metricState.summary({
error,
quantiles: snapshot(Date.now()),
count,
min,
max,
sum
}),
update: ([value, timestamp]) => observe(value, timestamp),
modify: ([value, timestamp]) => observe(value, timestamp)
});
};
/** @internal */
const calculateQuantiles = (error, sortedQuantiles, sortedSamples) => {
// The number of samples examined
const sampleCount = sortedSamples.length;
if (!Arr.isNonEmptyReadonlyArray(sortedQuantiles)) {
return Arr.empty();
}
const head = sortedQuantiles[0];
const tail = sortedQuantiles.slice(1);
const resolvedHead = resolveQuantile(error, sampleCount, Option.none(), 0, head, sortedSamples);
const resolved = Arr.of(resolvedHead);
tail.forEach(quantile => {
resolved.push(resolveQuantile(error, sampleCount, resolvedHead.value, resolvedHead.consumed, quantile, resolvedHead.rest));
});
return Arr.map(resolved, rq => [rq.quantile, rq.value]);
};
/** @internal */
const resolveQuantile = (error, sampleCount, current, consumed, quantile, rest) => {
let error_1 = error;
let sampleCount_1 = sampleCount;
let current_1 = current;
let consumed_1 = consumed;
let quantile_1 = quantile;
let rest_1 = rest;
let error_2 = error;
let sampleCount_2 = sampleCount;
let current_2 = current;
let consumed_2 = consumed;
let quantile_2 = quantile;
let rest_2 = rest;
// eslint-disable-next-line no-constant-condition
while (1) {
// If the remaining list of samples is empty, there is nothing more to resolve
if (!Arr.isNonEmptyReadonlyArray(rest_1)) {
return {
quantile: quantile_1,
value: Option.none(),
consumed: consumed_1,
rest: []
};
}
// If the quantile is the 100% quantile, we can take the maximum of all the
// remaining values as the result
if (quantile_1 === 1) {
return {
quantile: quantile_1,
value: Option.some(Arr.lastNonEmpty(rest_1)),
consumed: consumed_1 + rest_1.length,
rest: []
};
}
// Split into two chunks - the first chunk contains all elements of the same
// value as the chunk head
const headValue = Arr.headNonEmpty(rest_1); // Get head value since rest_1 is non-empty
const sameHead = Arr.span(rest_1, n => n === headValue);
// How many elements do we want to accept for this quantile
const desired = quantile_1 * sampleCount_1;
// The error margin
const allowedError = error_1 / 2 * desired;
// Taking into account the elements consumed from the samples so far and the
// number of same elements at the beginning of the chunk, calculate the number
// of elements we would have if we selected the current head as result
const candConsumed = consumed_1 + sameHead[0].length;
const candError = Math.abs(candConsumed - desired);
// If we haven't got enough elements yet, recurse
if (candConsumed < desired - allowedError) {
error_2 = error_1;
sampleCount_2 = sampleCount_1;
current_2 = Arr.head(rest_1);
consumed_2 = candConsumed;
quantile_2 = quantile_1;
rest_2 = sameHead[1];
error_1 = error_2;
sampleCount_1 = sampleCount_2;
current_1 = current_2;
consumed_1 = consumed_2;
quantile_1 = quantile_2;
rest_1 = rest_2;
continue;
}
// If consuming this chunk leads to too many elements (rank is too high)
if (candConsumed > desired + allowedError) {
const valueToReturn = Option.isNone(current_1) ? Option.some(headValue) : current_1;
return {
quantile: quantile_1,
value: valueToReturn,
consumed: consumed_1,
rest: rest_1
};
}
// If we are in the target interval, select the current head and hand back the leftover after dropping all elements
// from the sample chunk that are equal to the current head
switch (current_1._tag) {
case "None":
{
error_2 = error_1;
sampleCount_2 = sampleCount_1;
current_2 = Arr.head(rest_1);
consumed_2 = candConsumed;
quantile_2 = quantile_1;
rest_2 = sameHead[1];
error_1 = error_2;
sampleCount_1 = sampleCount_2;
current_1 = current_2;
consumed_1 = consumed_2;
quantile_1 = quantile_2;
rest_1 = rest_2;
continue;
}
case "Some":
{
const prevError = Math.abs(desired - current_1.value);
if (candError < prevError) {
error_2 = error_1;
sampleCount_2 = sampleCount_1;
current_2 = Arr.head(rest_1);
consumed_2 = candConsumed;
quantile_2 = quantile_1;
rest_2 = sameHead[1];
error_1 = error_2;
sampleCount_1 = sampleCount_2;
current_1 = current_2;
consumed_1 = consumed_2;
quantile_1 = quantile_2;
rest_1 = rest_2;
continue;
}
return {
quantile: quantile_1,
value: Option.some(current_1.value),
consumed: consumed_1,
rest: rest_1
};
}
}
}
throw new Error("BUG: MetricHook.resolveQuantiles - please report an issue at https://github.com/Effect-TS/effect/issues");
};
//# sourceMappingURL=hook.js.map

File diff suppressed because one or more lines are too long

60
_node_modules/effect/dist/esm/internal/metric/key.js generated vendored Normal file
View File

@@ -0,0 +1,60 @@
import * as Arr from "../../Array.js";
import * as Equal from "../../Equal.js";
import { dual, pipe } from "../../Function.js";
import * as Hash from "../../Hash.js";
import * as Option from "../../Option.js";
import { pipeArguments } from "../../Pipeable.js";
import { hasProperty } from "../../Predicate.js";
import * as metricKeyType from "./keyType.js";
import * as metricLabel from "./label.js";
/** @internal */
const MetricKeySymbolKey = "effect/MetricKey";
/** @internal */
export const MetricKeyTypeId = /*#__PURE__*/Symbol.for(MetricKeySymbolKey);
const metricKeyVariance = {
/* c8 ignore next */
_Type: _ => _
};
const arrayEquivilence = /*#__PURE__*/Arr.getEquivalence(Equal.equals);
/** @internal */
class MetricKeyImpl {
name;
keyType;
description;
tags;
[MetricKeyTypeId] = metricKeyVariance;
constructor(name, keyType, description, tags = []) {
this.name = name;
this.keyType = keyType;
this.description = description;
this.tags = tags;
this._hash = pipe(Hash.string(this.name + this.description), Hash.combine(Hash.hash(this.keyType)), Hash.combine(Hash.array(this.tags)));
}
_hash;
[Hash.symbol]() {
return this._hash;
}
[Equal.symbol](u) {
return isMetricKey(u) && this.name === u.name && Equal.equals(this.keyType, u.keyType) && Equal.equals(this.description, u.description) && arrayEquivilence(this.tags, u.tags);
}
pipe() {
return pipeArguments(this, arguments);
}
}
/** @internal */
export const isMetricKey = u => hasProperty(u, MetricKeyTypeId);
/** @internal */
export const counter = (name, options) => new MetricKeyImpl(name, metricKeyType.counter(options), Option.fromNullable(options?.description));
/** @internal */
export const frequency = (name, options) => new MetricKeyImpl(name, metricKeyType.frequency(options), Option.fromNullable(options?.description));
/** @internal */
export const gauge = (name, options) => new MetricKeyImpl(name, metricKeyType.gauge(options), Option.fromNullable(options?.description));
/** @internal */
export const histogram = (name, boundaries, description) => new MetricKeyImpl(name, metricKeyType.histogram(boundaries), Option.fromNullable(description));
/** @internal */
export const summary = options => new MetricKeyImpl(options.name, metricKeyType.summary(options), Option.fromNullable(options.description));
/** @internal */
export const tagged = /*#__PURE__*/dual(3, (self, key, value) => taggedWithLabels(self, [metricLabel.make(key, value)]));
/** @internal */
export const taggedWithLabels = /*#__PURE__*/dual(2, (self, extraTags) => extraTags.length === 0 ? self : new MetricKeyImpl(self.name, self.keyType, self.description, Arr.union(self.tags, extraTags)));
//# sourceMappingURL=key.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"key.js","names":["Arr","Equal","dual","pipe","Hash","Option","pipeArguments","hasProperty","metricKeyType","metricLabel","MetricKeySymbolKey","MetricKeyTypeId","Symbol","for","metricKeyVariance","_Type","_","arrayEquivilence","getEquivalence","equals","MetricKeyImpl","name","keyType","description","tags","constructor","_hash","string","combine","hash","array","symbol","u","isMetricKey","arguments","counter","options","fromNullable","frequency","gauge","histogram","boundaries","summary","tagged","self","key","value","taggedWithLabels","make","extraTags","length","union"],"sources":["../../../../src/internal/metric/key.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAO,KAAKA,GAAG,MAAM,gBAAgB;AAErC,OAAO,KAAKC,KAAK,MAAM,gBAAgB;AACvC,SAASC,IAAI,EAAEC,IAAI,QAAQ,mBAAmB;AAC9C,OAAO,KAAKC,IAAI,MAAM,eAAe;AAKrC,OAAO,KAAKC,MAAM,MAAM,iBAAiB;AACzC,SAASC,aAAa,QAAQ,mBAAmB;AACjD,SAASC,WAAW,QAAQ,oBAAoB;AAChD,OAAO,KAAKC,aAAa,MAAM,cAAc;AAC7C,OAAO,KAAKC,WAAW,MAAM,YAAY;AAEzC;AACA,MAAMC,kBAAkB,GAAG,kBAAkB;AAE7C;AACA,OAAO,MAAMC,eAAe,gBAA8BC,MAAM,CAACC,GAAG,CAClEH,kBAAkB,CACU;AAE9B,MAAMI,iBAAiB,GAAG;EACxB;EACAC,KAAK,EAAGC,CAAQ,IAAKA;CACtB;AAED,MAAMC,gBAAgB,gBAAGjB,GAAG,CAACkB,cAAc,CAACjB,KAAK,CAACkB,MAAM,CAAC;AAEzD;AACA,MAAMC,aAAa;EAGNC,IAAA;EACAC,OAAA;EACAC,WAAA;EACAC,IAAA;EALF,CAACb,eAAe,IAAIG,iBAAiB;EAC9CW,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AAEK,SAAS,KACnBA,SAAS,CAACC,MAAM,KAAK,CAAC,GAClBN,IAAI,GACJ,IAAIxB,aAAa,CAACwB,IAAI,CAACvB,IAAI,EAAEuB,IAAI,CAACtB,OAAO,EAAEsB,IAAI,CAACrB,WAAW,EAAEvB,GAAG,CAACmD,KAAK,CAACP,IAAI,CAACpB,IAAI,EAAEyB,SAAS,CAAC,CAAC,CAAC","ignoreList":[]}

View File

@@ -0,0 +1,169 @@
import * as Duration from "../../Duration.js";
import * as Equal from "../../Equal.js";
import { pipe } from "../../Function.js";
import * as Hash from "../../Hash.js";
import { pipeArguments } from "../../Pipeable.js";
import { hasProperty } from "../../Predicate.js";
/** @internal */
const MetricKeyTypeSymbolKey = "effect/MetricKeyType";
/** @internal */
export const MetricKeyTypeTypeId = /*#__PURE__*/Symbol.for(MetricKeyTypeSymbolKey);
/** @internal */
const CounterKeyTypeSymbolKey = "effect/MetricKeyType/Counter";
/** @internal */
export const CounterKeyTypeTypeId = /*#__PURE__*/Symbol.for(CounterKeyTypeSymbolKey);
/** @internal */
const FrequencyKeyTypeSymbolKey = "effect/MetricKeyType/Frequency";
/** @internal */
export const FrequencyKeyTypeTypeId = /*#__PURE__*/Symbol.for(FrequencyKeyTypeSymbolKey);
/** @internal */
const GaugeKeyTypeSymbolKey = "effect/MetricKeyType/Gauge";
/** @internal */
export const GaugeKeyTypeTypeId = /*#__PURE__*/Symbol.for(GaugeKeyTypeSymbolKey);
/** @internal */
const HistogramKeyTypeSymbolKey = "effect/MetricKeyType/Histogram";
/** @internal */
export const HistogramKeyTypeTypeId = /*#__PURE__*/Symbol.for(HistogramKeyTypeSymbolKey);
/** @internal */
const SummaryKeyTypeSymbolKey = "effect/MetricKeyType/Summary";
/** @internal */
export const SummaryKeyTypeTypeId = /*#__PURE__*/Symbol.for(SummaryKeyTypeSymbolKey);
const metricKeyTypeVariance = {
/* c8 ignore next */
_In: _ => _,
/* c8 ignore next */
_Out: _ => _
};
/** @internal */
class CounterKeyType {
incremental;
bigint;
[MetricKeyTypeTypeId] = metricKeyTypeVariance;
[CounterKeyTypeTypeId] = CounterKeyTypeTypeId;
constructor(incremental, bigint) {
this.incremental = incremental;
this.bigint = bigint;
this._hash = Hash.string(CounterKeyTypeSymbolKey);
}
_hash;
[Hash.symbol]() {
return this._hash;
}
[Equal.symbol](that) {
return isCounterKey(that);
}
pipe() {
return pipeArguments(this, arguments);
}
}
const FrequencyKeyTypeHash = /*#__PURE__*/Hash.string(FrequencyKeyTypeSymbolKey);
/** @internal */
class FrequencyKeyType {
preregisteredWords;
[MetricKeyTypeTypeId] = metricKeyTypeVariance;
[FrequencyKeyTypeTypeId] = FrequencyKeyTypeTypeId;
constructor(preregisteredWords) {
this.preregisteredWords = preregisteredWords;
}
[Hash.symbol]() {
return FrequencyKeyTypeHash;
}
[Equal.symbol](that) {
return isFrequencyKey(that);
}
pipe() {
return pipeArguments(this, arguments);
}
}
const GaugeKeyTypeHash = /*#__PURE__*/Hash.string(GaugeKeyTypeSymbolKey);
/** @internal */
class GaugeKeyType {
bigint;
[MetricKeyTypeTypeId] = metricKeyTypeVariance;
[GaugeKeyTypeTypeId] = GaugeKeyTypeTypeId;
constructor(bigint) {
this.bigint = bigint;
}
[Hash.symbol]() {
return GaugeKeyTypeHash;
}
[Equal.symbol](that) {
return isGaugeKey(that);
}
pipe() {
return pipeArguments(this, arguments);
}
}
/** @internal */
export class HistogramKeyType {
boundaries;
[MetricKeyTypeTypeId] = metricKeyTypeVariance;
[HistogramKeyTypeTypeId] = HistogramKeyTypeTypeId;
constructor(boundaries) {
this.boundaries = boundaries;
this._hash = pipe(Hash.string(HistogramKeyTypeSymbolKey), Hash.combine(Hash.hash(this.boundaries)));
}
_hash;
[Hash.symbol]() {
return this._hash;
}
[Equal.symbol](that) {
return isHistogramKey(that) && Equal.equals(this.boundaries, that.boundaries);
}
pipe() {
return pipeArguments(this, arguments);
}
}
/** @internal */
class SummaryKeyType {
maxAge;
maxSize;
error;
quantiles;
[MetricKeyTypeTypeId] = metricKeyTypeVariance;
[SummaryKeyTypeTypeId] = SummaryKeyTypeTypeId;
constructor(maxAge, maxSize, error, quantiles) {
this.maxAge = maxAge;
this.maxSize = maxSize;
this.error = error;
this.quantiles = quantiles;
this._hash = pipe(Hash.string(SummaryKeyTypeSymbolKey), Hash.combine(Hash.hash(this.maxAge)), Hash.combine(Hash.hash(this.maxSize)), Hash.combine(Hash.hash(this.error)), Hash.combine(Hash.array(this.quantiles)));
}
_hash;
[Hash.symbol]() {
return this._hash;
}
[Equal.symbol](that) {
return isSummaryKey(that) && Equal.equals(this.maxAge, that.maxAge) && this.maxSize === that.maxSize && this.error === that.error && Equal.equals(this.quantiles, that.quantiles);
}
pipe() {
return pipeArguments(this, arguments);
}
}
/** @internal */
export const counter = options => new CounterKeyType(options?.incremental ?? false, options?.bigint ?? false);
/** @internal */
export const frequency = options => new FrequencyKeyType(options?.preregisteredWords ?? []);
/** @internal */
export const gauge = options => new GaugeKeyType(options?.bigint ?? false);
/** @internal */
export const histogram = boundaries => {
return new HistogramKeyType(boundaries);
};
/** @internal */
export const summary = options => {
return new SummaryKeyType(Duration.decode(options.maxAge), options.maxSize, options.error, options.quantiles);
};
/** @internal */
export const isMetricKeyType = u => hasProperty(u, MetricKeyTypeTypeId);
/** @internal */
export const isCounterKey = u => hasProperty(u, CounterKeyTypeTypeId);
/** @internal */
export const isFrequencyKey = u => hasProperty(u, FrequencyKeyTypeTypeId);
/** @internal */
export const isGaugeKey = u => hasProperty(u, GaugeKeyTypeTypeId);
/** @internal */
export const isHistogramKey = u => hasProperty(u, HistogramKeyTypeTypeId);
/** @internal */
export const isSummaryKey = u => hasProperty(u, SummaryKeyTypeTypeId);
//# sourceMappingURL=keyType.js.map

File diff suppressed because one or more lines are too long

36
_node_modules/effect/dist/esm/internal/metric/label.js generated vendored Normal file
View File

@@ -0,0 +1,36 @@
import * as Equal from "../../Equal.js";
import * as Hash from "../../Hash.js";
import { pipeArguments } from "../../Pipeable.js";
import { hasProperty } from "../../Predicate.js";
/** @internal */
const MetricLabelSymbolKey = "effect/MetricLabel";
/** @internal */
export const MetricLabelTypeId = /*#__PURE__*/Symbol.for(MetricLabelSymbolKey);
/** @internal */
class MetricLabelImpl {
key;
value;
[MetricLabelTypeId] = MetricLabelTypeId;
_hash;
constructor(key, value) {
this.key = key;
this.value = value;
this._hash = Hash.string(MetricLabelSymbolKey + this.key + this.value);
}
[Hash.symbol]() {
return this._hash;
}
[Equal.symbol](that) {
return isMetricLabel(that) && this.key === that.key && this.value === that.value;
}
pipe() {
return pipeArguments(this, arguments);
}
}
/** @internal */
export const make = (key, value) => {
return new MetricLabelImpl(key, value);
};
/** @internal */
export const isMetricLabel = u => hasProperty(u, MetricLabelTypeId);
//# sourceMappingURL=label.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"label.js","names":["Equal","Hash","pipeArguments","hasProperty","MetricLabelSymbolKey","MetricLabelTypeId","Symbol","for","MetricLabelImpl","key","value","_hash","constructor","string","symbol","that","isMetricLabel","pipe","arguments","make","u"],"sources":["../../../../src/internal/metric/label.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,gBAAgB;AACvC,OAAO,KAAKC,IAAI,MAAM,eAAe;AAErC,SAASC,aAAa,QAAQ,mBAAmB;AACjD,SAASC,WAAW,QAAQ,oBAAoB;AAEhD;AACA,MAAMC,oBAAoB,GAAG,oBAAoB;AAEjD;AACA,OAAO,MAAMC,iBAAiB,gBAAkCC,MAAM,CAACC,GAAG,CACxEH,oBAAoB,CACY;AAElC;AACA,MAAMI,eAAe;EAGEC,GAAA;EAAsBC,KAAA;EAFlC,CAACL,iBAAiB,IAAmCA,iBAAiB;EACtEM,KAAK;EACdC,YAAqBH,GAAW,EAAWC,KAAa;IAAnC,KAAAD,GAAG,GAAHA,GAAG;IAAmB,KAAAC,KAAK,GAALA,KAAK;IAC9C,IAAI,CAACC,KAAK,GAAGV,IAAI,CAACY,MAAM,CAACT,oBAAoB,GAAG,IAAI,CAACK,GAAG,GAAG,IAAI,CAACC,KAAK,CAAC;EACxE;EACA,CAACT,IAAI,CAACa,MAAM,IAAC;IACX,OAAO,IAAI,CAACH,KAAK;EACnB;EACA,CAACX,KAAK,CAACc,MAAM,EAAEC,IAAa;IAC1B,OAAOC,aAAa,CAACD,IAAI,CAAC,IACxB,IAAI,CAACN,GAAG,KAAKM,IAAI,CAACN,GAAG,IACrB,IAAI,CAACC,KAAK,KAAKK,IAAI,CAACL,KAAK;EAC7B;EACAO,IAAIA,CAAA;IACF,OAAOf,aAAa,CAAC,IAAI,EAAEgB,SAAS,CAAC;EACvC;;AAGF;AACA,OAAO,MAAMC,IAAI,GAAGA,CAACV,GAAW,EAAEC,KAAa,KAA6B;EAC1E,OAAO,IAAIF,eAAe,CAACC,GAAG,EAAEC,KAAK,CAAC;AACxC,CAAC;AAED;AACA,OAAO,MAAMM,aAAa,GAAII,CAAU,IAAmCjB,WAAW,CAACiB,CAAC,EAAEf,iBAAiB,CAAC","ignoreList":[]}

32
_node_modules/effect/dist/esm/internal/metric/pair.js generated vendored Normal file
View File

@@ -0,0 +1,32 @@
import { pipeArguments } from "../../Pipeable.js";
/** @internal */
const MetricPairSymbolKey = "effect/MetricPair";
/** @internal */
export const MetricPairTypeId = /*#__PURE__*/Symbol.for(MetricPairSymbolKey);
const metricPairVariance = {
/* c8 ignore next */
_Type: _ => _
};
/** @internal */
export const make = (metricKey, metricState) => {
return {
[MetricPairTypeId]: metricPairVariance,
metricKey,
metricState,
pipe() {
return pipeArguments(this, arguments);
}
};
};
/** @internal */
export const unsafeMake = (metricKey, metricState) => {
return {
[MetricPairTypeId]: metricPairVariance,
metricKey,
metricState,
pipe() {
return pipeArguments(this, arguments);
}
};
};
//# sourceMappingURL=pair.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"pair.js","names":["pipeArguments","MetricPairSymbolKey","MetricPairTypeId","Symbol","for","metricPairVariance","_Type","_","make","metricKey","metricState","pipe","arguments","unsafeMake"],"sources":["../../../../src/internal/metric/pair.ts"],"sourcesContent":[null],"mappings":"AAIA,SAASA,aAAa,QAAQ,mBAAmB;AAEjD;AACA,MAAMC,mBAAmB,GAAG,mBAAmB;AAE/C;AACA,OAAO,MAAMC,gBAAgB,gBAAgCC,MAAM,CAACC,GAAG,CACrEH,mBAAmB,CACW;AAEhC,MAAMI,kBAAkB,GAAG;EACzB;EACAC,KAAK,EAAGC,CAAQ,IAAKA;CACtB;AAED;AACA,OAAO,MAAMC,IAAI,GAAGA,CAClBC,SAAoC,EACpCC,WAA+E,KAC9C;EACjC,OAAO;IACL,CAACR,gBAAgB,GAAGG,kBAAkB;IACtCI,SAAS;IACTC,WAAW;IACXC,IAAIA,CAAA;MACF,OAAOX,aAAa,CAAC,IAAI,EAAEY,SAAS,CAAC;IACvC;GACD;AACH,CAAC;AAED;AACA,OAAO,MAAMC,UAAU,GAAGA,CACxBJ,SAAoC,EACpCC,WAA4C,KACX;EACjC,OAAO;IACL,CAACR,gBAAgB,GAAGG,kBAAkB;IACtCI,SAAS;IACTC,WAAW;IACXC,IAAIA,CAAA;MACF,OAAOX,aAAa,CAAC,IAAI,EAAEY,SAAS,CAAC;IACvC;GACD;AACH,CAAC","ignoreList":[]}

View File

@@ -0,0 +1,69 @@
import { dual, pipe } from "../../Function.js";
import { pipeArguments } from "../../Pipeable.js";
import * as core from "../core.js";
import * as metric from "../metric.js";
import * as schedule_ from "../schedule.js";
/** @internal */
const MetricPollingSymbolKey = "effect/MetricPolling";
/** @internal */
export const MetricPollingTypeId = /*#__PURE__*/Symbol.for(MetricPollingSymbolKey);
/** @internal */
export const make = (metric, poll) => {
return {
[MetricPollingTypeId]: MetricPollingTypeId,
pipe() {
return pipeArguments(this, arguments);
},
metric,
poll
};
};
/** @internal */
export const collectAll = iterable => {
const metrics = Array.from(iterable);
return {
[MetricPollingTypeId]: MetricPollingTypeId,
pipe() {
return pipeArguments(this, arguments);
},
metric: metric.make(Array.of(void 0), (inputs, extraTags) => {
for (let i = 0; i < inputs.length; i++) {
const pollingMetric = metrics[i];
const input = pipe(inputs, x => x[i]);
pollingMetric.metric.unsafeUpdate(input, extraTags);
}
}, extraTags => Array.from(metrics.map(pollingMetric => pollingMetric.metric.unsafeValue(extraTags))), (inputs, extraTags) => {
for (let i = 0; i < inputs.length; i++) {
const pollingMetric = metrics[i];
const input = pipe(inputs, x => x[i]);
pollingMetric.metric.unsafeModify(input, extraTags);
}
}),
poll: core.forEachSequential(metrics, metric => metric.poll)
};
};
/** @internal */
export const launch = /*#__PURE__*/dual(2, (self, schedule) => pipe(pollAndUpdate(self), core.zipRight(metric.value(self.metric)), schedule_.scheduleForked(schedule)));
/** @internal */
export const poll = self => self.poll;
/** @internal */
export const pollAndUpdate = self => core.flatMap(self.poll, value => metric.update(self.metric, value));
/** @internal */
export const retry = /*#__PURE__*/dual(2, (self, policy) => ({
[MetricPollingTypeId]: MetricPollingTypeId,
pipe() {
return pipeArguments(this, arguments);
},
metric: self.metric,
poll: schedule_.retry_Effect(self.poll, policy)
}));
/** @internal */
export const zip = /*#__PURE__*/dual(2, (self, that) => ({
[MetricPollingTypeId]: MetricPollingTypeId,
pipe() {
return pipeArguments(this, arguments);
},
metric: pipe(self.metric, metric.zip(that.metric)),
poll: core.zip(self.poll, that.poll)
}));
//# sourceMappingURL=polling.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"polling.js","names":["dual","pipe","pipeArguments","core","metric","schedule_","MetricPollingSymbolKey","MetricPollingTypeId","Symbol","for","make","poll","arguments","collectAll","iterable","metrics","Array","from","of","inputs","extraTags","i","length","pollingMetric","input","x","unsafeUpdate","map","unsafeValue","unsafeModify","forEachSequential","launch","self","schedule","pollAndUpdate","zipRight","value","scheduleForked","flatMap","update","retry","policy","retry_Effect","zip","that"],"sources":["../../../../src/internal/metric/polling.ts"],"sourcesContent":[null],"mappings":"AAEA,SAASA,IAAI,EAAEC,IAAI,QAAQ,mBAAmB;AAG9C,SAASC,aAAa,QAAQ,mBAAmB;AAGjD,O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M;EACtB,CAAClC,mBAAmB,GAAGA,mBAAmB;EAC1CN,IAAIA,CAAA;IACF,OAAOC,aAAa,CAAC,IAAI,EAAEU,SAAS,CAAC;EACvC,CAAC;EACDR,MAAM,EAAE4B,IAAI,CAAC5B,MAAM;EACnBO,IAAI,EAAEN,SAAS,CAACqC,YAAY,CAACV,IAAI,CAACrB,IAAI,EAAE8B,MAAM;CAC/C,CAAC,CAAC;AAEH;AACA,OAAO,MAAME,GAAG,gBAAG3C,IAAI,CAsBrB,CAAC,EAAE,CAACgC,IAAI,EAAEY,IAAI,MAAM;EACpB,CAACrC,mBAAmB,GAAGA,mBAAmB;EAC1CN,IAAIA,CAAA;IACF,OAAOC,aAAa,CAAC,IAAI,EAAEU,SAAS,CAAC;EACvC,CAAC;EACDR,MAAM,EAAEH,IAAI,CAAC+B,IAAI,CAAC5B,MAAM,EAAEA,MAAM,CAACuC,GAAG,CAACC,IAAI,CAACxC,MAAM,CAAC,CAAC;EAClDO,IAAI,EAAER,IAAI,CAACwC,GAAG,CAACX,IAAI,CAACrB,IAAI,EAAEiC,IAAI,CAACjC,IAAI;CACpC,CAAC,CAAC","ignoreList":[]}

View File

@@ -0,0 +1,105 @@
import { pipe } from "../../Function.js";
import * as MutableHashMap from "../../MutableHashMap.js";
import * as Option from "../../Option.js";
import * as metricHook from "./hook.js";
import * as metricKeyType from "./keyType.js";
import * as metricPair from "./pair.js";
/** @internal */
const MetricRegistrySymbolKey = "effect/MetricRegistry";
/** @internal */
export const MetricRegistryTypeId = /*#__PURE__*/Symbol.for(MetricRegistrySymbolKey);
/** @internal */
class MetricRegistryImpl {
[MetricRegistryTypeId] = MetricRegistryTypeId;
map = /*#__PURE__*/MutableHashMap.empty();
snapshot() {
const result = [];
for (const [key, hook] of this.map) {
result.push(metricPair.unsafeMake(key, hook.get()));
}
return result;
}
get(key) {
const hook = pipe(this.map, MutableHashMap.get(key), Option.getOrUndefined);
if (hook == null) {
if (metricKeyType.isCounterKey(key.keyType)) {
return this.getCounter(key);
}
if (metricKeyType.isGaugeKey(key.keyType)) {
return this.getGauge(key);
}
if (metricKeyType.isFrequencyKey(key.keyType)) {
return this.getFrequency(key);
}
if (metricKeyType.isHistogramKey(key.keyType)) {
return this.getHistogram(key);
}
if (metricKeyType.isSummaryKey(key.keyType)) {
return this.getSummary(key);
}
throw new Error("BUG: MetricRegistry.get - unknown MetricKeyType - please report an issue at https://github.com/Effect-TS/effect/issues");
} else {
return hook;
}
}
getCounter(key) {
let value = pipe(this.map, MutableHashMap.get(key), Option.getOrUndefined);
if (value == null) {
const counter = metricHook.counter(key);
if (!pipe(this.map, MutableHashMap.has(key))) {
pipe(this.map, MutableHashMap.set(key, counter));
}
value = counter;
}
return value;
}
getFrequency(key) {
let value = pipe(this.map, MutableHashMap.get(key), Option.getOrUndefined);
if (value == null) {
const frequency = metricHook.frequency(key);
if (!pipe(this.map, MutableHashMap.has(key))) {
pipe(this.map, MutableHashMap.set(key, frequency));
}
value = frequency;
}
return value;
}
getGauge(key) {
let value = pipe(this.map, MutableHashMap.get(key), Option.getOrUndefined);
if (value == null) {
const gauge = metricHook.gauge(key, key.keyType.bigint ? BigInt(0) : 0);
if (!pipe(this.map, MutableHashMap.has(key))) {
pipe(this.map, MutableHashMap.set(key, gauge));
}
value = gauge;
}
return value;
}
getHistogram(key) {
let value = pipe(this.map, MutableHashMap.get(key), Option.getOrUndefined);
if (value == null) {
const histogram = metricHook.histogram(key);
if (!pipe(this.map, MutableHashMap.has(key))) {
pipe(this.map, MutableHashMap.set(key, histogram));
}
value = histogram;
}
return value;
}
getSummary(key) {
let value = pipe(this.map, MutableHashMap.get(key), Option.getOrUndefined);
if (value == null) {
const summary = metricHook.summary(key);
if (!pipe(this.map, MutableHashMap.has(key))) {
pipe(this.map, MutableHashMap.set(key, summary));
}
value = summary;
}
return value;
}
}
/** @internal */
export const make = () => {
return new MetricRegistryImpl();
};
//# sourceMappingURL=registry.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"registry.js","names":["pipe","MutableHashMap","Option","metricHook","metricKeyType","metricPair","MetricRegistrySymbolKey","MetricRegistryTypeId","Symbol","for","MetricRegistryImpl","map","empty","snapshot","result","key","hook","push","unsafeMake","get","getOrUndefined","isCounterKey","keyType","getCounter","isGaugeKey","getGauge","isFrequencyKey","getFrequency","isHistogramKey","getHistogram","isSummaryKey","getSummary","Error","value","counter","has","set","frequency","gauge","bigint","BigInt","histogram","summary","make"],"sources":["../../../../src/internal/metric/registry.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,IAAI,QAAQ,mBAAmB;AAMxC,OAAO,KAAKC,cAAc,MAAM,yBAAyB;AACzD,OAAO,KAAKC,MAAM,MAAM,iBAAiB;AACzC,OAAO,KAAKC,UAAU,MAAM,WAAW;AACvC,OAAO,KAAKC,aAAa,MAAM,cAAc;AAC7C,OAAO,KAAKC,UAAU,MAAM,WAAW;AAEvC;AACA,MAAMC,uBAAuB,GAAG,uBAAuB;AAEvD;AACA,OAAO,MAAMC,oBAAoB,gBAAwCC,MAAM,CAACC,GAAG,CACjFH,uBAAuB,CACe;AAExC;AACA,MAAMI,kBAAkB;EACb,CAACH,oBAAoB,IAAyCA,oBAAoB;EAEnFI,GAAG,gBAAGV,cAAc,CAACW,KAAK,EAG/B;EAEHC,QAAQA,CAAA;IACN,MAAMC,MAAM,GAAyC,EAAE;IACvD,KAAK,MAAM,CAACC,GAAG,EAAEC,IAAI,CAAC,IAAI,IAAI,CAACL,GAAG,EAAE;MAClCG,MAAM,CAACG,IAAI,CAACZ,UAAU,CAACa,UAAU,CAACH,GAAG,EAAEC,IAAI,CAACG,GAAG,EAAE,CAAC,CAAC;IACrD;IACA,OAAOL,MAAM;EACf;EAEAK,GAAGA,CACDJ,GAA8B;IAK9B,MAAMC,IAAI,GAAGhB,IAAI,CACf,IAAI,CAACW,GAAG,EACRV,cAAc,CAACkB,GAAG,CAACJ,GAA+D,CAAC,EACnFb,MAAM,CAACkB,cAAc,CACtB;IACD,IAAIJ,IAAI,I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AAYA,CAACd,GAAkC;IAC7C,IAAIkB,KAAK,GAAGjC,IAAI,CACd,IAAI,CAACW,GAAG,EACRV,cAAc,CAACkB,GAAG,CAACJ,GAA+D,CAAC,EACnFb,MAAM,CAACkB,cAAc,CACtB;IACD,IAAIa,KAAK,IAAI,IAAI,EAAE;MACjB,MAAMQ,SAAS,GAAGtC,UAAU,CAACsC,SAAS,CAAC1B,GAAG,CAAC;MAC3C,IAAI,CAACf,IAAI,CAAC,IAAI,CAACW,GAAG,EAAEV,cAAc,CAACkC,GAAG,CAACpB,GAA+D,CAAC,CAAC,EAAE;QACxGf,IAAI,CACF,IAAI,CAACW,GAAG,EACRV,cAAc,CAACmC,GAAG,CAChBrB,GAA+D,EAC/D0B,SAAuC,CACxC,CACF;MACH;MACAR,KAAK,GAAGQ,SAAS;IACnB;IACA,OAAOR,KAAwC;EACjD;EAEAF,UAAUA,CAAChB,GAAgC;IACzC,IAAIkB,KAAK,GAAGjC,IAAI,CACd,IAAI,CAACW,GAAG,EACRV,cAAc,CAACkB,GAAG,CAACJ,GAA+D,CAAC,EACnFb,MAAM,CAACkB,cAAc,CACtB;IACD,IAAIa,KAAK,IAAI,IAAI,EAAE;MACjB,MAAMS,OAAO,GAAGvC,UAAU,CAACuC,OAAO,CAAC3B,GAAG,CAAC;MACvC,IAAI,CAACf,IAAI,CAAC,IAAI,CAACW,GAAG,EAAEV,cAAc,CAACkC,GAAG,CAACpB,GAA+D,CAAC,CAAC,EAAE;QACxGf,IAAI,CACF,IAAI,CAACW,GAAG,EACRV,cAAc,CAACmC,GAAG,CAChBrB,GAA+D,EAC/D2B,OAAqC,CACtC,CACF;MACH;MACAT,KAAK,GAAGS,OAAO;IACjB;IACA,OAAOT,KAAsC;EAC/C;;AAGF;AACA,OAAO,MAAMU,IAAI,GAAGA,CAAA,KAAoC;EACtD,OAAO,IAAIjC,kBAAkB,EAAE;AACjC,CAAC","ignoreList":[]}

181
_node_modules/effect/dist/esm/internal/metric/state.js generated vendored Normal file
View File

@@ -0,0 +1,181 @@
import * as Arr from "../../Array.js";
import * as Equal from "../../Equal.js";
import { pipe } from "../../Function.js";
import * as Hash from "../../Hash.js";
import { pipeArguments } from "../../Pipeable.js";
import { hasProperty } from "../../Predicate.js";
/** @internal */
const MetricStateSymbolKey = "effect/MetricState";
/** @internal */
export const MetricStateTypeId = /*#__PURE__*/Symbol.for(MetricStateSymbolKey);
/** @internal */
const CounterStateSymbolKey = "effect/MetricState/Counter";
/** @internal */
export const CounterStateTypeId = /*#__PURE__*/Symbol.for(CounterStateSymbolKey);
/** @internal */
const FrequencyStateSymbolKey = "effect/MetricState/Frequency";
/** @internal */
export const FrequencyStateTypeId = /*#__PURE__*/Symbol.for(FrequencyStateSymbolKey);
/** @internal */
const GaugeStateSymbolKey = "effect/MetricState/Gauge";
/** @internal */
export const GaugeStateTypeId = /*#__PURE__*/Symbol.for(GaugeStateSymbolKey);
/** @internal */
const HistogramStateSymbolKey = "effect/MetricState/Histogram";
/** @internal */
export const HistogramStateTypeId = /*#__PURE__*/Symbol.for(HistogramStateSymbolKey);
/** @internal */
const SummaryStateSymbolKey = "effect/MetricState/Summary";
/** @internal */
export const SummaryStateTypeId = /*#__PURE__*/Symbol.for(SummaryStateSymbolKey);
const metricStateVariance = {
/* c8 ignore next */
_A: _ => _
};
/** @internal */
class CounterState {
count;
[MetricStateTypeId] = metricStateVariance;
[CounterStateTypeId] = CounterStateTypeId;
constructor(count) {
this.count = count;
}
[Hash.symbol]() {
return pipe(Hash.hash(CounterStateSymbolKey), Hash.combine(Hash.hash(this.count)), Hash.cached(this));
}
[Equal.symbol](that) {
return isCounterState(that) && this.count === that.count;
}
pipe() {
return pipeArguments(this, arguments);
}
}
const arrayEquals = /*#__PURE__*/Arr.getEquivalence(Equal.equals);
/** @internal */
class FrequencyState {
occurrences;
[MetricStateTypeId] = metricStateVariance;
[FrequencyStateTypeId] = FrequencyStateTypeId;
constructor(occurrences) {
this.occurrences = occurrences;
}
_hash;
[Hash.symbol]() {
return pipe(Hash.string(FrequencyStateSymbolKey), Hash.combine(Hash.array(Arr.fromIterable(this.occurrences.entries()))), Hash.cached(this));
}
[Equal.symbol](that) {
return isFrequencyState(that) && arrayEquals(Arr.fromIterable(this.occurrences.entries()), Arr.fromIterable(that.occurrences.entries()));
}
pipe() {
return pipeArguments(this, arguments);
}
}
/** @internal */
class GaugeState {
value;
[MetricStateTypeId] = metricStateVariance;
[GaugeStateTypeId] = GaugeStateTypeId;
constructor(value) {
this.value = value;
}
[Hash.symbol]() {
return pipe(Hash.hash(GaugeStateSymbolKey), Hash.combine(Hash.hash(this.value)), Hash.cached(this));
}
[Equal.symbol](u) {
return isGaugeState(u) && this.value === u.value;
}
pipe() {
return pipeArguments(this, arguments);
}
}
/** @internal */
export class HistogramState {
buckets;
count;
min;
max;
sum;
[MetricStateTypeId] = metricStateVariance;
[HistogramStateTypeId] = HistogramStateTypeId;
constructor(buckets, count, min, max, sum) {
this.buckets = buckets;
this.count = count;
this.min = min;
this.max = max;
this.sum = sum;
}
[Hash.symbol]() {
return pipe(Hash.hash(HistogramStateSymbolKey), Hash.combine(Hash.hash(this.buckets)), Hash.combine(Hash.hash(this.count)), Hash.combine(Hash.hash(this.min)), Hash.combine(Hash.hash(this.max)), Hash.combine(Hash.hash(this.sum)), Hash.cached(this));
}
[Equal.symbol](that) {
return isHistogramState(that) && Equal.equals(this.buckets, that.buckets) && this.count === that.count && this.min === that.min && this.max === that.max && this.sum === that.sum;
}
pipe() {
return pipeArguments(this, arguments);
}
}
/** @internal */
export class SummaryState {
error;
quantiles;
count;
min;
max;
sum;
[MetricStateTypeId] = metricStateVariance;
[SummaryStateTypeId] = SummaryStateTypeId;
constructor(error, quantiles, count, min, max, sum) {
this.error = error;
this.quantiles = quantiles;
this.count = count;
this.min = min;
this.max = max;
this.sum = sum;
}
[Hash.symbol]() {
return pipe(Hash.hash(SummaryStateSymbolKey), Hash.combine(Hash.hash(this.error)), Hash.combine(Hash.hash(this.quantiles)), Hash.combine(Hash.hash(this.count)), Hash.combine(Hash.hash(this.min)), Hash.combine(Hash.hash(this.max)), Hash.combine(Hash.hash(this.sum)), Hash.cached(this));
}
[Equal.symbol](that) {
return isSummaryState(that) && this.error === that.error && Equal.equals(this.quantiles, that.quantiles) && this.count === that.count && this.min === that.min && this.max === that.max && this.sum === that.sum;
}
pipe() {
return pipeArguments(this, arguments);
}
}
/** @internal */
export const counter = count => new CounterState(count);
/** @internal */
export const frequency = occurrences => {
return new FrequencyState(occurrences);
};
/** @internal */
export const gauge = count => new GaugeState(count);
/** @internal */
export const histogram = options => new HistogramState(options.buckets, options.count, options.min, options.max, options.sum);
/** @internal */
export const summary = options => new SummaryState(options.error, options.quantiles, options.count, options.min, options.max, options.sum);
/** @internal */
export const isMetricState = u => hasProperty(u, MetricStateTypeId);
/** @internal */
export const isCounterState = u => hasProperty(u, CounterStateTypeId);
/**
* @since 2.0.0
* @category refinements
*/
export const isFrequencyState = u => hasProperty(u, FrequencyStateTypeId);
/**
* @since 2.0.0
* @category refinements
*/
export const isGaugeState = u => hasProperty(u, GaugeStateTypeId);
/**
* @since 2.0.0
* @category refinements
*/
export const isHistogramState = u => hasProperty(u, HistogramStateTypeId);
/**
* @since 2.0.0
* @category refinements
*/
export const isSummaryState = u => hasProperty(u, SummaryStateTypeId);
//# sourceMappingURL=state.js.map

File diff suppressed because one or more lines are too long