@midwayjs/otel 3.10.4 → 3.10.6
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/dist/configuration.d.ts +2 -1
- package/dist/configuration.js +14 -0
- package/dist/service.js +2 -1
- package/index.d.ts +12 -0
- package/package.json +5 -5
package/dist/configuration.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { MidwayDecoratorService } from '@midwayjs/core';
|
|
1
|
+
import { MidwayApplicationManager, MidwayDecoratorService } from '@midwayjs/core';
|
|
2
2
|
import { TraceService } from './service';
|
|
3
3
|
export declare class OtelConfiguration {
|
|
4
4
|
decoratorService: MidwayDecoratorService;
|
|
5
5
|
traceService: TraceService;
|
|
6
|
+
applicationManager: MidwayApplicationManager;
|
|
6
7
|
onReady(): Promise<void>;
|
|
7
8
|
}
|
|
8
9
|
//# sourceMappingURL=configuration.d.ts.map
|
package/dist/configuration.js
CHANGED
|
@@ -43,6 +43,16 @@ let OtelConfiguration = class OtelConfiguration {
|
|
|
43
43
|
},
|
|
44
44
|
};
|
|
45
45
|
});
|
|
46
|
+
const apps = this.applicationManager.getApplications(['egg', 'koa']);
|
|
47
|
+
for (const app of apps) {
|
|
48
|
+
Object.defineProperties(app.context, {
|
|
49
|
+
traceId: {
|
|
50
|
+
get: () => {
|
|
51
|
+
return this.traceService.getTraceId();
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
}
|
|
46
56
|
}
|
|
47
57
|
};
|
|
48
58
|
__decorate([
|
|
@@ -53,6 +63,10 @@ __decorate([
|
|
|
53
63
|
(0, core_1.Inject)(),
|
|
54
64
|
__metadata("design:type", service_1.TraceService)
|
|
55
65
|
], OtelConfiguration.prototype, "traceService", void 0);
|
|
66
|
+
__decorate([
|
|
67
|
+
(0, core_1.Inject)(),
|
|
68
|
+
__metadata("design:type", core_1.MidwayApplicationManager)
|
|
69
|
+
], OtelConfiguration.prototype, "applicationManager", void 0);
|
|
56
70
|
OtelConfiguration = __decorate([
|
|
57
71
|
(0, core_1.Configuration)({
|
|
58
72
|
namespace: 'otel',
|
package/dist/service.js
CHANGED
|
@@ -21,7 +21,8 @@ let TraceService = class TraceService {
|
|
|
21
21
|
return api_1.trace.getSpan(api_1.context.active());
|
|
22
22
|
}
|
|
23
23
|
getTraceId() {
|
|
24
|
-
|
|
24
|
+
var _a;
|
|
25
|
+
return (_a = this.getCurrentSpan()) === null || _a === void 0 ? void 0 : _a.spanContext().traceId;
|
|
25
26
|
}
|
|
26
27
|
createSpan(name, callback) {
|
|
27
28
|
return api_1.trace.getTracer(this.currentTracerName).startActiveSpan(name, {
|
package/index.d.ts
CHANGED
|
@@ -5,3 +5,15 @@ declare module '@midwayjs/core/dist/interface' {
|
|
|
5
5
|
otel?: Record<string, any>;
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
|
+
|
|
9
|
+
declare module '@midwayjs/koa/dist/interface' {
|
|
10
|
+
interface Context {
|
|
11
|
+
traceId: string;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
declare module '@midwayjs/web/dist/interface' {
|
|
16
|
+
interface Context {
|
|
17
|
+
traceId: string;
|
|
18
|
+
}
|
|
19
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/otel",
|
|
3
3
|
"description": "midway open telemetry component",
|
|
4
|
-
"version": "3.10.
|
|
4
|
+
"version": "3.10.6",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"typings": "index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
"index.d.ts"
|
|
11
11
|
],
|
|
12
12
|
"devDependencies": {
|
|
13
|
-
"@midwayjs/core": "^3.10.
|
|
14
|
-
"@midwayjs/koa": "^3.10.
|
|
15
|
-
"@midwayjs/mock": "^3.10.
|
|
13
|
+
"@midwayjs/core": "^3.10.6",
|
|
14
|
+
"@midwayjs/koa": "^3.10.6",
|
|
15
|
+
"@midwayjs/mock": "^3.10.6",
|
|
16
16
|
"@opentelemetry/core": "^1.0.1",
|
|
17
17
|
"@opentelemetry/sdk-trace-base": "^1.0.1",
|
|
18
18
|
"@opentelemetry/sdk-trace-node": "^1.0.1"
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"type": "git",
|
|
42
42
|
"url": "https://github.com/midwayjs/midway.git"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "9d5babd57efe4c24415fcb3511bc4ca7c1bcb1b2"
|
|
45
45
|
}
|