@getvision/adapter-fastify 0.0.7 → 0.0.9-22facf0-develop

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 CHANGED
@@ -1,5 +1,12 @@
1
1
  # @getvision/adapter-fastify
2
2
 
3
+ ## 0.0.8
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [2635948]
8
+ - @getvision/core@0.0.8
9
+
3
10
  ## 0.0.7
4
11
 
5
12
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAElE,OAAO,EACL,UAAU,EAMX,MAAM,iBAAiB,CAAA;AACxB,OAAO,KAAK,EAIV,KAAK,EACL,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,iBAAiB,CAAA;AAGxB,UAAU,aAAa;IACrB,MAAM,EAAE,UAAU,CAAA;IAClB,KAAK,EAAE,KAAK,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,wBAAgB,gBAAgB,IAAI,aAAa,CAMhD;AAED,wBAAgB,aAAa,KAInB,CAAC,EACP,MAAM,MAAM,EACZ,YAAY,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,YAAK,EACpC,IAAI,MAAM,CAAC,KACV,CAAC,CAgCL;AAKD,wBAAgB,iBAAiB,IAAI,UAAU,GAAG,IAAI,CAErD;AA6OD,eAAO,MAAM,YAAY,0CAGvB,CAAA;AAEF,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,eAAe,EACxB,OAAO,CAAC,EAAE;IAAE,QAAQ,CAAC,EAAE,iBAAiB,EAAE,CAAA;CAAE,GAC3C,IAAI,CAgEN;AAmGD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAElE,OAAO,EACL,UAAU,EAOX,MAAM,iBAAiB,CAAA;AACxB,OAAO,KAAK,EAIV,KAAK,EACL,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,iBAAiB,CAAA;AAGxB,UAAU,aAAa;IACrB,MAAM,EAAE,UAAU,CAAA;IAClB,KAAK,EAAE,KAAK,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,wBAAgB,gBAAgB,IAAI,aAAa,CAMhD;AAED,wBAAgB,aAAa,KAInB,CAAC,EACP,MAAM,MAAM,EACZ,YAAY,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,YAAK,EACpC,IAAI,MAAM,CAAC,KACV,CAAC,CAgCL;AAKD,wBAAgB,iBAAiB,IAAI,UAAU,GAAG,IAAI,CAErD;AAqPD,eAAO,MAAM,YAAY,0CAGvB,CAAA;AAEF,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,eAAe,EACxB,OAAO,CAAC,EAAE;IAAE,QAAQ,CAAC,EAAE,iBAAiB,EAAE,CAAA;CAAE,GAC3C,IAAI,CAgEN;AAmGD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA"}
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import fp from 'fastify-plugin';
2
- import { VisionCore, autoDetectPackageInfo, autoDetectIntegrations, detectDrizzle, startDrizzleStudio, stopDrizzleStudio, } from '@getvision/core';
2
+ import { VisionCore, autoDetectPackageInfo, autoDetectIntegrations, detectDrizzle, startDrizzleStudio, stopDrizzleStudio, traceContext, } from '@getvision/core';
3
3
  import { fastifyRequestContext, requestContext } from '@fastify/request-context';
4
4
  export function getVisionContext() {
5
5
  const ctx = requestContext.get('visionTrace');
@@ -171,6 +171,13 @@ const visionPluginImpl = async (fastify, options) => {
171
171
  traceId: trace.id,
172
172
  rootSpanId: rootSpan.id,
173
173
  });
174
+ // Set core trace context for ConsoleInterceptor
175
+ // Fastify's onRequest hook doesn't wrap the handler execution in a callback,
176
+ // so we use enterWith() to set the context for the remainder of the sync execution
177
+ // and hopefully async chain if not broken.
178
+ if (traceContext) {
179
+ traceContext.enterWith(trace.id);
180
+ }
174
181
  tracer.setAttribute(rootSpan.id, 'http.method', request.method);
175
182
  tracer.setAttribute(rootSpan.id, 'http.path', request.url);
176
183
  tracer.setAttribute(rootSpan.id, 'http.url', request.url);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getvision/adapter-fastify",
3
- "version": "0.0.7",
3
+ "version": "0.0.9-22facf0-develop",
4
4
  "description": "Fastify adapter for Vision Dashboard",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
package/src/index.ts CHANGED
@@ -7,6 +7,7 @@ import {
7
7
  detectDrizzle,
8
8
  startDrizzleStudio,
9
9
  stopDrizzleStudio,
10
+ traceContext,
10
11
  } from '@getvision/core'
11
12
  import type {
12
13
  RequestBodySchema,
@@ -244,6 +245,14 @@ const visionPluginImpl: FastifyPluginAsync<VisionFastifyOptions> = async (fastif
244
245
  rootSpanId: rootSpan.id,
245
246
  })
246
247
 
248
+ // Set core trace context for ConsoleInterceptor
249
+ // Fastify's onRequest hook doesn't wrap the handler execution in a callback,
250
+ // so we use enterWith() to set the context for the remainder of the sync execution
251
+ // and hopefully async chain if not broken.
252
+ if (traceContext) {
253
+ traceContext.enterWith(trace.id)
254
+ }
255
+
247
256
  tracer.setAttribute(rootSpan.id, 'http.method', request.method)
248
257
  tracer.setAttribute(rootSpan.id, 'http.path', request.url)
249
258
  tracer.setAttribute(rootSpan.id, 'http.url', request.url)