@eggjs/tracer 3.0.0 → 4.0.0-beta.17

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.
Files changed (71) hide show
  1. package/README.md +1 -4
  2. package/dist/agent.d.ts +2 -0
  3. package/dist/agent.js +7 -0
  4. package/dist/app/extend/agent.d.ts +2 -0
  5. package/dist/app/extend/agent.js +7 -0
  6. package/dist/app/extend/application.d.ts +12 -0
  7. package/dist/app/extend/application.js +19 -0
  8. package/dist/app/extend/context.d.ts +12 -0
  9. package/dist/app/extend/context.js +17 -0
  10. package/dist/app.d.ts +2 -0
  11. package/dist/app.js +7 -0
  12. package/dist/boot.d.ts +10 -0
  13. package/dist/boot.js +18 -0
  14. package/dist/config/config.default.d.ts +11 -0
  15. package/dist/config/config.default.js +7 -0
  16. package/dist/index.d.ts +2 -0
  17. package/dist/index.js +6 -0
  18. package/dist/lib/tracer.d.ts +11 -0
  19. package/dist/lib/tracer.js +17 -0
  20. package/dist/types.d.ts +21 -0
  21. package/dist/types.js +1 -0
  22. package/package.json +35 -62
  23. package/dist/commonjs/agent.d.ts +0 -2
  24. package/dist/commonjs/agent.js +0 -5
  25. package/dist/commonjs/app/extend/agent.d.ts +0 -2
  26. package/dist/commonjs/app/extend/agent.js +0 -8
  27. package/dist/commonjs/app/extend/application.d.ts +0 -14
  28. package/dist/commonjs/app/extend/application.js +0 -20
  29. package/dist/commonjs/app/extend/context.d.ts +0 -15
  30. package/dist/commonjs/app/extend/context.js +0 -18
  31. package/dist/commonjs/app.d.ts +0 -2
  32. package/dist/commonjs/app.js +0 -5
  33. package/dist/commonjs/boot.d.ts +0 -6
  34. package/dist/commonjs/boot.js +0 -15
  35. package/dist/commonjs/config/config.default.d.ts +0 -18
  36. package/dist/commonjs/config/config.default.js +0 -9
  37. package/dist/commonjs/index.d.ts +0 -6
  38. package/dist/commonjs/index.js +0 -10
  39. package/dist/commonjs/lib/tracer.d.ts +0 -7
  40. package/dist/commonjs/lib/tracer.js +0 -19
  41. package/dist/commonjs/package.json +0 -3
  42. package/dist/esm/agent.d.ts +0 -2
  43. package/dist/esm/agent.js +0 -3
  44. package/dist/esm/app/extend/agent.d.ts +0 -2
  45. package/dist/esm/app/extend/agent.js +0 -3
  46. package/dist/esm/app/extend/application.d.ts +0 -14
  47. package/dist/esm/app/extend/application.js +0 -16
  48. package/dist/esm/app/extend/context.d.ts +0 -15
  49. package/dist/esm/app/extend/context.js +0 -15
  50. package/dist/esm/app.d.ts +0 -2
  51. package/dist/esm/app.js +0 -3
  52. package/dist/esm/boot.d.ts +0 -6
  53. package/dist/esm/boot.js +0 -11
  54. package/dist/esm/config/config.default.d.ts +0 -18
  55. package/dist/esm/config/config.default.js +0 -7
  56. package/dist/esm/index.d.ts +0 -6
  57. package/dist/esm/index.js +0 -7
  58. package/dist/esm/lib/tracer.d.ts +0 -7
  59. package/dist/esm/lib/tracer.js +0 -15
  60. package/dist/esm/package.json +0 -3
  61. package/dist/package.json +0 -4
  62. package/src/agent.ts +0 -3
  63. package/src/app/extend/agent.ts +0 -3
  64. package/src/app/extend/application.ts +0 -27
  65. package/src/app/extend/context.ts +0 -25
  66. package/src/app.ts +0 -3
  67. package/src/boot.ts +0 -10
  68. package/src/config/config.default.ts +0 -22
  69. package/src/index.ts +0 -8
  70. package/src/lib/tracer.ts +0 -18
  71. package/src/typings/index.d.ts +0 -4
package/README.md CHANGED
@@ -1,7 +1,6 @@
1
1
  # @eggjs/tracer
2
2
 
3
3
  [![NPM version][npm-image]][npm-url]
4
- [![Test coverage][codecov-image]][codecov-url]
5
4
  [![Known Vulnerabilities][snyk-image]][snyk-url]
6
5
  [![npm download][download-image]][download-url]
