@midwayjs/faas 4.0.0-beta.11 → 4.0.0-beta.12

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/framework.js CHANGED
@@ -212,7 +212,47 @@ let MidwayFaaSFramework = class MidwayFaaSFramework extends core_1.BaseFramework
212
212
  if (this.configurationOptions.applicationAdapter?.runContextHook) {
213
213
  this.configurationOptions.applicationAdapter.runContextHook(context);
214
214
  }
215
- const result = await (await this.applyMiddleware(async (ctx, next) => {
215
+ const traceService = this.applicationContext.get(core_1.MidwayTraceService);
216
+ const traceMetaResolver = this.configurationOptions?.tracing?.meta;
217
+ const traceEnabled = this.configurationOptions?.tracing?.enable !== false;
218
+ const traceExtractor = this.configurationOptions?.tracing
219
+ ?.extractor;
220
+ const entryCarrierDefault = isHttpFunction
221
+ ? context.headers || {}
222
+ : context.originEvent?.headers ||
223
+ context.originEvent?.properties ||
224
+ context.originEvent ||
225
+ {};
226
+ const entryCarrier = typeof traceExtractor === 'function'
227
+ ? traceExtractor({
228
+ ctx: context,
229
+ request: context.originEvent,
230
+ response: context.originContext,
231
+ custom: {
232
+ handlerMapping,
233
+ isHttpFunction,
234
+ },
235
+ })
236
+ : entryCarrierDefault;
237
+ const result = await traceService.runWithEntrySpan(`faas ${handlerMapping}`, {
238
+ enable: traceEnabled,
239
+ carrier: entryCarrier ?? entryCarrierDefault,
240
+ attributes: {
241
+ 'midway.protocol': isHttpFunction ? 'faas-http' : 'faas-event',
242
+ 'midway.faas.handler': handlerMapping,
243
+ },
244
+ meta: traceMetaResolver,
245
+ metaArgs: {
246
+ ctx: context,
247
+ carrier: entryCarrier ?? entryCarrierDefault,
248
+ request: context.originEvent,
249
+ response: context.originContext,
250
+ custom: {
251
+ handlerMapping,
252
+ isHttpFunction,
253
+ },
254
+ },
255
+ }, async () => await (await this.applyMiddleware(async (ctx, next) => {
216
256
  const fn = await this.middlewareService.compose([
217
257
  ...(isHttpFunction
218
258
  ? this.httpMiddlewareManager
@@ -245,7 +285,7 @@ let MidwayFaaSFramework = class MidwayFaaSFramework extends core_1.BaseFramework
245
285
  },
246
286
  ], this.app);
247
287
  return await fn(ctx, next);
248
- }))(context);
288
+ }))(context));
249
289
  if (isHttpFunction) {
250
290
  if (options.isCustomHttpResponse) {
251
291
  return context.body;
package/dist/starter.js CHANGED
@@ -50,7 +50,8 @@ class AbstractBootstrapStarter {
50
50
  }
51
51
  async initFramework(bootstrapOptions = {}) {
52
52
  // init midway
53
- this.applicationContext = await (0, core_1.initializeGlobalApplicationContext)(bootstrapOptions);
53
+ this.applicationContext =
54
+ await (0, core_1.initializeGlobalApplicationContext)(bootstrapOptions);
54
55
  const midwayFrameworkService = this.applicationContext.get(core_1.MidwayFrameworkService);
55
56
  this.framework = midwayFrameworkService.getMainFramework();
56
57
  }
package/index.d.ts CHANGED
@@ -84,7 +84,7 @@ interface TableStoreRecord {
84
84
  {
85
85
  ColumnName: string;
86
86
  Value: any;
87
- }
87
+ },
88
88
  ];
89
89
  Columns: [
90
90
  {
@@ -92,7 +92,7 @@ interface TableStoreRecord {
92
92
  ColumnName: string;
93
93
  Value: any;
94
94
  Timestamp: number;
95
- }
95
+ },
96
96
  ];
97
97
  }
98
98
 
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@midwayjs/faas",
3
- "version": "4.0.0-beta.11",
3
+ "version": "4.0.0-beta.12",
4
4
  "description": "Midway Framework for FaaS (Function as a Service)",
5
5
  "main": "dist/index.js",
6
6
  "typings": "index.d.ts",
7
7
  "dependencies": {
8
- "@midwayjs/core": "^4.0.0-beta.11",
9
- "@midwayjs/serverless-http-parser": "^4.0.0-beta.11",
8
+ "@midwayjs/core": "^4.0.0-beta.12",
9
+ "@midwayjs/serverless-http-parser": "^4.0.0-beta.12",
10
10
  "@midwayjs/simple-lock": "^1.1.4"
11
11
  },
12
12
  "devDependencies": {
13
13
  "@midwayjs/cookies": "^1.0.2",
14
14
  "@midwayjs/logger": "^4.0.0",
15
- "@midwayjs/mock": "^4.0.0-beta.11",
15
+ "@midwayjs/mock": "^4.0.0-beta.12",
16
16
  "mm": "3.4.0"
17
17
  },
18
18
  "engines": {
@@ -44,5 +44,5 @@
44
44
  "url": "git@github.com:midwayjs/midway.git"
45
45
  },
46
46
  "license": "MIT",
47
- "gitHead": "6ef05719ca6e900f1ec34aff7a5c5a9614358c50"
47
+ "gitHead": "1c48179b7c827ba8ec9351e9b6c36ec1726d3e11"
48
48
  }