@xylabs/telemetry-exporter 7.0.2 → 7.0.4
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 +6 -4
- package/dist/neutral/index.d.ts +1 -1
- package/dist/neutral/index.d.ts.map +1 -1
- package/dist/neutral/index.mjs +2 -87
- package/dist/neutral/index.mjs.map +3 -3
- package/package.json +12 -10
- package/dist/neutral/XyConsoleSpanExporter.d.ts +0 -40
- package/dist/neutral/XyConsoleSpanExporter.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
> **Deprecated.** Use [`@ariestools/sdk`](../../ariestools-sdk/README.md) instead. This package is a backward-compatibility re-export shim.
|
|
2
|
+
|
|
1
3
|
[![logo][]](https://xylabs.com)
|
|
2
4
|
|
|
3
5
|
# @xylabs/telemetry-exporter
|
|
@@ -12,25 +14,25 @@
|
|
|
12
14
|
Using npm:
|
|
13
15
|
|
|
14
16
|
```sh
|
|
15
|
-
npm install
|
|
17
|
+
npm install @xylabs/telemetry-exporter
|
|
16
18
|
```
|
|
17
19
|
|
|
18
20
|
Using yarn:
|
|
19
21
|
|
|
20
22
|
```sh
|
|
21
|
-
yarn add
|
|
23
|
+
yarn add @xylabs/telemetry-exporter
|
|
22
24
|
```
|
|
23
25
|
|
|
24
26
|
Using pnpm:
|
|
25
27
|
|
|
26
28
|
```sh
|
|
27
|
-
pnpm add
|
|
29
|
+
pnpm add @xylabs/telemetry-exporter
|
|
28
30
|
```
|
|
29
31
|
|
|
30
32
|
Using bun:
|
|
31
33
|
|
|
32
34
|
```sh
|
|
33
|
-
bun add
|
|
35
|
+
bun add @xylabs/telemetry-exporter
|
|
34
36
|
```
|
|
35
37
|
|
|
36
38
|
|
package/dist/neutral/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from '
|
|
1
|
+
export * from '@ariestools/sdk/telemetry-exporter';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oCAAoC,CAAA"}
|
package/dist/neutral/index.mjs
CHANGED
|
@@ -1,88 +1,3 @@
|
|
|
1
|
-
// src/
|
|
2
|
-
|
|
3
|
-
var color = (open, close = 39) => {
|
|
4
|
-
return (value) => `\x1B[${open}m${value}\x1B[${close}m`;
|
|
5
|
-
};
|
|
6
|
-
var logColors = {
|
|
7
|
-
green: color(32),
|
|
8
|
-
grey: color(90),
|
|
9
|
-
magenta: color(35),
|
|
10
|
-
red: color(31),
|
|
11
|
-
white: color(37),
|
|
12
|
-
yellow: color(33)
|
|
13
|
-
};
|
|
14
|
-
function spanDurationInMillis(span) {
|
|
15
|
-
return span.duration[0] * 1e3 + span.duration[1] / 1e6;
|
|
16
|
-
}
|
|
17
|
-
var XyConsoleSpanExporter = class _XyConsoleSpanExporter extends ConsoleSpanExporter {
|
|
18
|
-
/** Duration thresholds (in ms) that map to increasing log levels. */
|
|
19
|
-
static durationToLogLevel = [
|
|
20
|
-
0,
|
|
21
|
-
1,
|
|
22
|
-
10,
|
|
23
|
-
100,
|
|
24
|
-
1e3
|
|
25
|
-
];
|
|
26
|
-
/** Chalk color functions corresponding to each log level. */
|
|
27
|
-
static logLevelToChalkColor = [
|
|
28
|
-
logColors.grey,
|
|
29
|
-
logColors.white,
|
|
30
|
-
logColors.green,
|
|
31
|
-
logColors.yellow,
|
|
32
|
-
logColors.red
|
|
33
|
-
];
|
|
34
|
-
logger;
|
|
35
|
-
_logLevel;
|
|
36
|
-
constructor(logLevel = 0, logger = console) {
|
|
37
|
-
super();
|
|
38
|
-
this._logLevel = logLevel;
|
|
39
|
-
this.logger = logger;
|
|
40
|
-
}
|
|
41
|
-
/** The minimum log level required for a span to be exported. */
|
|
42
|
-
get logLevel() {
|
|
43
|
-
return this._logLevel;
|
|
44
|
-
}
|
|
45
|
-
export(spans) {
|
|
46
|
-
for (const span of spans) {
|
|
47
|
-
const spanLevel = this.spanLevel(span);
|
|
48
|
-
if (spanLevel < this.logLevel) {
|
|
49
|
-
continue;
|
|
50
|
-
}
|
|
51
|
-
const duration = spanDurationInMillis(span);
|
|
52
|
-
this.logger.log(logColors.grey([
|
|
53
|
-
`Span [${span.name}]`,
|
|
54
|
-
this.logColor(spanLevel)(`${duration}ms`),
|
|
55
|
-
`TraceId: ${span.spanContext().traceId}`
|
|
56
|
-
].join(", ")));
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Returns the chalk color function for the given log level.
|
|
61
|
-
* @param level - The log level index.
|
|
62
|
-
* @returns A chalk color function.
|
|
63
|
-
*/
|
|
64
|
-
logColor(level) {
|
|
65
|
-
return _XyConsoleSpanExporter.logLevelToChalkColor[level] ?? logColors.magenta;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Determines the log level of a span based on its duration.
|
|
69
|
-
* @param span - The span to evaluate.
|
|
70
|
-
* @returns The numeric log level (index into durationToLogLevel).
|
|
71
|
-
*/
|
|
72
|
-
spanLevel(span) {
|
|
73
|
-
let logLevel = 0;
|
|
74
|
-
const duration = spanDurationInMillis(span);
|
|
75
|
-
for (let x = _XyConsoleSpanExporter.durationToLogLevel.length - 1; x >= 0; x--) {
|
|
76
|
-
if (duration > _XyConsoleSpanExporter.durationToLogLevel[x]) {
|
|
77
|
-
logLevel = x;
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
return logLevel;
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
export {
|
|
85
|
-
XyConsoleSpanExporter,
|
|
86
|
-
spanDurationInMillis
|
|
87
|
-
};
|
|
1
|
+
// src/index.ts
|
|
2
|
+
export * from "@ariestools/sdk/telemetry-exporter";
|
|
88
3
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";
|
|
3
|
+
"sources": ["../../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["export * from '@ariestools/sdk/telemetry-exporter'\n"],
|
|
5
|
+
"mappings": ";AAAA,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xylabs/telemetry-exporter",
|
|
3
|
-
"version": "7.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "7.0.4",
|
|
4
|
+
"description": "DEPRECATED — use @ariestools/sdk/telemetry-exporter. Backward-compatibility re-export shim.",
|
|
5
5
|
"keywords": [
|
|
6
|
-
"hex",
|
|
7
6
|
"xylabs",
|
|
8
7
|
"utility",
|
|
9
8
|
"typescript",
|
|
@@ -41,28 +40,31 @@
|
|
|
41
40
|
"README.md"
|
|
42
41
|
],
|
|
43
42
|
"dependencies": {
|
|
44
|
-
"@
|
|
43
|
+
"@ariestools/sdk": "~7.0.4"
|
|
45
44
|
},
|
|
46
45
|
"devDependencies": {
|
|
47
46
|
"@opentelemetry/api": "^1.9.1",
|
|
48
47
|
"@opentelemetry/sdk-trace-base": "^2.8.0",
|
|
49
|
-
"@xylabs/toolchain": "^8.5.
|
|
50
|
-
"@xylabs/tsconfig": "^8.5.
|
|
48
|
+
"@xylabs/toolchain": "^8.5.11",
|
|
49
|
+
"@xylabs/tsconfig": "^8.5.11",
|
|
50
|
+
"async-mutex": "^0.5.0",
|
|
51
51
|
"browserslist": "4.28.4",
|
|
52
52
|
"eslint": "^10.6.0",
|
|
53
53
|
"eslint-import-resolver-typescript": "^4.4.5",
|
|
54
54
|
"typescript": "^6.0.3",
|
|
55
|
-
"
|
|
56
|
-
"vitest": "^4.1.9"
|
|
55
|
+
"zod": "^4.4.3"
|
|
57
56
|
},
|
|
58
57
|
"peerDependencies": {
|
|
59
58
|
"@opentelemetry/api": "^1.9",
|
|
60
|
-
"@opentelemetry/sdk-trace-base": "^2.7"
|
|
59
|
+
"@opentelemetry/sdk-trace-base": "^2.7",
|
|
60
|
+
"async-mutex": "^0.5",
|
|
61
|
+
"zod": "^4.4"
|
|
61
62
|
},
|
|
62
63
|
"engines": {
|
|
63
64
|
"node": ">=18"
|
|
64
65
|
},
|
|
65
66
|
"publishConfig": {
|
|
66
67
|
"access": "public"
|
|
67
|
-
}
|
|
68
|
+
},
|
|
69
|
+
"deprecated": "Use @ariestools/sdk/telemetry-exporter instead. @xylabs/telemetry-exporter is a compatibility shim only and will not receive further updates."
|
|
68
70
|
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import type { ReadableSpan } from '@opentelemetry/sdk-trace-base';
|
|
2
|
-
import { ConsoleSpanExporter } from '@opentelemetry/sdk-trace-base';
|
|
3
|
-
import type { Logger } from '@xylabs/logger';
|
|
4
|
-
type LogColor = (value: string) => string;
|
|
5
|
-
/**
|
|
6
|
-
* Calculates the duration of a span in milliseconds from its high-resolution time tuple.
|
|
7
|
-
* @param span - The span to measure.
|
|
8
|
-
* @returns The span duration in milliseconds.
|
|
9
|
-
*/
|
|
10
|
-
export declare function spanDurationInMillis(span: ReadableSpan): number;
|
|
11
|
-
/**
|
|
12
|
-
* A console span exporter that formats spans with color-coded durations using chalk.
|
|
13
|
-
* Spans are filtered by a configurable log level based on their duration.
|
|
14
|
-
*/
|
|
15
|
-
export declare class XyConsoleSpanExporter extends ConsoleSpanExporter {
|
|
16
|
-
/** Duration thresholds (in ms) that map to increasing log levels. */
|
|
17
|
-
static readonly durationToLogLevel: number[];
|
|
18
|
-
/** Chalk color functions corresponding to each log level. */
|
|
19
|
-
static readonly logLevelToChalkColor: LogColor[];
|
|
20
|
-
logger: Logger;
|
|
21
|
-
private _logLevel;
|
|
22
|
-
constructor(logLevel?: number, logger?: Logger);
|
|
23
|
-
/** The minimum log level required for a span to be exported. */
|
|
24
|
-
get logLevel(): number;
|
|
25
|
-
export(spans: ReadableSpan[]): void;
|
|
26
|
-
/**
|
|
27
|
-
* Returns the chalk color function for the given log level.
|
|
28
|
-
* @param level - The log level index.
|
|
29
|
-
* @returns A chalk color function.
|
|
30
|
-
*/
|
|
31
|
-
logColor(level: number): LogColor;
|
|
32
|
-
/**
|
|
33
|
-
* Determines the log level of a span based on its duration.
|
|
34
|
-
* @param span - The span to evaluate.
|
|
35
|
-
* @returns The numeric log level (index into durationToLogLevel).
|
|
36
|
-
*/
|
|
37
|
-
spanLevel(span: ReadableSpan): number;
|
|
38
|
-
}
|
|
39
|
-
export {};
|
|
40
|
-
//# sourceMappingURL=XyConsoleSpanExporter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"XyConsoleSpanExporter.d.ts","sourceRoot":"","sources":["../../src/XyConsoleSpanExporter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAA;AACnE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAI5C,KAAK,QAAQ,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAA;AAezC;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,YAAY,UAEtD;AAED;;;GAGG;AACH,qBAAa,qBAAsB,SAAQ,mBAAmB;IAC5D,qEAAqE;IACrE,MAAM,CAAC,QAAQ,CAAC,kBAAkB,WAMjC;IAED,6DAA6D;IAC7D,MAAM,CAAC,QAAQ,CAAC,oBAAoB,aAMnC;IAED,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,SAAS,CAAQ;gBAEb,QAAQ,SAAI,EAAE,MAAM,GAAE,MAAgB;IAMlD,gEAAgE;IAChE,IAAI,QAAQ,WAEX;IAEQ,MAAM,CAAC,KAAK,EAAE,YAAY,EAAE,GAAG,IAAI;IAe5C;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM;IAItB;;;;OAIG;IACH,SAAS,CAAC,IAAI,EAAE,YAAY;CAW7B"}
|