7
6
  [![Node.js Version](https://img.shields.io/node/v/@eggjs/tracer.svg?style=flat)](https://nodejs.org/en/download/)
@@ -10,8 +9,6 @@
10
9
 
11
10
  [npm-image]: https://img.shields.io/npm/v/@eggjs/tracer.svg?style=flat-square
12
11
  [npm-url]: https://npmjs.org/package/@eggjs/tracer
13
- [codecov-image]: https://img.shields.io/codecov/c/github/eggjs/tracer.svg?style=flat-square
14
- [codecov-url]: https://codecov.io/github/eggjs/tracer?branch=master
15
12
  [snyk-image]: https://snyk.io/test/npm/@eggjs/tracer/badge.svg?style=flat-square
16
13
  [snyk-url]: https://snyk.io/test/npm/@eggjs/tracer
17
14
  [download-image]: https://img.shields.io/npm/dm/@eggjs/tracer.svg?style=flat-square
@@ -72,6 +69,6 @@ Please open an issue [here](https://github.com/eggjs/egg/issues).
72
69
 
73
70
  ## Contributors
74
71
 
75
- [![Contributors](https://contrib.rocks/image?repo=eggjs/tracer)](https://github.com/eggjs/tracer/graphs/contributors)
72
+ [![Contributors](https://contrib.rocks/image?repo=eggjs/egg)](https://github.com/eggjs/egg/graphs/contributors)
76
73
 
77
74
  Made with [contributors-img](https://contrib.rocks).
@@ -0,0 +1,2 @@
1
+ import { TracerBoot } from "./boot.js";
2
+ export { TracerBoot as default };
package/dist/agent.js ADDED
@@ -0,0 +1,7 @@
1
+ import { TracerBoot } from "./boot.js";
2
+
3
+ //#region src/agent.ts
4
+ var agent_default = TracerBoot;
5
+
6
+ //#endregion
7
+ export { agent_default as default };
@@ -0,0 +1,2 @@
1
+ import TracerApplication from "./application.js";
2
+ export { TracerApplication as default };
@@ -0,0 +1,7 @@
1
+ import TracerApplication from "./application.js";
2
+
3
+ //#region src/app/extend/agent.ts
4
+ var agent_default = TracerApplication;
5
+
6
+ //#endregion
7
+ export { agent_default as default };
@@ -0,0 +1,12 @@
1
+ import { Tracer } from "../../lib/tracer.js";
2
+ import { Application } from "egg";
3
+
4
+ //#region src/app/extend/application.d.ts
5
+ declare const cacheTracer: unique symbol;
6
+ declare const isReady: unique symbol;
7
+ declare class TracerApplication extends Application {
8
+ [cacheTracer]: Tracer | undefined;
9
+ get tracer(): Tracer;
10
+ }
11
+ //#endregion
12
+ export { TracerApplication as default, isReady };
@@ -0,0 +1,19 @@
1
+ import { debuglog } from "node:util";
2
+ import { Application } from "egg";
3
+
4
+ //#region src/app/extend/application.ts
5
+ const debug = debuglog("egg/tracer/app/extend/application");
6
+ const cacheTracer = Symbol("before_ready_tracer");
7
+ const isReady = Symbol("egg_tracer_is_ready");
8
+ var TracerApplication = class extends Application {
9
+ [cacheTracer];
10
+ get tracer() {
11
+ if (this[isReady]) return new this.config.tracer.Class(this.createAnonymousContext());
12
+ if (!this[cacheTracer]) this[cacheTracer] = new this.config.tracer.Class(this.createAnonymousContext());
13
+ debug("use cached tracer before ready, type: %o", this.type);
14
+ return this[cacheTracer];
15
+ }
16
+ };
17
+
18
+ //#endregion
19
+ export { TracerApplication as default, isReady };
@@ -0,0 +1,12 @@
1
+ import { Tracer } from "../../lib/tracer.js";
2
+ import { Context } from "egg";
3
+
4
+ //#region src/app/extend/context.d.ts
5
+ declare const TRACER: unique symbol;
6
+ declare class TracerContext extends Context {
7
+ [TRACER]: Tracer | undefined;
8
+ get tracer(): Tracer;
9
+ get traceId(): string;
10
+ }
11
+ //#endregion
12
+ export { TracerContext as default };
@@ -0,0 +1,17 @@
1
+ import { Context } from "egg";
2
+
3
+ //#region src/app/extend/context.ts
4
+ const TRACER = Symbol("context tracer");
5
+ var TracerContext = class extends Context {
6
+ [TRACER];
7
+ get tracer() {
8
+ if (!this[TRACER]) this[TRACER] = new this.app.config.tracer.Class(this);
9
+ return this[TRACER];
10
+ }
11
+ get traceId() {
12
+ return this.tracer.traceId;
13
+ }
14
+ };
15
+
16
+ //#endregion
17
+ export { TracerContext as default };
package/dist/app.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import { TracerBoot } from "./boot.js";
2
+ export { TracerBoot as default };
package/dist/app.js ADDED
@@ -0,0 +1,7 @@
1
+ import { TracerBoot } from "./boot.js";
2
+
3
+ //#region src/app.ts
4
+ var app_default = TracerBoot;
5
+
6
+ //#endregion
7
+ export { app_default as default };
package/dist/boot.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ import { EggApplicationCore, ILifecycleBoot } from "egg";
2
+
3
+ //#region src/boot.d.ts
4
+ declare class TracerBoot implements ILifecycleBoot {
5
+ private readonly app;
6
+ constructor(app: EggApplicationCore);
7
+ didLoad(): Promise<void>;
8
+ }
9
+ //#endregion
10
+ export { TracerBoot };
package/dist/boot.js ADDED
@@ -0,0 +1,18 @@
1
+ import { isReady } from "./app/extend/application.js";
2
+ import { debuglog } from "node:util";
3
+
4
+ //#region src/boot.ts
5
+ const debug = debuglog("egg/tracer/boot");
6
+ var TracerBoot = class {
7
+ app;
8
+ constructor(app) {
9
+ this.app = app;
10
+ }
11
+ async didLoad() {
12
+ debug("didLoad %o", this.app.type);
13
+ this.app[isReady] = true;
14
+ }
15
+ };
16
+
17
+ //#endregion
18
+ export { TracerBoot };
@@ -0,0 +1,11 @@
1
+ import { Tracer } from "../lib/tracer.js";
2
+
3
+ //#region src/config/config.default.d.ts
4
+ interface TracerConfig {
5
+ Class: typeof Tracer;
6
+ }
7
+ declare const _default: {
8
+ tracer: TracerConfig;
9
+ };
10
+ //#endregion
11
+ export { TracerConfig, _default as default };
@@ -0,0 +1,7 @@
1
+ import { Tracer } from "../lib/tracer.js";
2
+
3
+ //#region src/config/config.default.ts
4
+ var config_default_default = { tracer: { Class: Tracer } };
5
+
6
+ //#endregion
7
+ export { config_default_default as default };
@@ -0,0 +1,2 @@
1
+ import { Tracer } from "./lib/tracer.js";
2
+ export { Tracer };
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ import "./app/extend/application.js";
2
+ import { Tracer } from "./lib/tracer.js";
3
+ import "./app/extend/agent.js";
4
+ import "./app/extend/context.js";
5
+
6
+ export { Tracer };
@@ -0,0 +1,11 @@
1
+ import { Context } from "egg";
2
+
3
+ //#region src/lib/tracer.d.ts
4
+ declare class Tracer {
5
+ #private;
6
+ readonly ctx: Context;
7
+ constructor(ctx: Context);
8
+ get traceId(): string;
9
+ }
10
+ //#endregion
11
+ export { Tracer };
@@ -0,0 +1,17 @@
1
+ import { randomUUID } from "node:crypto";
2
+
3
+ //#region src/lib/tracer.ts
4
+ var Tracer = class {
5
+ ctx;
6
+ #traceId;
7
+ constructor(ctx) {
8
+ this.ctx = ctx;
9
+ }
10
+ get traceId() {
11
+ if (!this.#traceId) this.#traceId = randomUUID();
12
+ return this.#traceId;
13
+ }
14
+ };
15
+
16
+ //#endregion
17
+ export { Tracer };
@@ -0,0 +1,21 @@
1
+ import { Tracer } from "./lib/tracer.js";
2
+ import { TracerConfig } from "./config/config.default.js";
3
+
4
+ //#region src/types.d.ts
5
+ declare module 'egg' {
6
+ interface EggAppConfig {
7
+ /**
8
+ * tracer config
9
+ * @member Config#tracer
10
+ * @property {Tracer} Class - tracer class name
11
+ */
12
+ tracer: TracerConfig;
13
+ }
14
+ interface Application {
15
+ tracer: Tracer;
16
+ }
17
+ interface Context {
18
+ tracer: Tracer;
19
+ traceId: string;
20
+ }
21
+ }
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export { };
package/package.json CHANGED
@@ -1,17 +1,12 @@
1
1
  {
2
2
  "name": "@eggjs/tracer",
3
- "version": "3.0.0",
3
+ "version": "4.0.0-beta.17",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
7
  "description": "tracer for egg",
8
8
  "eggPlugin": {
9
- "name": "tracer",
10
- "exports": {
11
- "import": "./dist/esm",
12
- "require": "./dist/commonjs",
13
- "typescript": "./src"
14
- }
9
+ "name": "tracer"
15
10
  },
16
11
  "keywords": [
17
12
  "egg",
@@ -24,75 +19,53 @@
24
19
  ],
25
20
  "repository": {
26
21
  "type": "git",
27
- "url": "git+https://github.com/eggjs/tracer.git"
22
+ "url": "git://github.com/eggjs/egg.git",
23
+ "directory": "plugins/tracer"
28
24
  },
29
25
  "bugs": {
30
26
  "url": "https://github.com/eggjs/egg/issues"
31
27
  },
32
- "homepage": "https://github.com/eggjs/tracer#readme",
28
+ "homepage": "https://github.com/eggjs/egg/tree/next/plugins/tracer",
33
29
  "author": "fengmk2 <fengmk2@gmail.com> (https://github.com/fengmk2)",
34
30
  "license": "MIT",
35
31
  "engines": {
36
- "node": ">= 18.19.0"
32
+ "node": ">=22.18.0"
37
33
  },
38
- "dependencies": {
39
- "@eggjs/core": "^6.2.13"
34
+ "dependencies": {},
35
+ "peerDependencies": {
36
+ "egg": "4.1.0-beta.17"
40
37
  },
41
38
  "devDependencies": {
42
- "@arethetypeswrong/cli": "^0.17.3",
43
- "@eggjs/bin": "7",
44
- "@eggjs/mock": "^6.0.5",
45
- "@eggjs/tsconfig": "1",
46
- "@types/mocha": "10",
47
- "@types/node": "22",
48
- "egg": "^4.0.5",
49
- "egg-logger": "^3.6.1",
50
- "eslint": "8",
51
- "eslint-config-egg": "14",
52
- "glob": "^11.0.1",
53
- "rimraf": "6",
54
- "snap-shot-it": "^7.9.10",
55
- "supertest": "^6.3.3",
56
- "tsd": "^0.31.2",
57
- "tshy": "3",
58
- "tshy-after": "1",
59
- "typescript": "5"
60
- },
61
- "scripts": {
62
- "lint": "eslint --cache src test --ext .ts",
63
- "pretest": "npm run clean && npm run lint -- --fix",
64
- "test": "egg-bin test",
65
- "preci": "npm run clean && npm run lint",
66
- "ci": "egg-bin cov",
67
- "postci": "npm run prepublishOnly && npm run clean",
68
- "clean": "rimraf dist",
69
- "prepublishOnly": "tshy && tshy-after && attw --pack"
39
+ "tsdown": "^0.15.4",
40
+ "typescript": "5.9.2",
41
+ "vitest": "4.0.0-beta.13",
42
+ "@eggjs/mock": "7.0.0-beta.17",
43
+ "@eggjs/tsconfig": "3.1.0-beta.17"
70
44
  },
71
45
  "type": "module",
72
- "tshy": {
73
- "exports": {
74
- ".": "./src/index.ts",
75
- "./package.json": "./package.json"
76
- }
77
- },
78
46
  "exports": {
79
- ".": {
80
- "import": {
81
- "types": "./dist/esm/index.d.ts",
82
- "default": "./dist/esm/index.js"
83
- },
84
- "require": {
85
- "types": "./dist/commonjs/index.d.ts",
86
- "default": "./dist/commonjs/index.js"
87
- }
88
- },
47
+ ".": "./dist/index.js",
48
+ "./agent": "./dist/agent.js",
49
+ "./app": "./dist/app.js",
50
+ "./app/extend/agent": "./dist/app/extend/agent.js",
51
+ "./app/extend/application": "./dist/app/extend/application.js",
52
+ "./app/extend/context": "./dist/app/extend/context.js",
53
+ "./boot": "./dist/boot.js",
54
+ "./config/config.default": "./dist/config/config.default.js",
55
+ "./lib/tracer": "./dist/lib/tracer.js",
56
+ "./types": "./dist/types.js",
89
57
  "./package.json": "./package.json"
90
58
  },
91
59
  "files": [
92
- "dist",
93
- "src"
60
+ "dist"
94
61
  ],
95
- "types": "./dist/commonjs/index.d.ts",
96
- "main": "./dist/commonjs/index.js",
97
- "module": "./dist/esm/index.js"
98
- }
62
+ "types": "./dist/index.d.ts",
63
+ "main": "./dist/index.js",
64
+ "module": "./dist/index.js",
65
+ "scripts": {
66
+ "lint": "oxlint --type-aware",
67
+ "typecheck": "tsc --noEmit",
68
+ "test": "vitest run",
69
+ "build": "tsdown"
70
+ }
71
+ }
@@ -1,2 +0,0 @@
1
- import { TracerBoot } from './boot.js';
2
- export default TracerBoot;
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const boot_js_1 = require("./boot.js");
4
- exports.default = boot_js_1.TracerBoot;
5
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWdlbnQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvYWdlbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSx1Q0FBdUM7QUFFdkMsa0JBQWUsb0JBQVUsQ0FBQyJ9
@@ -1,2 +0,0 @@
1
- import TracerApplication from './application.js';
2
- export default TracerApplication;
@@ -1,8 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const application_js_1 = __importDefault(require("./application.js"));
7
- exports.default = application_js_1.default;
8
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWdlbnQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvYXBwL2V4dGVuZC9hZ2VudC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUFBLHNFQUFpRDtBQUVqRCxrQkFBZSx3QkFBaUIsQ0FBQyJ9
@@ -1,14 +0,0 @@
1
- import { EggCore } from '@eggjs/core';
2
- import type { Tracer } from '../../lib/tracer.js';
3
- declare const cacheTracer: unique symbol;
4
- export declare const isReady: unique symbol;
5
- export default class TracerApplication extends EggCore {
6
- [cacheTracer]: Tracer | undefined;
7
- get tracer(): Tracer;
8
- }
9
- declare module '@eggjs/core' {
10
- interface EggCore {
11
- tracer: Tracer;
12
- }
13
- }
14
- export {};
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isReady = void 0;
4
- const core_1 = require("@eggjs/core");
5
- const cacheTracer = Symbol('before_ready_tracer');
6
- exports.isReady = Symbol('egg_tracer_is_ready');
7
- class TracerApplication extends core_1.EggCore {
8
- [cacheTracer];
9
- get tracer() {
10
- if (this[exports.isReady]) {
11
- return new this.config.tracer.Class(this.createAnonymousContext());
12
- }
13
- if (!this[cacheTracer]) {
14
- this[cacheTracer] = new this.config.tracer.Class(this.createAnonymousContext());
15
- }
16
- return this[cacheTracer];
17
- }
18
- }
19
- exports.default = TracerApplication;
20
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXBwbGljYXRpb24uanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvYXBwL2V4dGVuZC9hcHBsaWNhdGlvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSxzQ0FBc0M7QUFHdEMsTUFBTSxXQUFXLEdBQUcsTUFBTSxDQUFDLHFCQUFxQixDQUFDLENBQUM7QUFDckMsUUFBQSxPQUFPLEdBQUcsTUFBTSxDQUFDLHFCQUFxQixDQUFDLENBQUM7QUFFckQsTUFBcUIsaUJBQWtCLFNBQVEsY0FBTztJQUNwRCxDQUFDLFdBQVcsQ0FBQyxDQUFxQjtJQUVsQyxJQUFJLE1BQU07UUFDUixJQUFJLElBQUksQ0FBQyxlQUFPLENBQUMsRUFBRSxDQUFDO1lBQ2xCLE9BQU8sSUFBSSxJQUFJLENBQUMsTUFBTSxDQUFDLE1BQU0sQ0FBQyxLQUFLLENBQUMsSUFBSSxDQUFDLHNCQUFzQixFQUFFLENBQUMsQ0FBQztRQUNyRSxDQUFDO1FBRUQsSUFBSSxDQUFDLElBQUksQ0FBQyxXQUFXLENBQUMsRUFBRSxDQUFDO1lBQ3ZCLElBQUksQ0FBQyxXQUFXLENBQUMsR0FBRyxJQUFJLElBQUksQ0FBQyxNQUFNLENBQUMsTUFBTSxDQUFDLEtBQUssQ0FBQyxJQUFJLENBQUMsc0JBQXNCLEVBQUUsQ0FBQyxDQUFDO1FBQ2xGLENBQUM7UUFFRCxPQUFPLElBQUksQ0FBQyxXQUFXLENBQUMsQ0FBQztJQUMzQixDQUFDO0NBQ0Y7QUFkRCxvQ0FjQyJ9
@@ -1,15 +0,0 @@
1
- import { Context } from '@eggjs/core';
2
- import type { Tracer } from '../../lib/tracer.js';
3
- declare const TRACER: unique symbol;
4
- export default class TracerContext extends Context {
5
- [TRACER]: Tracer | undefined;
6
- get tracer(): Tracer;
7
- get traceId(): string;
8
- }
9
- declare module '@eggjs/core' {
10
- interface Context {
11
- tracer: Tracer;
12
- traceId: string;
13
- }
14
- }
15
- export {};
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const core_1 = require("@eggjs/core");
4
- const TRACER = Symbol('context tracer');
5
- class TracerContext extends core_1.Context {
6
- [TRACER];
7
- get tracer() {
8
- if (!this[TRACER]) {
9
- this[TRACER] = new this.app.config.tracer.Class(this);
10
- }
11
- return this[TRACER];
12
- }
13
- get traceId() {
14
- return this.tracer.traceId;
15
- }
16
- }
17
- exports.default = TracerContext;
18
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29udGV4dC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9hcHAvZXh0ZW5kL2NvbnRleHQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSxzQ0FBc0M7QUFFdEMsTUFBTSxNQUFNLEdBQUcsTUFBTSxDQUFDLGdCQUFnQixDQUFDLENBQUM7QUFFeEMsTUFBcUIsYUFBYyxTQUFRLGNBQU87SUFDaEQsQ0FBQyxNQUFNLENBQUMsQ0FBcUI7SUFFN0IsSUFBSSxNQUFNO1FBQ1IsSUFBSSxDQUFDLElBQUksQ0FBQyxNQUFNLENBQUMsRUFBRSxDQUFDO1lBQ2xCLElBQUksQ0FBQyxNQUFNLENBQUMsR0FBRyxJQUFJLElBQUksQ0FBQyxHQUFHLENBQUMsTUFBTSxDQUFDLE1BQU0sQ0FBQyxLQUFLLENBQUMsSUFBSSxDQUFDLENBQUM7UUFDeEQsQ0FBQztRQUNELE9BQU8sSUFBSSxDQUFDLE1BQU0sQ0FBQyxDQUFDO0lBQ3RCLENBQUM7SUFFRCxJQUFJLE9BQU87UUFDVCxPQUFPLElBQUksQ0FBQyxNQUFNLENBQUMsT0FBTyxDQUFDO0lBQzdCLENBQUM7Q0FDRjtBQWJELGdDQWFDIn0=
@@ -1,2 +0,0 @@
1
- import { TracerBoot } from './boot.js';
2
- export default TracerBoot;
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const boot_js_1 = require("./boot.js");
4
- exports.default = boot_js_1.TracerBoot;
5
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXBwLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2FwcC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLHVDQUF1QztBQUV2QyxrQkFBZSxvQkFBVSxDQUFDIn0=
@@ -1,6 +0,0 @@
1
- import type { EggCore, ILifecycleBoot } from '@eggjs/core';
2
- export declare class TracerBoot implements ILifecycleBoot {
3
- private app;
4
- constructor(app: EggCore);
5
- didLoad(): Promise<void>;
6
- }
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TracerBoot = void 0;
4
- const application_js_1 = require("./app/extend/application.js");
5
- class TracerBoot {
6
- app;
7
- constructor(app) {
8
- this.app = app;
9
- }
10
- async didLoad() {
11
- this.app[application_js_1.isReady] = true;
12
- }
13
- }
14
- exports.TracerBoot = TracerBoot;
15
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYm9vdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ib290LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUNBLGdFQUFzRDtBQUV0RCxNQUFhLFVBQVU7SUFDRDtJQUFwQixZQUFvQixHQUFZO1FBQVosUUFBRyxHQUFILEdBQUcsQ0FBUztJQUFHLENBQUM7SUFFcEMsS0FBSyxDQUFDLE9BQU87UUFDWCxJQUFJLENBQUMsR0FBRyxDQUFDLHdCQUFPLENBQUMsR0FBRyxJQUFJLENBQUM7SUFDM0IsQ0FBQztDQUNGO0FBTkQsZ0NBTUMifQ==
@@ -1,18 +0,0 @@
1
- import { Tracer } from '../lib/tracer.js';
2
- /**
3
- * tracer config
4
- * @member Config#tracer
5
- * @property {Tracer} Class - tracer class name
6
- */
7
- interface TracerConfig {
8
- Class: typeof Tracer;
9
- }
10
- declare const _default: {
11
- tracer: TracerConfig;
12
- };
13
- export default _default;
14
- declare module '@eggjs/core' {
15
- interface EggAppConfig {
16
- tracer: TracerConfig;
17
- }
18
- }
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tracer_js_1 = require("../lib/tracer.js");
4
- exports.default = {
5
- tracer: {
6
- Class: tracer_js_1.Tracer,
7
- },
8
- };
9
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uZmlnLmRlZmF1bHQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvY29uZmlnL2NvbmZpZy5kZWZhdWx0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsZ0RBQTBDO0FBVzFDLGtCQUFlO0lBQ2IsTUFBTSxFQUFFO1FBQ04sS0FBSyxFQUFFLGtCQUFNO0tBQ0U7Q0FDbEIsQ0FBQyJ9
@@ -1,6 +0,0 @@
1
- import './config/config.default.js';
2
- import './app/extend/application.js';
3
- import './app/extend/agent.js';
4
- import './app/extend/context.js';
5
- import { Tracer } from './lib/tracer.js';
6
- export { Tracer };
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Tracer = void 0;
4
- require("./config/config.default.js");
5
- require("./app/extend/application.js");
6
- require("./app/extend/agent.js");
7
- require("./app/extend/context.js");
8
- const tracer_js_1 = require("./lib/tracer.js");
9
- Object.defineProperty(exports, "Tracer", { enumerable: true, get: function () { return tracer_js_1.Tracer; } });
10
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsc0NBQW9DO0FBQ3BDLHVDQUFxQztBQUNyQyxpQ0FBK0I7QUFDL0IsbUNBQWlDO0FBRWpDLCtDQUF5QztBQUVoQyx1RkFGQSxrQkFBTSxPQUVBIn0=
@@ -1,7 +0,0 @@
1
- import type { Context } from '@eggjs/core';
2
- export declare class Tracer {
3
- #private;
4
- readonly ctx: Context;
5
- constructor(ctx: Context);
6
- get traceId(): string;
7
- }
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Tracer = void 0;
4
- const node_crypto_1 = require("node:crypto");
5
- class Tracer {
6
- ctx;
7
- #traceId;
8
- constructor(ctx) {
9
- this.ctx = ctx;
10
- }
11
- get traceId() {
12
- if (!this.#traceId) {
13
- this.#traceId = (0, node_crypto_1.randomUUID)();
14
- }
15
- return this.#traceId;
16
- }
17
- }
18
- exports.Tracer = Tracer;
19
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHJhY2VyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2xpYi90cmFjZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsNkNBQXlDO0FBR3pDLE1BQWEsTUFBTTtJQUNSLEdBQUcsQ0FBVTtJQUN0QixRQUFRLENBQXFCO0lBRTdCLFlBQVksR0FBWTtRQUN0QixJQUFJLENBQUMsR0FBRyxHQUFHLEdBQUcsQ0FBQztJQUNqQixDQUFDO0lBRUQsSUFBSSxPQUFPO1FBQ1QsSUFBSSxDQUFDLElBQUksQ0FBQyxRQUFRLEVBQUUsQ0FBQztZQUNuQixJQUFJLENBQUMsUUFBUSxHQUFHLElBQUEsd0JBQVUsR0FBRSxDQUFDO1FBQy9CLENBQUM7UUFDRCxPQUFPLElBQUksQ0FBQyxRQUFRLENBQUM7SUFDdkIsQ0FBQztDQUNGO0FBZEQsd0JBY0MifQ==
@@ -1,3 +0,0 @@
1
- {
2
- "type": "commonjs"
3
- }
@@ -1,2 +0,0 @@
1
- import { TracerBoot } from './boot.js';
2
- export default TracerBoot;
package/dist/esm/agent.js DELETED
@@ -1,3 +0,0 @@
1
- import { TracerBoot } from './boot.js';
2
- export default TracerBoot;
3
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWdlbnQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvYWdlbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFVBQVUsRUFBRSxNQUFNLFdBQVcsQ0FBQztBQUV2QyxlQUFlLFVBQVUsQ0FBQyJ9
@@ -1,2 +0,0 @@
1
- import TracerApplication from './application.js';
2
- export default TracerApplication;
@@ -1,3 +0,0 @@
1
- import TracerApplication from './application.js';
2
- export default TracerApplication;
3
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWdlbnQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvYXBwL2V4dGVuZC9hZ2VudC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLGlCQUFpQixNQUFNLGtCQUFrQixDQUFDO0FBRWpELGVBQWUsaUJBQWlCLENBQUMifQ==
@@ -1,14 +0,0 @@
1
- import { EggCore } from '@eggjs/core';
2
- import type { Tracer } from '../../lib/tracer.js';
3
- declare const cacheTracer: unique symbol;
4
- export declare const isReady: unique symbol;
5
- export default class TracerApplication extends EggCore {
6
- [cacheTracer]: Tracer | undefined;
7
- get tracer(): Tracer;
8
- }
9
- declare module '@eggjs/core' {
10
- interface EggCore {
11
- tracer: Tracer;
12
- }
13
- }
14
- export {};
@@ -1,16 +0,0 @@
1
- import { EggCore } from '@eggjs/core';
2
- const cacheTracer = Symbol('before_ready_tracer');
3
- export const isReady = Symbol('egg_tracer_is_ready');
4
- export default class TracerApplication extends EggCore {
5
- [cacheTracer];
6
- get tracer() {
7
- if (this[isReady]) {
8
- return new this.config.tracer.Class(this.createAnonymousContext());
9
- }
10
- if (!this[cacheTracer]) {
11
- this[cacheTracer] = new this.config.tracer.Class(this.createAnonymousContext());
12
- }
13
- return this[cacheTracer];
14
- }
15
- }
16
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXBwbGljYXRpb24uanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvYXBwL2V4dGVuZC9hcHBsaWNhdGlvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsT0FBTyxFQUFFLE1BQU0sYUFBYSxDQUFDO0FBR3RDLE1BQU0sV0FBVyxHQUFHLE1BQU0sQ0FBQyxxQkFBcUIsQ0FBQyxDQUFDO0FBQ2xELE1BQU0sQ0FBQyxNQUFNLE9BQU8sR0FBRyxNQUFNLENBQUMscUJBQXFCLENBQUMsQ0FBQztBQUVyRCxNQUFNLENBQUMsT0FBTyxPQUFPLGlCQUFrQixTQUFRLE9BQU87SUFDcEQsQ0FBQyxXQUFXLENBQUMsQ0FBcUI7SUFFbEMsSUFBSSxNQUFNO1FBQ1IsSUFBSSxJQUFJLENBQUMsT0FBTyxDQUFDLEVBQUUsQ0FBQztZQUNsQixPQUFPLElBQUksSUFBSSxDQUFDLE1BQU0sQ0FBQyxNQUFNLENBQUMsS0FBSyxDQUFDLElBQUksQ0FBQyxzQkFBc0IsRUFBRSxDQUFDLENBQUM7UUFDckUsQ0FBQztRQUVELElBQUksQ0FBQyxJQUFJLENBQUMsV0FBVyxDQUFDLEVBQUUsQ0FBQztZQUN2QixJQUFJLENBQUMsV0FBVyxDQUFDLEdBQUcsSUFBSSxJQUFJLENBQUMsTUFBTSxDQUFDLE1BQU0sQ0FBQyxLQUFLLENBQUMsSUFBSSxDQUFDLHNCQUFzQixFQUFFLENBQUMsQ0FBQztRQUNsRixDQUFDO1FBRUQsT0FBTyxJQUFJLENBQUMsV0FBVyxDQUFDLENBQUM7SUFDM0IsQ0FBQztDQUNGIn0=
@@ -1,15 +0,0 @@
1
- import { Context } from '@eggjs/core';
2
- import type { Tracer } from '../../lib/tracer.js';
3
- declare const TRACER: unique symbol;
4
- export default class TracerContext extends Context {
5
- [TRACER]: Tracer | undefined;
6
- get tracer(): Tracer;
7
- get traceId(): string;
8
- }
9
- declare module '@eggjs/core' {
10
- interface Context {
11
- tracer: Tracer;
12
- traceId: string;
13
- }
14
- }
15
- export {};
@@ -1,15 +0,0 @@
1
- import { Context } from '@eggjs/core';
2
- const TRACER = Symbol('context tracer');
3
- export default class TracerContext extends Context {
4
- [TRACER];
5
- get tracer() {
6
- if (!this[TRACER]) {
7
- this[TRACER] = new this.app.config.tracer.Class(this);
8
- }
9
- return this[TRACER];
10
- }
11
- get traceId() {
12
- return this.tracer.traceId;
13
- }
14
- }
15
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29udGV4dC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9hcHAvZXh0ZW5kL2NvbnRleHQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLE9BQU8sRUFBRSxNQUFNLGFBQWEsQ0FBQztBQUV0QyxNQUFNLE1BQU0sR0FBRyxNQUFNLENBQUMsZ0JBQWdCLENBQUMsQ0FBQztBQUV4QyxNQUFNLENBQUMsT0FBTyxPQUFPLGFBQWMsU0FBUSxPQUFPO0lBQ2hELENBQUMsTUFBTSxDQUFDLENBQXFCO0lBRTdCLElBQUksTUFBTTtRQUNSLElBQUksQ0FBQyxJQUFJLENBQUMsTUFBTSxDQUFDLEVBQUUsQ0FBQztZQUNsQixJQUFJLENBQUMsTUFBTSxDQUFDLEdBQUcsSUFBSSxJQUFJLENBQUMsR0FBRyxDQUFDLE1BQU0sQ0FBQyxNQUFNLENBQUMsS0FBSyxDQUFDLElBQUksQ0FBQyxDQUFDO1FBQ3hELENBQUM7UUFDRCxPQUFPLElBQUksQ0FBQyxNQUFNLENBQUMsQ0FBQztJQUN0QixDQUFDO0lBRUQsSUFBSSxPQUFPO1FBQ1QsT0FBTyxJQUFJLENBQUMsTUFBTSxDQUFDLE9BQU8sQ0FBQztJQUM3QixDQUFDO0NBQ0YifQ==
package/dist/esm/app.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import { TracerBoot } from './boot.js';
2
- export default TracerBoot;
package/dist/esm/app.js DELETED
@@ -1,3 +0,0 @@
1
- import { TracerBoot } from './boot.js';
2
- export default TracerBoot;
3
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXBwLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2FwcC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sV0FBVyxDQUFDO0FBRXZDLGVBQWUsVUFBVSxDQUFDIn0=
@@ -1,6 +0,0 @@
1
- import type { EggCore, ILifecycleBoot } from '@eggjs/core';
2
- export declare class TracerBoot implements ILifecycleBoot {
3
- private app;
4
- constructor(app: EggCore);
5
- didLoad(): Promise<void>;
6
- }
package/dist/esm/boot.js DELETED
@@ -1,11 +0,0 @@
1
- import { isReady } from './app/extend/application.js';
2
- export class TracerBoot {
3
- app;
4
- constructor(app) {
5
- this.app = app;
6
- }
7
- async didLoad() {
8
- this.app[isReady] = true;
9
- }
10
- }
11
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYm9vdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ib290LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sRUFBRSxPQUFPLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUV0RCxNQUFNLE9BQU8sVUFBVTtJQUNEO0lBQXBCLFlBQW9CLEdBQVk7UUFBWixRQUFHLEdBQUgsR0FBRyxDQUFTO0lBQUcsQ0FBQztJQUVwQyxLQUFLLENBQUMsT0FBTztRQUNYLElBQUksQ0FBQyxHQUFHLENBQUMsT0FBTyxDQUFDLEdBQUcsSUFBSSxDQUFDO0lBQzNCLENBQUM7Q0FDRiJ9
@@ -1,18 +0,0 @@
1
- import { Tracer } from '../lib/tracer.js';
2
- /**
3
- * tracer config
4
- * @member Config#tracer
5
- * @property {Tracer} Class - tracer class name
6
- */
7
- interface TracerConfig {
8
- Class: typeof Tracer;
9
- }
10
- declare const _default: {
11
- tracer: TracerConfig;
12
- };
13
- export default _default;
14
- declare module '@eggjs/core' {
15
- interface EggAppConfig {
16
- tracer: TracerConfig;
17
- }
18
- }
@@ -1,7 +0,0 @@
1
- import { Tracer } from '../lib/tracer.js';
2
- export default {
3
- tracer: {
4
- Class: Tracer,
5
- },
6
- };
7
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uZmlnLmRlZmF1bHQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvY29uZmlnL2NvbmZpZy5kZWZhdWx0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxNQUFNLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQztBQVcxQyxlQUFlO0lBQ2IsTUFBTSxFQUFFO1FBQ04sS0FBSyxFQUFFLE1BQU07S0FDRTtDQUNsQixDQUFDIn0=
@@ -1,6 +0,0 @@
1
- import './config/config.default.js';
2
- import './app/extend/application.js';
3
- import './app/extend/agent.js';
4
- import './app/extend/context.js';
5
- import { Tracer } from './lib/tracer.js';
6
- export { Tracer };
package/dist/esm/index.js DELETED
@@ -1,7 +0,0 @@
1
- import './config/config.default.js';
2
- import './app/extend/application.js';
3
- import './app/extend/agent.js';
4
- import './app/extend/context.js';
5
- import { Tracer } from './lib/tracer.js';
6
- export { Tracer };
7
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyw0QkFBNEIsQ0FBQztBQUNwQyxPQUFPLDZCQUE2QixDQUFDO0FBQ3JDLE9BQU8sdUJBQXVCLENBQUM7QUFDL0IsT0FBTyx5QkFBeUIsQ0FBQztBQUVqQyxPQUFPLEVBQUUsTUFBTSxFQUFFLE1BQU0saUJBQWlCLENBQUM7QUFFekMsT0FBTyxFQUFFLE1BQU0sRUFBRSxDQUFDIn0=
@@ -1,7 +0,0 @@
1
- import type { Context } from '@eggjs/core';
2
- export declare class Tracer {
3
- #private;
4
- readonly ctx: Context;
5
- constructor(ctx: Context);
6
- get traceId(): string;
7
- }
@@ -1,15 +0,0 @@
1
- import { randomUUID } from 'node:crypto';
2
- export class Tracer {
3
- ctx;
4
- #traceId;
5
- constructor(ctx) {
6
- this.ctx = ctx;
7
- }
8
- get traceId() {
9
- if (!this.#traceId) {
10
- this.#traceId = randomUUID();
11
- }
12
- return this.#traceId;
13
- }
14
- }
15
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHJhY2VyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2xpYi90cmFjZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFVBQVUsRUFBRSxNQUFNLGFBQWEsQ0FBQztBQUd6QyxNQUFNLE9BQU8sTUFBTTtJQUNSLEdBQUcsQ0FBVTtJQUN0QixRQUFRLENBQXFCO0lBRTdCLFlBQVksR0FBWTtRQUN0QixJQUFJLENBQUMsR0FBRyxHQUFHLEdBQUcsQ0FBQztJQUNqQixDQUFDO0lBRUQsSUFBSSxPQUFPO1FBQ1QsSUFBSSxDQUFDLElBQUksQ0FBQyxRQUFRLEVBQUUsQ0FBQztZQUNuQixJQUFJLENBQUMsUUFBUSxHQUFHLFVBQVUsRUFBRSxDQUFDO1FBQy9CLENBQUM7UUFDRCxPQUFPLElBQUksQ0FBQyxRQUFRLENBQUM7SUFDdkIsQ0FBQztDQUNGIn0=
@@ -1,3 +0,0 @@
1
- {
2
- "type": "module"
3
- }
package/dist/package.json DELETED
@@ -1,4 +0,0 @@
1
- {
2
- "name": "@eggjs/tracer",
3
- "version": "3.0.0"
4
- }
package/src/agent.ts DELETED
@@ -1,3 +0,0 @@
1
- import { TracerBoot } from './boot.js';
2
-
3
- export default TracerBoot;
@@ -1,3 +0,0 @@
1
- import TracerApplication from './application.js';
2
-
3
- export default TracerApplication;
@@ -1,27 +0,0 @@
1
- import { EggCore } from '@eggjs/core';
2
- import type { Tracer } from '../../lib/tracer.js';
3
-
4
- const cacheTracer = Symbol('before_ready_tracer');
5
- export const isReady = Symbol('egg_tracer_is_ready');
6
-
7
- export default class TracerApplication extends EggCore {
8
- [cacheTracer]: Tracer | undefined;
9
-
10
- get tracer(): Tracer {
11
- if (this[isReady]) {
12
- return new this.config.tracer.Class(this.createAnonymousContext());
13
- }
14
-
15
- if (!this[cacheTracer]) {
16
- this[cacheTracer] = new this.config.tracer.Class(this.createAnonymousContext());
17
- }
18
-
19
- return this[cacheTracer];
20
- }
21
- }
22
-
23
- declare module '@eggjs/core' {
24
- interface EggCore {
25
- tracer: Tracer;
26
- }
27
- }
@@ -1,25 +0,0 @@
1
- import { Context } from '@eggjs/core';
2
- import type { Tracer } from '../../lib/tracer.js';
3
- const TRACER = Symbol('context tracer');
4
-
5
- export default class TracerContext extends Context {
6
- [TRACER]: Tracer | undefined;
7
-
8
- get tracer(): Tracer {
9
- if (!this[TRACER]) {
10
- this[TRACER] = new this.app.config.tracer.Class(this);
11
- }
12
- return this[TRACER];
13
- }
14
-
15
- get traceId(): string {
16
- return this.tracer.traceId;
17
- }
18
- }
19
-
20
- declare module '@eggjs/core' {
21
- interface Context {
22
- tracer: Tracer;
23
- traceId: string;
24
- }
25
- }
package/src/app.ts DELETED
@@ -1,3 +0,0 @@
1
- import { TracerBoot } from './boot.js';
2
-
3
- export default TracerBoot;
package/src/boot.ts DELETED
@@ -1,10 +0,0 @@
1
- import type { EggCore, ILifecycleBoot } from '@eggjs/core';
2
- import { isReady } from './app/extend/application.js';
3
-
4
- export class TracerBoot implements ILifecycleBoot {
5
- constructor(private app: EggCore) {}
6
-
7
- async didLoad() {
8
- this.app[isReady] = true;
9
- }
10
- }
@@ -1,22 +0,0 @@
1
- import { Tracer } from '../lib/tracer.js';
2
-
3
- /**
4
- * tracer config
5
- * @member Config#tracer
6
- * @property {Tracer} Class - tracer class name
7
- */
8
- interface TracerConfig {
9
- Class: typeof Tracer;
10
- }
11
-
12
- export default {
13
- tracer: {
14
- Class: Tracer,
15
- } as TracerConfig,
16
- };
17
-
18
- declare module '@eggjs/core' {
19
- interface EggAppConfig {
20
- tracer: TracerConfig;
21
- }
22
- }
package/src/index.ts DELETED
@@ -1,8 +0,0 @@
1
- import './config/config.default.js';
2
- import './app/extend/application.js';
3
- import './app/extend/agent.js';
4
- import './app/extend/context.js';
5
-
6
- import { Tracer } from './lib/tracer.js';
7
-
8
- export { Tracer };
package/src/lib/tracer.ts DELETED
@@ -1,18 +0,0 @@
1
- import { randomUUID } from 'node:crypto';
2
- import type { Context } from '@eggjs/core';
3
-
4
- export class Tracer {
5
- readonly ctx: Context;
6
- #traceId: string | undefined;
7
-
8
- constructor(ctx: Context) {
9
- this.ctx = ctx;
10
- }
11
-
12
- get traceId() {
13
- if (!this.#traceId) {
14
- this.#traceId = randomUUID();
15
- }
16
- return this.#traceId;
17
- }
18
- }
@@ -1,4 +0,0 @@
1
- // make sure to import egg typings and let typescript know about it
2
- // @see https://github.com/whxaxes/blog/issues/11
3
- // and https://www.typescriptlang.org/docs/handbook/declaration-merging.html
4
- import 'egg';