@tinyshed/tinystore 0.1.0-rc.5 → 0.1.0-rc.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -37
- package/bin/tinystore.js +12 -1
- package/dist/backup.d.ts +33 -0
- package/dist/backup.js +49 -0
- package/dist/blobs.d.ts +160 -79
- package/dist/blobs.js +510 -217
- package/dist/channels.d.ts +90 -0
- package/dist/channels.js +291 -0
- package/dist/clock.js +3 -3
- package/dist/config.d.ts +209 -86
- package/dist/config.js +581 -538
- package/dist/connection.d.ts +64 -2
- package/dist/connection.js +201 -16
- package/dist/console.d.ts +27 -3
- package/dist/console.js +165 -12
- package/dist/dotenv.d.ts +7 -0
- package/dist/dotenv.js +79 -0
- package/dist/errors.d.ts +61 -1
- package/dist/errors.js +81 -1
- package/dist/handles.d.ts +44 -2
- package/dist/handles.js +81 -2
- package/dist/index.d.ts +17 -11
- package/dist/index.js +5 -3
- package/dist/instruments.d.ts +177 -0
- package/dist/instruments.js +819 -0
- package/dist/jobs.d.ts +335 -239
- package/dist/jobs.js +716 -536
- package/dist/json.d.ts +2 -0
- package/dist/json.js +122 -0
- package/dist/kv.d.ts +130 -243
- package/dist/kv.js +273 -640
- package/dist/limits.d.ts +80 -0
- package/dist/limits.js +139 -0
- package/dist/locks.d.ts +62 -0
- package/dist/locks.js +237 -0
- package/dist/logger.d.ts +45 -9
- package/dist/logger.js +150 -38
- package/dist/metrics.d.ts +210 -209
- package/dist/metrics.js +319 -556
- package/dist/once.d.ts +19 -18
- package/dist/once.js +74 -63
- package/dist/query.d.ts +181 -0
- package/dist/query.js +788 -0
- package/dist/records.d.ts +241 -150
- package/dist/records.js +507 -291
- package/dist/runtime/addon.d.ts +14 -0
- package/dist/runtime/addon.js +69 -0
- package/dist/runtime/bun.js +5 -7
- package/dist/runtime/node.js +5 -7
- package/dist/runtime/pipe.d.ts +17 -0
- package/dist/runtime/pipe.js +133 -0
- package/dist/runtime/shared.d.ts +6 -0
- package/dist/runtime/shared.js +19 -0
- package/dist/runtime.d.ts +5 -2
- package/dist/search.d.ts +189 -0
- package/dist/search.js +281 -0
- package/dist/session.d.ts +31 -3
- package/dist/session.js +153 -41
- package/dist/sql.d.ts +228 -78
- package/dist/sql.js +745 -240
- package/dist/store.d.ts +244 -24
- package/dist/store.js +270 -67
- package/dist/time.d.ts +5 -1
- package/dist/time.js +22 -2
- package/dist/tx.d.ts +61 -0
- package/dist/tx.js +314 -0
- package/dist/wire/codec.d.ts +23 -7
- package/dist/wire/codec.js +56 -35
- package/dist/wire/frame.d.ts +2 -0
- package/dist/wire/frame.js +31 -14
- package/dist/wire/messages.d.ts +259 -0
- package/dist/wire/messages.js +22 -0
- package/dist/wire/msgpack.d.ts +49 -1
- package/dist/wire/msgpack.js +293 -56
- package/dist/wire/protocol.d.ts +2683 -0
- package/dist/wire/protocol.js +10846 -0
- package/package.json +39 -38
- package/src/backup.ts +81 -0
- package/src/blobs.ts +678 -301
- package/src/channels.ts +377 -0
- package/src/clock.ts +4 -4
- package/src/config.ts +902 -612
- package/src/connection.ts +279 -21
- package/src/console.ts +180 -12
- package/src/dotenv.ts +82 -0
- package/src/errors.ts +105 -0
- package/src/handles.ts +157 -8
- package/src/index.ts +158 -52
- package/src/instruments.ts +1042 -0
- package/src/jobs.ts +1017 -733
- package/src/json.ts +133 -0
- package/src/kv.ts +424 -847
- package/src/limits.ts +202 -0
- package/src/locks.ts +320 -0
- package/src/logger.ts +209 -40
- package/src/metrics.ts +557 -752
- package/src/once.ts +86 -83
- package/src/query.ts +1005 -0
- package/src/records.ts +795 -418
- package/src/runtime/addon.ts +99 -0
- package/src/runtime/bun.ts +5 -7
- package/src/runtime/node.ts +5 -7
- package/src/runtime/pipe.ts +178 -0
- package/src/runtime/shared.ts +20 -0
- package/src/runtime.ts +5 -2
- package/src/search.ts +480 -0
- package/src/session.ts +187 -41
- package/src/sql.ts +993 -306
- package/src/store.ts +473 -78
- package/src/time.ts +48 -3
- package/src/tx.ts +426 -0
- package/src/wire/codec.ts +78 -37
- package/src/wire/frame.ts +44 -14
- package/src/wire/messages.ts +25 -0
- package/src/wire/msgpack.ts +327 -56
- package/src/wire/protocol.ts +11709 -0
- package/dist/limiter.d.ts +0 -45
- package/dist/limiter.js +0 -68
- package/dist/quota.d.ts +0 -44
- package/dist/quota.js +0 -98
- package/src/limiter.ts +0 -99
- package/src/quota.ts +0 -137
package/dist/metrics.d.ts
CHANGED
|
@@ -1,249 +1,250 @@
|
|
|
1
1
|
import { type Link } from './connection.ts';
|
|
2
|
-
import { type
|
|
3
|
-
import { type Duration, type Time } from './time.ts';
|
|
4
|
-
export type
|
|
2
|
+
import { Counter, Gauge, type GaugeFuncOptions, Histogram, type HistogramOptions, type InstrumentOptions, type Instruments, type LabelValue, Timer, type TimerOptions } from './instruments.ts';
|
|
3
|
+
import { type Duration, type DurationText, type Time } from './time.ts';
|
|
4
|
+
export { type Buckets, Counter, exponentialBuckets, Gauge, type GaugeFuncOptions, Histogram, type HistogramOptions, type InstrumentLabels, type InstrumentOptions, type LabelValue, Timer, type TimerOptions, Timing, } from './instruments.ts';
|
|
5
|
+
/** What a series' samples are. */
|
|
6
|
+
export type SeriesKind = 'gauge' | 'counter' | 'histogram';
|
|
7
|
+
/** What tells the series of one name apart: a host, a route, a status. */
|
|
8
|
+
export type Labels = Record<string, string>;
|
|
5
9
|
/**
|
|
6
|
-
* What
|
|
7
|
-
*
|
|
10
|
+
* What a label's value must be: a value, one of a list, none of them with
|
|
11
|
+
* `not` (or the label absent), or a prefix. A number or a boolean is its
|
|
12
|
+
* text, as in an instrument's `with`.
|
|
8
13
|
*/
|
|
9
|
-
export type
|
|
14
|
+
export type Condition = LabelValue | readonly LabelValue[] | {
|
|
15
|
+
not: LabelValue | readonly LabelValue[];
|
|
16
|
+
} | {
|
|
17
|
+
prefix: string;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* The series a call finds and its range: `{ name: 'cpu', where: { host:
|
|
21
|
+
* 'web-1' }, since: '1h' }`. A query is data, the same in every language.
|
|
22
|
+
*/
|
|
23
|
+
export interface Query {
|
|
24
|
+
/** the series of this name; a timer's name, the series it writes */
|
|
25
|
+
name?: string | undefined;
|
|
26
|
+
where?: Record<string, Condition> | undefined;
|
|
27
|
+
/** the span before now the range covers; or from and to */
|
|
28
|
+
since?: Duration | undefined;
|
|
29
|
+
/** the range's start, included */
|
|
30
|
+
from?: Time | undefined;
|
|
31
|
+
/** the range's end, excluded; now, a sample taken now in the range, unless given */
|
|
32
|
+
to?: Time | undefined;
|
|
33
|
+
}
|
|
34
|
+
/** A series to write: its samples as [time, value] pairs, or as times and values columns. */
|
|
10
35
|
export interface SeriesInput {
|
|
11
|
-
/** the metric: 'http_requests_total' */
|
|
12
36
|
name: string;
|
|
13
37
|
kind: SeriesKind;
|
|
14
|
-
labels?:
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
38
|
+
labels?: Record<string, LabelValue>;
|
|
39
|
+
samples?: readonly (readonly [time: Time, value: number])[];
|
|
40
|
+
times?: readonly Time[] | Float64Array;
|
|
41
|
+
values?: readonly number[] | Float64Array;
|
|
42
|
+
/** how long the name's samples stay: its own, kept in the file; unless given, what it keeps already */
|
|
43
|
+
keep?: Duration | undefined;
|
|
20
44
|
}
|
|
45
|
+
/** A series as a read gives it: its samples as two columns. */
|
|
21
46
|
export interface Series {
|
|
22
47
|
name: string;
|
|
23
48
|
kind: SeriesKind;
|
|
24
49
|
labels: Labels;
|
|
25
|
-
/** unix milliseconds, in
|
|
26
|
-
times:
|
|
27
|
-
/** the values,
|
|
50
|
+
/** unix milliseconds, in the order of their times */
|
|
51
|
+
times: Float64Array;
|
|
52
|
+
/** the values, whose bytes keep each one's bits: -0 and a NaN's payload survive */
|
|
28
53
|
values: Float64Array;
|
|
29
54
|
}
|
|
55
|
+
/** p and a rank: 'p95', 'p99.9'. The ranks offered are those asked most; any other is written the same way. */
|
|
56
|
+
export type Percentile = 'p50' | 'p75' | 'p90' | 'p95' | 'p99' | 'p99.9' | (`p${number}` & Record<never, never>);
|
|
57
|
+
/** What a bucket answers: count … last, or a percentile; rate is a second's increase. */
|
|
58
|
+
export type Op = 'count' | 'sum' | 'avg' | 'min' | 'max' | 'increase' | 'rate' | 'delta' | 'first' | 'last' | Percentile;
|
|
59
|
+
/** An aggregate: a query cut into buckets of every, each one exact value of op, by groups. */
|
|
60
|
+
export interface AggregateQuery<O extends Op = Op> extends Query {
|
|
61
|
+
/** the buckets' span, counted from 1970 in UTC; the range is one bucket without it */
|
|
62
|
+
every?: Duration | undefined;
|
|
63
|
+
op: O;
|
|
64
|
+
/** the labels a group keeps; without by and without, every series of a name is one group */
|
|
65
|
+
by?: readonly string[] | undefined;
|
|
66
|
+
/** the labels a group leaves out, keeping every other; [] keeps every series apart */
|
|
67
|
+
without?: readonly string[] | undefined;
|
|
68
|
+
/** a timer's percentile also gives a point between its bounds, interpolated: an estimate */
|
|
69
|
+
estimate?: boolean | undefined;
|
|
70
|
+
}
|
|
71
|
+
/** What every bucket of an aggregate says of itself. */
|
|
72
|
+
interface Spanned {
|
|
73
|
+
/** where it begins */
|
|
74
|
+
at: Date;
|
|
75
|
+
/** how many samples it comes from; a timer's, how many durations */
|
|
76
|
+
samples: number;
|
|
77
|
+
resets: number;
|
|
78
|
+
/** its value comes from less than its span: the range, the clock or retention cut it */
|
|
79
|
+
partial: boolean;
|
|
80
|
+
/** its first step began before the bucket before it: a whole bucket between had no samples */
|
|
81
|
+
gap: boolean;
|
|
82
|
+
}
|
|
83
|
+
/** A bucket of count … last: its one exact value. */
|
|
84
|
+
export interface ValueBucket extends Spanned {
|
|
85
|
+
value: number;
|
|
86
|
+
}
|
|
30
87
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* ```ts
|
|
35
|
-
* { name: 'cpu', since: '1h' } // the last hour of every cpu series
|
|
36
|
-
* { match: { host: 'web-1' }, from: start, to: end } // every series of web-1
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
/**
|
|
40
|
-
* What a label's value must be beyond equality, made by oneOf, noneOf or
|
|
41
|
-
* prefix: an object of the SDK's own, so that a stored value is never read as
|
|
42
|
-
* a query.
|
|
88
|
+
* A bucket of a percentile: a gauge's sample at the rank, as value, or a
|
|
89
|
+
* timer's bucket of its spread that holds it, from lower to upper, and with
|
|
90
|
+
* estimate asked a point between them.
|
|
43
91
|
*/
|
|
44
|
-
export
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
export
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
/**
|
|
92
|
+
export interface PercentileBucket extends Spanned {
|
|
93
|
+
value?: number;
|
|
94
|
+
lower?: number;
|
|
95
|
+
/** Infinity past the last bound */
|
|
96
|
+
upper?: number;
|
|
97
|
+
estimate?: number;
|
|
98
|
+
}
|
|
99
|
+
/** A bucket of an aggregate of op: a value, or what a percentile gives. */
|
|
100
|
+
export type Bucket<O extends Op = Op> = O extends Percentile ? PercentileBucket : ValueBucket;
|
|
101
|
+
export interface Aggregate<O extends Op = Op> {
|
|
102
|
+
name: string;
|
|
103
|
+
/** the labels by kept or without left */
|
|
104
|
+
labels: Labels;
|
|
105
|
+
/** a bucket without samples is left out */
|
|
106
|
+
buckets: Bucket<O>[];
|
|
107
|
+
}
|
|
108
|
+
/** A series' newest sample in the range. */
|
|
109
|
+
export interface Newest {
|
|
110
|
+
name: string;
|
|
111
|
+
labels: Labels;
|
|
112
|
+
at: Date;
|
|
113
|
+
value: number;
|
|
114
|
+
}
|
|
115
|
+
/** What a read or an aggregate would spend of each bound, and the bound it would stop at. */
|
|
56
116
|
export interface Plan {
|
|
57
117
|
series: number;
|
|
58
|
-
blocks: number;
|
|
59
|
-
/** the blocks an aggregate answers from their summaries, decoding none of their samples */
|
|
60
|
-
summarized: number;
|
|
61
118
|
bytes: number;
|
|
62
119
|
decoded: number;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
answered: number;
|
|
69
|
-
};
|
|
70
|
-
/** the limit the call would reach, which it would end with; undefined when it fits */
|
|
71
|
-
stops: LimitError | undefined;
|
|
72
|
-
}
|
|
73
|
-
export interface Range {
|
|
74
|
-
name?: string;
|
|
75
|
-
/** labels a series holds, each exactly */
|
|
76
|
-
match?: Labels;
|
|
77
|
-
/**
|
|
78
|
-
* labels under a condition: `{ status: oneOf('500', '502'), env: noneOf('dev'), host: prefix('api-') }`;
|
|
79
|
-
* a plain value is equality. A range of noneOf alone is refused, since it would scan every series.
|
|
80
|
-
*/
|
|
81
|
-
where?: Record<string, Condition | string>;
|
|
82
|
-
/** the span before now the range covers: '1h', '15m', or milliseconds */
|
|
83
|
-
since?: Duration;
|
|
84
|
-
/** the range's start, included; the oldest sample kept when absent */
|
|
85
|
-
from?: Time;
|
|
86
|
-
/** excluded; the open end when absent */
|
|
87
|
-
to?: Time;
|
|
88
|
-
/** each narrows the server's: series matched, blocks decoded, bytes fetched, samples decoded, answered */
|
|
89
|
-
limits?: {
|
|
90
|
-
series?: number;
|
|
91
|
-
blocks?: number;
|
|
92
|
-
bytes?: number;
|
|
93
|
-
decoded?: number;
|
|
94
|
-
answered?: number;
|
|
95
|
-
};
|
|
120
|
+
exceeds: {
|
|
121
|
+
limit: string;
|
|
122
|
+
wanted: number;
|
|
123
|
+
bound: number;
|
|
124
|
+
} | undefined;
|
|
96
125
|
}
|
|
97
|
-
/**
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
* An aggregate's buckets and, to join series, what groups them: by these
|
|
105
|
-
* labels, or without them, each group one result. `by: []` joins every series
|
|
106
|
-
* of a name. A group never joins two names or two kinds.
|
|
107
|
-
*/
|
|
108
|
-
export interface AggregateRange extends Range {
|
|
109
|
-
width: Duration;
|
|
110
|
-
op: AggregateOp;
|
|
111
|
-
by?: string[];
|
|
112
|
-
without?: string[];
|
|
113
|
-
}
|
|
114
|
-
export interface Bucket {
|
|
115
|
-
from: Date;
|
|
116
|
-
to: Date;
|
|
117
|
-
/** the samples it counted */
|
|
118
|
-
count: number;
|
|
119
|
-
/** the resets among them, a counter's */
|
|
120
|
-
resets: number;
|
|
121
|
-
/** computed exactly and rounded once */
|
|
122
|
-
value: number;
|
|
123
|
-
/** the value overflowed to an infinity */
|
|
124
|
-
overflow: boolean;
|
|
125
|
-
/** retention cut the bucket, which counted only its samples from the cutoff on */
|
|
126
|
-
partial: boolean;
|
|
126
|
+
/** A page's options: a prefix, how many, and where the page before ended. */
|
|
127
|
+
export interface PageOptions {
|
|
128
|
+
prefix?: string | undefined;
|
|
129
|
+
/** 1000 unless given, 10,000 at most */
|
|
130
|
+
limit?: number | undefined;
|
|
131
|
+
/** a page's next, so that a page's options can be the one before's */
|
|
132
|
+
after?: string | undefined;
|
|
127
133
|
}
|
|
128
|
-
|
|
134
|
+
/** A name the store holds samples of. */
|
|
135
|
+
export interface NameInfo {
|
|
129
136
|
name: string;
|
|
130
137
|
kind: SeriesKind;
|
|
138
|
+
seriesCount: number;
|
|
139
|
+
unit: string;
|
|
140
|
+
help: string;
|
|
141
|
+
keep: DurationText;
|
|
142
|
+
/** its oldest sample, or where its keep begins while it holds samples from before */
|
|
143
|
+
retainedFrom: Date;
|
|
144
|
+
newest: Date;
|
|
145
|
+
}
|
|
146
|
+
export interface NamePage {
|
|
147
|
+
names: NameInfo[];
|
|
148
|
+
/** where the next page starts; none on the last */
|
|
149
|
+
next?: string;
|
|
150
|
+
}
|
|
151
|
+
export interface LabelPage {
|
|
152
|
+
labels: string[];
|
|
153
|
+
next?: string;
|
|
154
|
+
}
|
|
155
|
+
export interface ValuePage {
|
|
156
|
+
values: string[];
|
|
157
|
+
next?: string;
|
|
158
|
+
}
|
|
159
|
+
/** A name's unit and help; empty ones remove them. */
|
|
160
|
+
export interface Description {
|
|
161
|
+
unit?: string;
|
|
162
|
+
help?: string;
|
|
163
|
+
}
|
|
164
|
+
/** A series whose bytes no longer read, which delete removes. */
|
|
165
|
+
export interface Damage {
|
|
166
|
+
name: string;
|
|
131
167
|
labels: Labels;
|
|
132
|
-
|
|
133
|
-
buckets: Bucket[];
|
|
168
|
+
error: string;
|
|
134
169
|
}
|
|
170
|
+
/**
|
|
171
|
+
* A store's metrics: series by name and labels, their reads and aggregates,
|
|
172
|
+
* what the store holds of them, and the program's instruments.
|
|
173
|
+
*/
|
|
135
174
|
export declare class Metrics {
|
|
136
175
|
#private;
|
|
137
|
-
/**
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
constructor(link: Link);
|
|
141
|
-
/** Stores series and their samples, all or none; a refused series is named by its labels. */
|
|
176
|
+
/** The store's close stops instruments, sending what they changed last. */
|
|
177
|
+
constructor(link: Link, instruments: Instruments);
|
|
178
|
+
/** Writes series and their samples, every one or none: a refused series names itself. */
|
|
142
179
|
ingest(series: SeriesInput | readonly SeriesInput[]): Promise<void>;
|
|
143
|
-
/**
|
|
144
|
-
read(
|
|
145
|
-
/**
|
|
146
|
-
|
|
180
|
+
/** The samples of each series the query finds, in its range: whole, or a limit error naming its bound. */
|
|
181
|
+
read(query: Query): Promise<Series[]>;
|
|
182
|
+
/** The newest sample of each series the query finds, when it has one in the range. */
|
|
183
|
+
latest(query: Query): Promise<Newest[]>;
|
|
147
184
|
/**
|
|
148
|
-
*
|
|
149
|
-
* of
|
|
150
|
-
* series, the blocks, those an aggregate answers from their summaries, the
|
|
151
|
-
* bytes and the samples, beside the limits; stops is the LimitError the
|
|
152
|
-
* call would end with, undefined when it fits.
|
|
185
|
+
* The buckets of each group of the series the query finds, each one exact
|
|
186
|
+
* value of op, rounded once; a bucket of count … last has its value.
|
|
153
187
|
*/
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
188
|
+
aggregate<O extends Op>(query: AggregateQuery<O>): Promise<Aggregate<O>[]>;
|
|
189
|
+
/** What a read, or an aggregate when given its op, would spend of each bound; it decodes no sample. */
|
|
190
|
+
explain(query: Query & Partial<Omit<AggregateQuery, keyof Query>>): Promise<Plan>;
|
|
191
|
+
/** A page of the names the store holds samples of, in the byte order of their text. */
|
|
192
|
+
names(options?: PageOptions): Promise<NamePage>;
|
|
193
|
+
/** A page of a name's label names, but the store's own. */
|
|
194
|
+
labelNames(name: string, options?: PageOptions): Promise<LabelPage>;
|
|
195
|
+
/** A page of the values a label of a name's series holds. */
|
|
196
|
+
labelValues(name: string, label: string, options?: PageOptions): Promise<ValuePage>;
|
|
197
|
+
/**
|
|
198
|
+
* Sets a name's unit and help in place of what it had, as the Rust metrics
|
|
199
|
+
* crate's describe_counter! does: what is not given is removed, and `{}`
|
|
200
|
+
* removes both. They belong to the name, so a delete of its series leaves them.
|
|
201
|
+
*/
|
|
202
|
+
describe(name: string, description: Description): Promise<void>;
|
|
203
|
+
/** A name's unit and help; both empty when nothing described it. */
|
|
204
|
+
description(name: string): Promise<{
|
|
205
|
+
unit: string;
|
|
206
|
+
help: string;
|
|
162
207
|
}>;
|
|
163
|
-
/** A counter: its total since this process started, ingested every flush; a restart is a reset. */
|
|
164
|
-
counter(name: string): Counter;
|
|
165
|
-
/** A gauge: its value at each flush. */
|
|
166
|
-
gauge(name: string): Gauge;
|
|
167
|
-
/** A gauge read by a function at each flush; a function that throws skips that sample. */
|
|
168
|
-
gaugeFunc(name: string, read: () => number | Promise<number>): void;
|
|
169
208
|
/**
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
* measured none. A range's mean is its sum's increase over its count's.
|
|
209
|
+
* Removes the one series of exactly this name and these labels, no more
|
|
210
|
+
* and no fewer, with every sample it holds, whether they still read or
|
|
211
|
+
* not; true when the store held it. `labels: {}` is the series without labels.
|
|
174
212
|
*/
|
|
175
|
-
|
|
213
|
+
delete(series: {
|
|
214
|
+
name: string;
|
|
215
|
+
labels: Record<string, LabelValue>;
|
|
216
|
+
}): Promise<boolean>;
|
|
176
217
|
/**
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
218
|
+
* The series whose bytes no longer read, 1000 at most, each with what
|
|
219
|
+
* broke; deleting them shows the next.
|
|
220
|
+
*
|
|
221
|
+
* for (let damaged = await store.metrics.damaged(); damaged.length > 0; damaged = await store.metrics.damaged()) {
|
|
222
|
+
* for (const series of damaged) await store.metrics.delete(series)
|
|
223
|
+
* }
|
|
180
224
|
*/
|
|
225
|
+
damaged(): Promise<Damage[]>;
|
|
226
|
+
/** Sends what every instrument changed and has the store write its totals now, as it does every 15 seconds. */
|
|
181
227
|
flush(): Promise<void>;
|
|
182
|
-
/** Stops flushing every 15 s and ingests the instruments' last values; the store's close calls it. */
|
|
183
|
-
stop(): Promise<void>;
|
|
184
|
-
get instruments(): number;
|
|
185
|
-
}
|
|
186
|
-
interface Instrument {
|
|
187
|
-
name: string;
|
|
188
|
-
kind: SeriesKind;
|
|
189
|
-
/** by the canonical spelling of each label set */
|
|
190
|
-
series: Map<string, {
|
|
191
|
-
labels: Labels;
|
|
192
|
-
value: number;
|
|
193
|
-
}>;
|
|
194
|
-
/** the spellings of the label sets the store refused, whose writes are left out */
|
|
195
|
-
refused: Set<string>;
|
|
196
|
-
read?: () => number | Promise<number>;
|
|
197
|
-
/** the error a gauge's function last threw, said once while it stays the same */
|
|
198
|
-
lastRead: string | undefined;
|
|
199
|
-
}
|
|
200
|
-
interface TimerInstrument {
|
|
201
|
-
name: string;
|
|
202
|
-
/** by the canonical spelling of each label set */
|
|
203
|
-
series: Map<string, Timing>;
|
|
204
|
-
refused: Set<string>;
|
|
205
|
-
}
|
|
206
|
-
interface Timing {
|
|
207
|
-
labels: Labels;
|
|
208
|
-
count: number;
|
|
209
|
-
/** milliseconds */
|
|
210
|
-
sum: number;
|
|
211
|
-
/** milliseconds, since the flush before */
|
|
212
|
-
longest: number;
|
|
213
|
-
/** since the flush before */
|
|
214
|
-
measured: boolean;
|
|
215
|
-
}
|
|
216
|
-
export declare class Counter {
|
|
217
|
-
#private;
|
|
218
|
-
constructor(instrument: Instrument, labels: Labels);
|
|
219
|
-
/** The counter of these labels besides its own: the same labels in any order are one series. */
|
|
220
|
-
with(labels: Labels): Counter;
|
|
221
|
-
inc(): void;
|
|
222
|
-
add(n: number): void;
|
|
223
|
-
}
|
|
224
|
-
export declare class Gauge {
|
|
225
|
-
#private;
|
|
226
|
-
constructor(instrument: Instrument, labels: Labels);
|
|
227
|
-
with(labels: Labels): Gauge;
|
|
228
|
-
set(value: number): void;
|
|
229
|
-
add(n: number): void;
|
|
230
|
-
inc(): void;
|
|
231
|
-
dec(): void;
|
|
232
|
-
}
|
|
233
|
-
/** A timer of labels; record and measure add a duration to the next flush. */
|
|
234
|
-
export declare class Timer {
|
|
235
|
-
#private;
|
|
236
|
-
constructor(timer: TimerInstrument, labels: Labels);
|
|
237
|
-
/** The timer of these labels besides its own: the same labels in any order are one series. */
|
|
238
|
-
with(labels: Labels): Timer;
|
|
239
|
-
/** Adds one duration: milliseconds, their fractions kept, or text such as '250ms'. */
|
|
240
|
-
record(d: Duration): void;
|
|
241
228
|
/**
|
|
242
|
-
*
|
|
243
|
-
*
|
|
229
|
+
* A total that only goes up, which the store keeps: processes counting
|
|
230
|
+
* into one series count into one total. Its label names, when given,
|
|
231
|
+
* `counter<'route' | 'status'>(…)`, are the only ones `with` compiles with.
|
|
232
|
+
*/
|
|
233
|
+
counter<L extends string = string>(name: string, options?: InstrumentOptions): Counter<L>;
|
|
234
|
+
/** A value that goes up and down: a queue's length, a temperature. */
|
|
235
|
+
gauge<L extends string = string>(name: string, options?: InstrumentOptions): Gauge<L>;
|
|
236
|
+
/**
|
|
237
|
+
* A gauge whose value read gives every 15 seconds, of the set of labels
|
|
238
|
+
* given; another set of the name takes a function of its own, and a set
|
|
239
|
+
* is read by one. It may be async, is never called again while a call of
|
|
240
|
+
* it runs, and an error or an answer that is not a number writes nothing
|
|
241
|
+
* that time, said once while it repeats.
|
|
244
242
|
*
|
|
245
|
-
*
|
|
243
|
+
* store.metrics.gaugeFunc('queue_depth', () => emails.depth(), { labels: { queue: 'emails' } })
|
|
246
244
|
*/
|
|
247
|
-
|
|
245
|
+
gaugeFunc(name: string, read: () => number | Promise<number>, options?: GaugeFuncOptions): void;
|
|
246
|
+
/** How many things took how long: their count, sum and longest in milliseconds, and with buckets their spread. */
|
|
247
|
+
timer<L extends string = string>(name: string, options?: TimerOptions): Timer<L>;
|
|
248
|
+
/** A timer of numbers that are not durations: a response's size in bytes. */
|
|
249
|
+
histogram<L extends string = string>(name: string, options?: HistogramOptions): Histogram<L>;
|
|
248
250
|
}
|
|
249
|
-
export {};
|