@procedures/sink 0.0.0-bootstrap.0 → 0.68.18
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/CHANGELOG.md +13 -0
- package/LICENSE +21 -0
- package/README.md +78 -1
- package/dist/api.d.ts +95 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +170 -0
- package/dist/api.js.map +1 -0
- package/dist/call.d.ts +42 -0
- package/dist/call.d.ts.map +1 -0
- package/dist/call.js +44 -0
- package/dist/call.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/module.d.ts +32 -0
- package/dist/module.d.ts.map +1 -0
- package/dist/module.js +97 -0
- package/dist/module.js.map +1 -0
- package/dist/procedures/sink/errors.d.ts +8 -0
- package/dist/procedures/sink/errors.d.ts.map +1 -0
- package/dist/procedures/sink/errors.js +9 -0
- package/dist/procedures/sink/errors.js.map +1 -0
- package/dist/procedures/sink/index.d.ts +6 -0
- package/dist/procedures/sink/index.d.ts.map +1 -0
- package/dist/procedures/sink/index.js +6 -0
- package/dist/procedures/sink/index.js.map +1 -0
- package/dist/procedures/sink/services.d.ts +8 -0
- package/dist/procedures/sink/services.d.ts.map +1 -0
- package/dist/procedures/sink/services.js +9 -0
- package/dist/procedures/sink/services.js.map +1 -0
- package/dist/procedures/sink/slowest.d.ts +8 -0
- package/dist/procedures/sink/slowest.d.ts.map +1 -0
- package/dist/procedures/sink/slowest.js +9 -0
- package/dist/procedures/sink/slowest.js.map +1 -0
- package/dist/procedures/sink/stats.d.ts +8 -0
- package/dist/procedures/sink/stats.d.ts.map +1 -0
- package/dist/procedures/sink/stats.js +9 -0
- package/dist/procedures/sink/stats.js.map +1 -0
- package/dist/procedures/sink/trace.d.ts +8 -0
- package/dist/procedures/sink/trace.d.ts.map +1 -0
- package/dist/procedures/sink/trace.js +9 -0
- package/dist/procedures/sink/trace.js.map +1 -0
- package/dist/register.d.ts +6 -0
- package/dist/register.d.ts.map +1 -0
- package/dist/register.js +8 -0
- package/dist/register.js.map +1 -0
- package/dist/types.d.ts +140 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +98 -0
- package/dist/types.js.map +1 -0
- package/package.json +76 -5
- package/src/api.ts +217 -0
- package/src/call.ts +69 -0
- package/src/index.ts +6 -0
- package/src/module.ts +150 -0
- package/src/procedures/sink/errors.ts +11 -0
- package/src/procedures/sink/index.ts +5 -0
- package/src/procedures/sink/services.ts +11 -0
- package/src/procedures/sink/slowest.ts +11 -0
- package/src/procedures/sink/stats.ts +11 -0
- package/src/procedures/sink/trace.ts +11 -0
- package/src/register.ts +10 -0
- package/src/types.ts +234 -0
package/dist/module.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The procedures of @procedures/sink as data. An import of this file registers nothing.
|
|
3
|
+
*
|
|
4
|
+
* Each procedure reads one query route of the OTLP sink over HTTP. It changes nothing in the sink.
|
|
5
|
+
*/
|
|
6
|
+
import { createProcedure, defineModule, registerModules, PROCEDURE_REGISTRY, } from "@procedures/client";
|
|
7
|
+
import { defaultSinkFetch } from "./call.js";
|
|
8
|
+
import { sinkErrors } from "./procedures/sink/errors.js";
|
|
9
|
+
import { sinkServices } from "./procedures/sink/services.js";
|
|
10
|
+
import { sinkSlowest } from "./procedures/sink/slowest.js";
|
|
11
|
+
import { sinkStats } from "./procedures/sink/stats.js";
|
|
12
|
+
import { sinkTrace } from "./procedures/sink/trace.js";
|
|
13
|
+
import { SinkErrorsInputSchema, SinkErrorsOutputSchema, SinkServicesInputSchema, SinkServicesOutputSchema, SinkSlowestInputSchema, SinkSlowestOutputSchema, SinkStatsInputSchema, SinkStatsOutputSchema, SinkTraceInputSchema, SinkTraceOutputSchema, } from "./types.js";
|
|
14
|
+
/** The name of the module */
|
|
15
|
+
const NAME = "@procedures/sink";
|
|
16
|
+
/** The effects of each procedure: a read over the network, and no write. The sink is idempotent for each query. */
|
|
17
|
+
export const SINK_EFFECTS = { reads: ["network"], writes: [], idempotent: true };
|
|
18
|
+
/** This function gives the procedures of this package with the settings of the host. */
|
|
19
|
+
export function createSinkProcedures(options = {}) {
|
|
20
|
+
const fetch = options.fetch ?? defaultSinkFetch();
|
|
21
|
+
const context = (ctx) => ({ fetch, signal: ctx?.signal });
|
|
22
|
+
const slowest = createProcedure()
|
|
23
|
+
.path(["sink", "slowest"])
|
|
24
|
+
.input(SinkSlowestInputSchema)
|
|
25
|
+
.output(SinkSlowestOutputSchema)
|
|
26
|
+
.meta({
|
|
27
|
+
description: "Give the slowest spans of a window from the OTLP sink, the slowest first",
|
|
28
|
+
output: "json",
|
|
29
|
+
effects: SINK_EFFECTS,
|
|
30
|
+
})
|
|
31
|
+
.handler(async (input, ctx) => sinkSlowest(input, context(ctx)))
|
|
32
|
+
.build();
|
|
33
|
+
const errors = createProcedure()
|
|
34
|
+
.path(["sink", "errors"])
|
|
35
|
+
.input(SinkErrorsInputSchema)
|
|
36
|
+
.output(SinkErrorsOutputSchema)
|
|
37
|
+
.meta({
|
|
38
|
+
description: "Give the failed spans and the error logs of a window from the OTLP sink, the newest first",
|
|
39
|
+
output: "json",
|
|
40
|
+
effects: SINK_EFFECTS,
|
|
41
|
+
})
|
|
42
|
+
.handler(async (input, ctx) => sinkErrors(input, context(ctx)))
|
|
43
|
+
.build();
|
|
44
|
+
const services = createProcedure()
|
|
45
|
+
.path(["sink", "services"])
|
|
46
|
+
.input(SinkServicesInputSchema)
|
|
47
|
+
.output(SinkServicesOutputSchema)
|
|
48
|
+
.meta({
|
|
49
|
+
description: "Give the span counts and the error rate of each service in a window from the OTLP sink",
|
|
50
|
+
output: "json",
|
|
51
|
+
effects: SINK_EFFECTS,
|
|
52
|
+
})
|
|
53
|
+
.handler(async (input, ctx) => sinkServices(input, context(ctx)))
|
|
54
|
+
.build();
|
|
55
|
+
const trace = createProcedure()
|
|
56
|
+
.path(["sink", "trace"])
|
|
57
|
+
.input(SinkTraceInputSchema)
|
|
58
|
+
.output(SinkTraceOutputSchema)
|
|
59
|
+
.meta({
|
|
60
|
+
description: "Give the spans and the logs of one trace from the OTLP sink, in the order of their times",
|
|
61
|
+
args: ["id"],
|
|
62
|
+
output: "json",
|
|
63
|
+
effects: SINK_EFFECTS,
|
|
64
|
+
})
|
|
65
|
+
.handler(async (input, ctx) => sinkTrace(input, context(ctx)))
|
|
66
|
+
.build();
|
|
67
|
+
const stats = createProcedure()
|
|
68
|
+
.path(["sink", "stats"])
|
|
69
|
+
.input(SinkStatsInputSchema)
|
|
70
|
+
.output(SinkStatsOutputSchema)
|
|
71
|
+
.meta({
|
|
72
|
+
description: "Give how much telemetry the OTLP sink stores: the rows and bytes of each signal, the file size and the retention rules",
|
|
73
|
+
output: "json",
|
|
74
|
+
effects: SINK_EFFECTS,
|
|
75
|
+
})
|
|
76
|
+
.handler(async (input, ctx) => sinkStats(input, context(ctx)))
|
|
77
|
+
.build();
|
|
78
|
+
return [slowest, errors, services, trace, stats];
|
|
79
|
+
}
|
|
80
|
+
export const sinkModule = defineModule(NAME, createSinkProcedures());
|
|
81
|
+
export default sinkModule;
|
|
82
|
+
/**
|
|
83
|
+
* This function gives the module with the settings of the host: the `fetch` of the requests. Without options, it
|
|
84
|
+
* gives `sinkModule`.
|
|
85
|
+
*/
|
|
86
|
+
export function createSinkModule(options = {}) {
|
|
87
|
+
if (options.fetch === undefined)
|
|
88
|
+
return sinkModule;
|
|
89
|
+
return defineModule(NAME, createSinkProcedures(options));
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* This function registers the procedures of @procedures/sink in a registry. The default is the global registry.
|
|
93
|
+
*/
|
|
94
|
+
export function registerSinkProcedures(registry = PROCEDURE_REGISTRY) {
|
|
95
|
+
registerModules(registry, [sinkModule]);
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.js","sour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AsB,kBAAkB;IACrF,eAAe,CAAC,QAAQ,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;AAC1C,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The procedure `sink.errors`: the query `GET /api/errors` of the sink.
|
|
3
|
+
*/
|
|
4
|
+
import { type SinkContext } from "../../call.js";
|
|
5
|
+
import type { SinkErrorsInput, SinkErrorsOutput } from "../../types.js";
|
|
6
|
+
/** This function gives the spans with the status error and the error logs of the window, the newest first. */
|
|
7
|
+
export declare function sinkErrors(input: SinkErrorsInput, context: SinkContext): Promise<SinkErrorsOutput>;
|
|
8
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/procedures/sink/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAuB,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAExE,8GAA8G;AAC9G,wBAAsB,UAAU,CAAC,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAExG"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The procedure `sink.errors`: the query `GET /api/errors` of the sink.
|
|
3
|
+
*/
|
|
4
|
+
import { querySink, windowOf } from "../../call.js";
|
|
5
|
+
/** This function gives the spans with the status error and the error logs of the window, the newest first. */
|
|
6
|
+
export async function sinkErrors(input, context) {
|
|
7
|
+
return querySink(context.fetch, { route: "errors", window: windowOf(input) }, { ...input, signal: context.signal });
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/procedures/sink/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAoB,MAAM,eAAe,CAAC;AAGtE,8GAA8G;AAC9G,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,KAAsB,EAAE,OAAoB;IAC3E,OAAO,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,GAAG,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;AACtH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/procedures/sink/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/procedures/sink/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The procedure `sink.services`: the query `GET /api/services` of the sink.
|
|
3
|
+
*/
|
|
4
|
+
import { type SinkContext } from "../../call.js";
|
|
5
|
+
import type { SinkServicesInput, SinkServicesOutput } from "../../types.js";
|
|
6
|
+
/** This function gives the span counts of each service in the window, the most failed spans first. */
|
|
7
|
+
export declare function sinkServices(input: SinkServicesInput, context: SinkContext): Promise<SinkServicesOutput>;
|
|
8
|
+
//# sourceMappingURL=services.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"services.d.ts","sourceRoot":"","sources":["../../../src/procedures/sink/services.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAuB,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAE5E,sGAAsG;AACtG,wBAAsB,YAAY,CAAC,KAAK,EAAE,iBAAiB,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAE9G"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The procedure `sink.services`: the query `GET /api/services` of the sink.
|
|
3
|
+
*/
|
|
4
|
+
import { querySink, windowOf } from "../../call.js";
|
|
5
|
+
/** This function gives the span counts of each service in the window, the most failed spans first. */
|
|
6
|
+
export async function sinkServices(input, context) {
|
|
7
|
+
return querySink(context.fetch, { route: "services", window: windowOf(input) }, { ...input, signal: context.signal });
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=services.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"services.js","sourceRoot":"","sources":["../../../src/procedures/sink/services.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAoB,MAAM,eAAe,CAAC;AAGtE,sGAAsG;AACtG,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,KAAwB,EAAE,OAAoB;IAC/E,OAAO,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,GAAG,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;AACxH,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The procedure `sink.slowest`: the query `GET /api/slowest` of the sink.
|
|
3
|
+
*/
|
|
4
|
+
import { type SinkContext } from "../../call.js";
|
|
5
|
+
import type { SinkSlowestInput, SinkSlowestOutput } from "../../types.js";
|
|
6
|
+
/** This function gives the slowest spans that start in the window, the slowest first. */
|
|
7
|
+
export declare function sinkSlowest(input: SinkSlowestInput, context: SinkContext): Promise<SinkSlowestOutput>;
|
|
8
|
+
//# sourceMappingURL=slowest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slowest.d.ts","sourceRoot":"","sources":["../../../src/procedures/sink/slowest.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAuB,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAE1E,yFAAyF;AACzF,wBAAsB,WAAW,CAAC,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAE3G"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The procedure `sink.slowest`: the query `GET /api/slowest` of the sink.
|
|
3
|
+
*/
|
|
4
|
+
import { querySink, windowOf } from "../../call.js";
|
|
5
|
+
/** This function gives the slowest spans that start in the window, the slowest first. */
|
|
6
|
+
export async function sinkSlowest(input, context) {
|
|
7
|
+
return querySink(context.fetch, { route: "slowest", window: windowOf(input) }, { ...input, signal: context.signal });
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=slowest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slowest.js","sourceRoot":"","sources":["../../../src/procedures/sink/slowest.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAoB,MAAM,eAAe,CAAC;AAGtE,yFAAyF;AACzF,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,KAAuB,EAAE,OAAoB;IAC7E,OAAO,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,GAAG,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;AACvH,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The procedure `sink.stats`: the query `GET /api/stats` of the sink.
|
|
3
|
+
*/
|
|
4
|
+
import { type SinkContext } from "../../call.js";
|
|
5
|
+
import type { SinkStatsInput, SinkStatsOutput } from "../../types.js";
|
|
6
|
+
/** This function gives the rows and the bytes of each signal, the bytes of the file and the retention rules. */
|
|
7
|
+
export declare function sinkStats(input: SinkStatsInput, context: SinkContext): Promise<SinkStatsOutput>;
|
|
8
|
+
//# sourceMappingURL=stats.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stats.d.ts","sourceRoot":"","sources":["../../../src/procedures/sink/stats.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAa,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEtE,gHAAgH;AAChH,wBAAsB,SAAS,CAAC,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,eAAe,CAAC,CAErG"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The procedure `sink.stats`: the query `GET /api/stats` of the sink.
|
|
3
|
+
*/
|
|
4
|
+
import { querySink } from "../../call.js";
|
|
5
|
+
/** This function gives the rows and the bytes of each signal, the bytes of the file and the retention rules. */
|
|
6
|
+
export async function sinkStats(input, context) {
|
|
7
|
+
return querySink(context.fetch, { route: "stats" }, { ...input, signal: context.signal });
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=stats.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stats.js","sourceRoot":"","sources":["../../../src/procedures/sink/stats.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAoB,MAAM,eAAe,CAAC;AAG5D,gHAAgH;AAChH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,KAAqB,EAAE,OAAoB;IACzE,OAAO,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;AAC5F,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The procedure `sink.trace`: the query `GET /api/trace` of the sink.
|
|
3
|
+
*/
|
|
4
|
+
import { type SinkContext } from "../../call.js";
|
|
5
|
+
import type { SinkTraceInput, SinkTraceOutput } from "../../types.js";
|
|
6
|
+
/** This function gives the spans and the logs of one trace, in the order of their times. */
|
|
7
|
+
export declare function sinkTrace(input: SinkTraceInput, context: SinkContext): Promise<SinkTraceOutput>;
|
|
8
|
+
//# sourceMappingURL=trace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trace.d.ts","sourceRoot":"","sources":["../../../src/procedures/sink/trace.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAa,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEtE,4FAA4F;AAC5F,wBAAsB,SAAS,CAAC,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,eAAe,CAAC,CAErG"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The procedure `sink.trace`: the query `GET /api/trace` of the sink.
|
|
3
|
+
*/
|
|
4
|
+
import { querySink } from "../../call.js";
|
|
5
|
+
/** This function gives the spans and the logs of one trace, in the order of their times. */
|
|
6
|
+
export async function sinkTrace(input, context) {
|
|
7
|
+
return querySink(context.fetch, { route: "trace", id: input.id }, { ...input, signal: context.signal });
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=trace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trace.js","sourceRoot":"","sources":["../../../src/procedures/sink/trace.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAoB,MAAM,eAAe,CAAC;AAG5D,4FAA4F;AAC5F,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,KAAqB,EAAE,OAAoB;IACzE,OAAO,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,EAAE,EAAE,GAAG,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;AAC1G,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../src/register.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,cAAc,aAAa,CAAC"}
|
package/dist/register.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An import of this file registers the procedures of @procedures/sink in the global registry:
|
|
3
|
+
* `import "@procedures/sink/register"`. The package root registers nothing.
|
|
4
|
+
*/
|
|
5
|
+
import { registerSinkProcedures } from "./module.js";
|
|
6
|
+
export * from "./module.js";
|
|
7
|
+
registerSinkProcedures();
|
|
8
|
+
//# sourceMappingURL=register.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register.js","sourceRoot":"","sources":["../src/register.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAErD,cAAc,aAAa,CAAC;AAE5B,sBAAsB,EAAE,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The types and the Zod schemas of the procedures of this package: the inputs of the five queries, and the answers
|
|
3
|
+
* of the sink. Each time in an answer is in milliseconds since the epoch, and each duration is in milliseconds.
|
|
4
|
+
*/
|
|
5
|
+
import * as z from "zod";
|
|
6
|
+
/** The base URL of the sink on this computer */
|
|
7
|
+
export declare const DEFAULT_SINK_URL = "http://127.0.0.1:4328";
|
|
8
|
+
/** The most rows of one answer of the sink */
|
|
9
|
+
export declare const MAX_LIMIT = 1000;
|
|
10
|
+
/** The most time of one query, in milliseconds */
|
|
11
|
+
export declare const MAX_TIMEOUT_MS = 120000;
|
|
12
|
+
/** The time limit of a query without `timeoutMs`, in milliseconds */
|
|
13
|
+
export declare const DEFAULT_TIMEOUT_MS = 10000;
|
|
14
|
+
/** The pattern of a trace id: 32 hex digits, in lowercase or in uppercase */
|
|
15
|
+
export declare const TRACE_ID_INPUT: RegExp;
|
|
16
|
+
/** The attributes of a span or of a log record. Each value is a JSON value. */
|
|
17
|
+
export type Attributes = {
|
|
18
|
+
readonly [key: string]: unknown;
|
|
19
|
+
};
|
|
20
|
+
/** A span in an answer of the sink */
|
|
21
|
+
export interface SpanView {
|
|
22
|
+
readonly traceId: string;
|
|
23
|
+
readonly spanId: string;
|
|
24
|
+
readonly parentId: string | null;
|
|
25
|
+
readonly service: string;
|
|
26
|
+
readonly name: string;
|
|
27
|
+
readonly kind: number | null;
|
|
28
|
+
readonly startMs: number;
|
|
29
|
+
readonly durationMs: number;
|
|
30
|
+
/** The status code of OTLP: 0 is unset, 1 is ok and 2 is error. */
|
|
31
|
+
readonly status: number;
|
|
32
|
+
readonly attributes: Attributes;
|
|
33
|
+
}
|
|
34
|
+
/** A log record in an answer of the sink */
|
|
35
|
+
export interface LogView {
|
|
36
|
+
readonly timeMs: number;
|
|
37
|
+
readonly service: string;
|
|
38
|
+
/** The severity number of OTLP. An error has 17 or more. */
|
|
39
|
+
readonly severity: number | null;
|
|
40
|
+
readonly body: string | null;
|
|
41
|
+
readonly traceId: string | null;
|
|
42
|
+
readonly spanId: string | null;
|
|
43
|
+
readonly attributes: Attributes;
|
|
44
|
+
}
|
|
45
|
+
/** The counts of the spans of one service */
|
|
46
|
+
export interface ServiceView {
|
|
47
|
+
readonly service: string;
|
|
48
|
+
readonly spans: number;
|
|
49
|
+
readonly failed: number;
|
|
50
|
+
/** The fraction of the spans with the status error */
|
|
51
|
+
readonly errorRate: number;
|
|
52
|
+
readonly slowestMs: number;
|
|
53
|
+
}
|
|
54
|
+
/** The rows and the bytes of one signal in the store */
|
|
55
|
+
export interface SignalSize {
|
|
56
|
+
readonly rows: number;
|
|
57
|
+
readonly bytes: number;
|
|
58
|
+
}
|
|
59
|
+
/** The retention rule of one signal: the oldest age and the most bytes */
|
|
60
|
+
export interface RetentionRule {
|
|
61
|
+
readonly maxAgeMs: number;
|
|
62
|
+
readonly maxBytes: number;
|
|
63
|
+
}
|
|
64
|
+
/** The three signals of the store */
|
|
65
|
+
export type Signal = "spans" | "logs" | "points";
|
|
66
|
+
/** The output of `sink.slowest`: the slowest spans that start in the window, the slowest first */
|
|
67
|
+
export interface SinkSlowestOutput {
|
|
68
|
+
readonly spans: readonly SpanView[];
|
|
69
|
+
}
|
|
70
|
+
/** The output of `sink.errors`: the spans with the status error and the error logs, the newest first */
|
|
71
|
+
export interface SinkErrorsOutput {
|
|
72
|
+
readonly spans: readonly SpanView[];
|
|
73
|
+
readonly logs: readonly LogView[];
|
|
74
|
+
}
|
|
75
|
+
/** The output of `sink.services`: the counts of each service, the most failed spans first */
|
|
76
|
+
export interface SinkServicesOutput {
|
|
77
|
+
readonly services: readonly ServiceView[];
|
|
78
|
+
}
|
|
79
|
+
/** The output of `sink.trace`: the spans and the logs of one trace, in the order of their times */
|
|
80
|
+
export interface SinkTraceOutput {
|
|
81
|
+
readonly spans: readonly SpanView[];
|
|
82
|
+
readonly logs: readonly LogView[];
|
|
83
|
+
}
|
|
84
|
+
/** The output of `sink.stats`: the size of each signal, the size of the file and the retention rules */
|
|
85
|
+
export interface SinkStatsOutput {
|
|
86
|
+
readonly sizes: {
|
|
87
|
+
readonly [signal in Signal]: SignalSize;
|
|
88
|
+
};
|
|
89
|
+
readonly fileBytes: number;
|
|
90
|
+
readonly rules: {
|
|
91
|
+
readonly [signal in Signal]: RetentionRule;
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
/** The input of `sink.slowest`, `sink.errors` and `sink.services`: a window of the store */
|
|
95
|
+
export interface SinkWindowInput {
|
|
96
|
+
readonly baseUrl?: string | undefined;
|
|
97
|
+
/** The start of the window, in milliseconds since the epoch. The sink uses the last hour without it. */
|
|
98
|
+
readonly since?: number | undefined;
|
|
99
|
+
/** The most rows of the answer. The sink uses 50 without it. */
|
|
100
|
+
readonly limit?: number | undefined;
|
|
101
|
+
/** Only the rows of this service */
|
|
102
|
+
readonly service?: string | undefined;
|
|
103
|
+
readonly timeoutMs: number;
|
|
104
|
+
}
|
|
105
|
+
/** The input of `sink.trace` */
|
|
106
|
+
export interface SinkTraceInput {
|
|
107
|
+
readonly baseUrl?: string | undefined;
|
|
108
|
+
/** The trace id: 32 hex digits */
|
|
109
|
+
readonly id: string;
|
|
110
|
+
readonly timeoutMs: number;
|
|
111
|
+
}
|
|
112
|
+
/** The input of `sink.stats` */
|
|
113
|
+
export interface SinkStatsInput {
|
|
114
|
+
readonly baseUrl?: string | undefined;
|
|
115
|
+
readonly timeoutMs: number;
|
|
116
|
+
}
|
|
117
|
+
export type SinkSlowestInput = SinkWindowInput;
|
|
118
|
+
export type SinkErrorsInput = SinkWindowInput;
|
|
119
|
+
export type SinkServicesInput = SinkWindowInput;
|
|
120
|
+
/** The input of a procedure before the defaults */
|
|
121
|
+
type Given<T extends {
|
|
122
|
+
timeoutMs: number;
|
|
123
|
+
}> = Omit<T, "timeoutMs"> & {
|
|
124
|
+
readonly timeoutMs?: number | undefined;
|
|
125
|
+
};
|
|
126
|
+
export declare const SinkSlowestInputSchema: z.ZodType<SinkSlowestInput, Given<SinkSlowestInput>>;
|
|
127
|
+
export declare const SinkErrorsInputSchema: z.ZodType<SinkErrorsInput, Given<SinkErrorsInput>>;
|
|
128
|
+
export declare const SinkServicesInputSchema: z.ZodType<SinkServicesInput, Given<SinkServicesInput>>;
|
|
129
|
+
export declare const SinkTraceInputSchema: z.ZodType<SinkTraceInput, Given<SinkTraceInput>>;
|
|
130
|
+
export declare const SinkStatsInputSchema: z.ZodType<SinkStatsInput, Given<SinkStatsInput>>;
|
|
131
|
+
export declare const SpanViewSchema: z.ZodType<SpanView>;
|
|
132
|
+
export declare const LogViewSchema: z.ZodType<LogView>;
|
|
133
|
+
export declare const ServiceViewSchema: z.ZodType<ServiceView>;
|
|
134
|
+
export declare const SinkSlowestOutputSchema: z.ZodType<SinkSlowestOutput>;
|
|
135
|
+
export declare const SinkErrorsOutputSchema: z.ZodType<SinkErrorsOutput>;
|
|
136
|
+
export declare const SinkServicesOutputSchema: z.ZodType<SinkServicesOutput>;
|
|
137
|
+
export declare const SinkTraceOutputSchema: z.ZodType<SinkTraceOutput>;
|
|
138
|
+
export declare const SinkStatsOutputSchema: z.ZodType<SinkStatsOutput>;
|
|
139
|
+
export {};
|
|
140
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;G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CAAC,eAAe,CAG3D,CAAC;AACH,eAAO,MAAM,qBAAqB,EAAE,CAAC,CAAC,OAAO,CAAC,eAAe,CAI3D,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The types and the Zod schemas of the procedures of this package: the inputs of the five queries, and the answers
|
|
3
|
+
* of the sink. Each time in an answer is in milliseconds since the epoch, and each duration is in milliseconds.
|
|
4
|
+
*/
|
|
5
|
+
import * as z from "zod";
|
|
6
|
+
/** The base URL of the sink on this computer */
|
|
7
|
+
export const DEFAULT_SINK_URL = "http://127.0.0.1:4328";
|
|
8
|
+
/** The most rows of one answer of the sink */
|
|
9
|
+
export const MAX_LIMIT = 1000;
|
|
10
|
+
/** The most time of one query, in milliseconds */
|
|
11
|
+
export const MAX_TIMEOUT_MS = 120_000;
|
|
12
|
+
/** The time limit of a query without `timeoutMs`, in milliseconds */
|
|
13
|
+
export const DEFAULT_TIMEOUT_MS = 10_000;
|
|
14
|
+
/** The pattern of a trace id: 32 hex digits, in lowercase or in uppercase */
|
|
15
|
+
export const TRACE_ID_INPUT = /^[0-9a-fA-F]{32}$/;
|
|
16
|
+
const baseUrl = z
|
|
17
|
+
.url({ protocol: /^https?$/ })
|
|
18
|
+
.optional()
|
|
19
|
+
.describe(`The base URL of the sink, http: or https: (default: ${DEFAULT_SINK_URL}). The host must allow its host and port.`);
|
|
20
|
+
const timeoutMs = z
|
|
21
|
+
.number()
|
|
22
|
+
.int()
|
|
23
|
+
.positive()
|
|
24
|
+
.max(MAX_TIMEOUT_MS)
|
|
25
|
+
.default(DEFAULT_TIMEOUT_MS)
|
|
26
|
+
.describe(`The time limit, in milliseconds (default: ${DEFAULT_TIMEOUT_MS})`);
|
|
27
|
+
const windowShape = {
|
|
28
|
+
baseUrl,
|
|
29
|
+
since: z.number().int().min(0).optional().describe("The start of the window, in milliseconds since the epoch (default: one hour ago)"),
|
|
30
|
+
limit: z.number().int().min(1).max(MAX_LIMIT).optional().describe(`The most rows of the answer, from 1 to ${MAX_LIMIT} (default: 50)`),
|
|
31
|
+
service: z.string().min(1).optional().describe("Only the rows of this service (default: each service)"),
|
|
32
|
+
timeoutMs,
|
|
33
|
+
};
|
|
34
|
+
export const SinkSlowestInputSchema = z.object(windowShape);
|
|
35
|
+
export const SinkErrorsInputSchema = z.object(windowShape);
|
|
36
|
+
export const SinkServicesInputSchema = z.object(windowShape);
|
|
37
|
+
export const SinkTraceInputSchema = z.object({
|
|
38
|
+
baseUrl,
|
|
39
|
+
id: z.string().regex(TRACE_ID_INPUT, "The id must be a trace id of 32 hex digits").describe("The trace id: 32 hex digits"),
|
|
40
|
+
timeoutMs,
|
|
41
|
+
});
|
|
42
|
+
export const SinkStatsInputSchema = z.object({ baseUrl, timeoutMs });
|
|
43
|
+
const attributes = z.record(z.string(), z.unknown());
|
|
44
|
+
const span = z.object({
|
|
45
|
+
traceId: z.string(),
|
|
46
|
+
spanId: z.string(),
|
|
47
|
+
parentId: z.string().nullable(),
|
|
48
|
+
service: z.string(),
|
|
49
|
+
name: z.string(),
|
|
50
|
+
kind: z.number().nullable(),
|
|
51
|
+
startMs: z.number(),
|
|
52
|
+
durationMs: z.number(),
|
|
53
|
+
status: z.number(),
|
|
54
|
+
attributes,
|
|
55
|
+
});
|
|
56
|
+
const log = z.object({
|
|
57
|
+
timeMs: z.number(),
|
|
58
|
+
service: z.string(),
|
|
59
|
+
severity: z.number().nullable(),
|
|
60
|
+
body: z.string().nullable(),
|
|
61
|
+
traceId: z.string().nullable(),
|
|
62
|
+
spanId: z.string().nullable(),
|
|
63
|
+
attributes,
|
|
64
|
+
});
|
|
65
|
+
const serviceView = z.object({
|
|
66
|
+
service: z.string(),
|
|
67
|
+
spans: z.number(),
|
|
68
|
+
failed: z.number(),
|
|
69
|
+
errorRate: z.number(),
|
|
70
|
+
slowestMs: z.number(),
|
|
71
|
+
});
|
|
72
|
+
const signalSize = z.object({ rows: z.number(), bytes: z.number() });
|
|
73
|
+
const retentionRule = z.object({ maxAgeMs: z.number(), maxBytes: z.number() });
|
|
74
|
+
export const SpanViewSchema = span;
|
|
75
|
+
export const LogViewSchema = log;
|
|
76
|
+
export const ServiceViewSchema = serviceView;
|
|
77
|
+
const spans = z.array(span);
|
|
78
|
+
const logs = z.array(log);
|
|
79
|
+
export const SinkSlowestOutputSchema = z.object({
|
|
80
|
+
spans: spans.describe("The slowest spans of the window, the slowest first"),
|
|
81
|
+
});
|
|
82
|
+
export const SinkErrorsOutputSchema = z.object({
|
|
83
|
+
spans: spans.describe("The failed spans of the window (status 2), the newest first"),
|
|
84
|
+
logs: logs.describe("The error logs of the window (severity 17 or more), the newest first"),
|
|
85
|
+
});
|
|
86
|
+
export const SinkServicesOutputSchema = z.object({
|
|
87
|
+
services: z.array(serviceView).describe("Each service of the window, with its span count, its failed spans, its error rate and its slowest span"),
|
|
88
|
+
});
|
|
89
|
+
export const SinkTraceOutputSchema = z.object({
|
|
90
|
+
spans: spans.describe("The spans of the trace, in the order of their start times"),
|
|
91
|
+
logs: logs.describe("The logs of the trace, in the order of their times"),
|
|
92
|
+
});
|
|
93
|
+
export const SinkStatsOutputSchema = z.object({
|
|
94
|
+
sizes: z.object({ spans: signalSize, logs: signalSize, points: signalSize }).describe("The rows and bytes of each signal: spans, logs and metric points"),
|
|
95
|
+
fileBytes: z.number().describe("The size of the database file of the sink, in bytes"),
|
|
96
|
+
rules: z.object({ spans: retentionRule, logs: retentionRule, points: retentionRule }).describe("The retention rule of each signal: the most age and the most bytes"),
|
|
97
|
+
});
|
|
98
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAEzB,gDAAgD;AAChD,MAAM,CAAC,MAAM,gBAAgB,GAAG,uBAAuB,CAAC;AAExD,8CAA8C;AAC9C,MAA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