@interfere/nest 0.0.1-canary.3 → 0.0.1-canary.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 +1 -1
- package/dist/init.cjs +1 -1
- package/dist/init.d.cts +12 -5
- package/dist/init.d.mts +12 -5
- package/dist/init.mjs +1 -1
- package/dist/nest-instrumentation.cjs +1 -0
- package/dist/nest-instrumentation.d.cts +12 -0
- package/dist/nest-instrumentation.d.mts +12 -0
- package/dist/nest-instrumentation.mjs +2 -0
- package/dist/package.cjs +1 -0
- package/dist/package.mjs +2 -0
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ bun add @interfere/nest
|
|
|
13
13
|
## Usage
|
|
14
14
|
|
|
15
15
|
```ts
|
|
16
|
-
// instrument.ts —
|
|
16
|
+
// instrument.ts — must run before @nestjs/core is imported
|
|
17
17
|
import { init } from "@interfere/nest";
|
|
18
18
|
init({ serviceName: "my-api", debug: true });
|
|
19
19
|
```
|
package/dist/init.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let _interfere_node=require("@interfere/node"),_opentelemetry_instrumentation=require("@opentelemetry/instrumentation"),_opentelemetry_instrumentation_nestjs_core=require("@opentelemetry/instrumentation-nestjs-core")
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const require_nest_instrumentation=require("./nest-instrumentation.cjs");let _interfere_node=require("@interfere/node"),node_module=require("node:module"),_opentelemetry_instrumentation=require("@opentelemetry/instrumentation"),_opentelemetry_instrumentation_nestjs_core=require("@opentelemetry/instrumentation-nestjs-core");const INIT_KEY=`__interfereNestInitialized__`,g=globalThis;function init(options={}){g[INIT_KEY]||(typeof node_module.register==`function`&&(0,node_module.register)(`import-in-the-middle/hook.mjs`,require("url").pathToFileURL(__filename).href),(0,_interfere_node.init)(options),(0,_opentelemetry_instrumentation.registerInstrumentations)({instrumentations:[new _opentelemetry_instrumentation_nestjs_core.NestInstrumentation,new require_nest_instrumentation.InterfereNestInstrumentation]}),g[INIT_KEY]=!0)}exports.init=init;
|
package/dist/init.d.cts
CHANGED
|
@@ -2,11 +2,18 @@ import { InitOptions, InitOptions as InitOptions$1 } from "@interfere/node";
|
|
|
2
2
|
|
|
3
3
|
//#region src/init.d.ts
|
|
4
4
|
/**
|
|
5
|
-
* Bootstraps `@interfere/node` and registers
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* `
|
|
5
|
+
* Bootstraps `@interfere/node` and registers auto-instrumentation for
|
|
6
|
+
* NestJS controllers, guards, pipes, interceptors, and middleware.
|
|
7
|
+
*
|
|
8
|
+
* Uses two complementary instrumentation strategies:
|
|
9
|
+
* - `@opentelemetry/instrumentation-nestjs-core` for NestFactory and
|
|
10
|
+
* router-level spans (when RITM hooks engage)
|
|
11
|
+
* - `InterfereNestInstrumentation` which patches `@Injectable` to wrap
|
|
12
|
+
* middleware, guards, pipes, and interceptors at the decorator level
|
|
13
|
+
* (always works, no RITM dependency for nested paths)
|
|
14
|
+
*
|
|
15
|
+
* Registers ESM loader hooks via `module.register()` so that
|
|
16
|
+
* `@nestjs/common` imports are intercepted for auto-instrumentation.
|
|
10
17
|
*/
|
|
11
18
|
declare function init(options?: InitOptions$1): void;
|
|
12
19
|
//#endregion
|
package/dist/init.d.mts
CHANGED
|
@@ -2,11 +2,18 @@ import { InitOptions, InitOptions as InitOptions$1 } from "@interfere/node";
|
|
|
2
2
|
|
|
3
3
|
//#region src/init.d.ts
|
|
4
4
|
/**
|
|
5
|
-
* Bootstraps `@interfere/node` and registers
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* `
|
|
5
|
+
* Bootstraps `@interfere/node` and registers auto-instrumentation for
|
|
6
|
+
* NestJS controllers, guards, pipes, interceptors, and middleware.
|
|
7
|
+
*
|
|
8
|
+
* Uses two complementary instrumentation strategies:
|
|
9
|
+
* - `@opentelemetry/instrumentation-nestjs-core` for NestFactory and
|
|
10
|
+
* router-level spans (when RITM hooks engage)
|
|
11
|
+
* - `InterfereNestInstrumentation` which patches `@Injectable` to wrap
|
|
12
|
+
* middleware, guards, pipes, and interceptors at the decorator level
|
|
13
|
+
* (always works, no RITM dependency for nested paths)
|
|
14
|
+
*
|
|
15
|
+
* Registers ESM loader hooks via `module.register()` so that
|
|
16
|
+
* `@nestjs/common` imports are intercepted for auto-instrumentation.
|
|
10
17
|
*/
|
|
11
18
|
declare function init(options?: InitOptions$1): void;
|
|
12
19
|
//#endregion
|
package/dist/init.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{init as init$1}from"@interfere/node";import{registerInstrumentations}from"@opentelemetry/instrumentation";import{NestInstrumentation}from"@opentelemetry/instrumentation-nestjs-core";
|
|
1
|
+
import{InterfereNestInstrumentation}from"./nest-instrumentation.mjs";import{register}from"node:module";import{init as init$1}from"@interfere/node";import{registerInstrumentations}from"@opentelemetry/instrumentation";import{NestInstrumentation}from"@opentelemetry/instrumentation-nestjs-core";const INIT_KEY=`__interfereNestInitialized__`,g=globalThis;function init(options={}){g[INIT_KEY]||(typeof register==`function`&®ister(`import-in-the-middle/hook.mjs`,import.meta.url),init$1(options),registerInstrumentations({instrumentations:[new NestInstrumentation,new InterfereNestInstrumentation]}),g[INIT_KEY]=!0)}export{init};
|
|
2
2
|
//# sourceMappingURL=init.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const require_package=require("./package.cjs");let _opentelemetry_instrumentation=require("@opentelemetry/instrumentation"),_opentelemetry_api=require("@opentelemetry/api");const SUPPORTED_VERSIONS=[`>=8.0.0 <12`],COMPONENT=`@nestjs/common`;var InterfereNestInstrumentation=class extends _opentelemetry_instrumentation.InstrumentationBase{constructor(config={}){super(require_package.name,require_package.version,config)}init(){let moduleDef=new _opentelemetry_instrumentation.InstrumentationNodeModuleDefinition(COMPONENT,SUPPORTED_VERSIONS);return moduleDef.files.push(this.getInjectableInstrumentation(SUPPORTED_VERSIONS)),moduleDef}getInjectableInstrumentation(versions){return new _opentelemetry_instrumentation.InstrumentationNodeModuleFile(`@nestjs/common/decorators/core/injectable.decorator.js`,versions,moduleExports=>((0,_opentelemetry_instrumentation.isWrapped)(moduleExports.Injectable)&&this._unwrap(moduleExports,`Injectable`),this._wrap(moduleExports,`Injectable`,original=>this.wrapInjectable(original)),moduleExports),moduleExports=>{this._unwrap(moduleExports,`Injectable`)})}wrapInjectable(original){let tracer=this.tracer;return function(options){return target=>target.__INTERFERE_PATCHED__?original(options)(target):(target.__INTERFERE_PATCHED__=!0,typeof target.prototype.use==`function`&&patchMethod(tracer,target,`use`,`middleware.nestjs`),typeof target.prototype.canActivate==`function`&&patchMethod(tracer,target,`canActivate`,`guard.nestjs`),typeof target.prototype.transform==`function`&&patchMethod(tracer,target,`transform`,`pipe.nestjs`),typeof target.prototype.intercept==`function`&&patchMethod(tracer,target,`intercept`,`interceptor.nestjs`),original(options)(target))}}};function patchMethod(tracer,target,method,op){let original=target.prototype[method];target.prototype[method]=function(...args){let span=tracer.startSpan(`${target.name}.${method}`,{kind:_opentelemetry_api.SpanKind.INTERNAL,attributes:{component:COMPONENT,"nestjs.type":op,"nestjs.callback":method,"nestjs.controller":target.name}}),ctx=_opentelemetry_api.trace.setSpan(_opentelemetry_api.context.active(),span);return _opentelemetry_api.context.with(ctx,()=>{try{let result=original.apply(this,args);return result&&typeof result.then==`function`?result.then(v=>(span.end(),v),err=>{throw span.recordException(err),span.setStatus({code:_opentelemetry_api.SpanStatusCode.ERROR}),span.end(),err}):(span.end(),result)}catch(err){throw span.recordException(err),span.setStatus({code:_opentelemetry_api.SpanStatusCode.ERROR}),span.end(),err}})}}exports.InterfereNestInstrumentation=InterfereNestInstrumentation;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { InstrumentationBase, InstrumentationConfig, InstrumentationNodeModuleDefinition } from "@opentelemetry/instrumentation";
|
|
2
|
+
|
|
3
|
+
//#region src/nest-instrumentation.d.ts
|
|
4
|
+
declare class InterfereNestInstrumentation extends InstrumentationBase {
|
|
5
|
+
constructor(config?: InstrumentationConfig);
|
|
6
|
+
init(): InstrumentationNodeModuleDefinition;
|
|
7
|
+
private getInjectableInstrumentation;
|
|
8
|
+
private wrapInjectable;
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { InterfereNestInstrumentation };
|
|
12
|
+
//# sourceMappingURL=nest-instrumentation.d.cts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { InstrumentationBase, InstrumentationConfig, InstrumentationNodeModuleDefinition } from "@opentelemetry/instrumentation";
|
|
2
|
+
|
|
3
|
+
//#region src/nest-instrumentation.d.ts
|
|
4
|
+
declare class InterfereNestInstrumentation extends InstrumentationBase {
|
|
5
|
+
constructor(config?: InstrumentationConfig);
|
|
6
|
+
init(): InstrumentationNodeModuleDefinition;
|
|
7
|
+
private getInjectableInstrumentation;
|
|
8
|
+
private wrapInjectable;
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { InterfereNestInstrumentation };
|
|
12
|
+
//# sourceMappingURL=nest-instrumentation.d.mts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{name,version}from"./package.mjs";import{InstrumentationBase,InstrumentationNodeModuleDefinition,InstrumentationNodeModuleFile,isWrapped}from"@opentelemetry/instrumentation";import{SpanKind,SpanStatusCode,context,trace}from"@opentelemetry/api";const SUPPORTED_VERSIONS=[`>=8.0.0 <12`],COMPONENT=`@nestjs/common`;var InterfereNestInstrumentation=class extends InstrumentationBase{constructor(config={}){super(name,version,config)}init(){let moduleDef=new InstrumentationNodeModuleDefinition(COMPONENT,SUPPORTED_VERSIONS);return moduleDef.files.push(this.getInjectableInstrumentation(SUPPORTED_VERSIONS)),moduleDef}getInjectableInstrumentation(versions){return new InstrumentationNodeModuleFile(`@nestjs/common/decorators/core/injectable.decorator.js`,versions,moduleExports=>(isWrapped(moduleExports.Injectable)&&this._unwrap(moduleExports,`Injectable`),this._wrap(moduleExports,`Injectable`,original=>this.wrapInjectable(original)),moduleExports),moduleExports=>{this._unwrap(moduleExports,`Injectable`)})}wrapInjectable(original){let tracer=this.tracer;return function(options){return target=>target.__INTERFERE_PATCHED__?original(options)(target):(target.__INTERFERE_PATCHED__=!0,typeof target.prototype.use==`function`&&patchMethod(tracer,target,`use`,`middleware.nestjs`),typeof target.prototype.canActivate==`function`&&patchMethod(tracer,target,`canActivate`,`guard.nestjs`),typeof target.prototype.transform==`function`&&patchMethod(tracer,target,`transform`,`pipe.nestjs`),typeof target.prototype.intercept==`function`&&patchMethod(tracer,target,`intercept`,`interceptor.nestjs`),original(options)(target))}}};function patchMethod(tracer,target,method,op){let original=target.prototype[method];target.prototype[method]=function(...args){let span=tracer.startSpan(`${target.name}.${method}`,{kind:SpanKind.INTERNAL,attributes:{component:COMPONENT,"nestjs.type":op,"nestjs.callback":method,"nestjs.controller":target.name}}),ctx=trace.setSpan(context.active(),span);return context.with(ctx,()=>{try{let result=original.apply(this,args);return result&&typeof result.then==`function`?result.then(v=>(span.end(),v),err=>{throw span.recordException(err),span.setStatus({code:SpanStatusCode.ERROR}),span.end(),err}):(span.end(),result)}catch(err){throw span.recordException(err),span.setStatus({code:SpanStatusCode.ERROR}),span.end(),err}})}}export{InterfereNestInstrumentation};
|
|
2
|
+
//# sourceMappingURL=nest-instrumentation.mjs.map
|
package/dist/package.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var name=`@interfere/nest`,version=`0.0.1-canary.4`;Object.defineProperty(exports,"name",{enumerable:!0,get:function(){return name}}),Object.defineProperty(exports,"version",{enumerable:!0,get:function(){return version}});
|
package/dist/package.mjs
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@interfere/nest",
|
|
3
|
-
"version": "0.0.1-canary.
|
|
3
|
+
"version": "0.0.1-canary.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "NestJS SDK for Interfere. Auto-captures uncaught exceptions from controllers, providers, and middleware via a global ExceptionFilter, plus re-exports the @interfere/node OTel instrumentation.",
|
|
6
6
|
"keywords": [
|
|
@@ -55,7 +55,8 @@
|
|
|
55
55
|
"typecheck": "tsc --noEmit --incremental"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@interfere/node": "^0.0.1-canary.
|
|
58
|
+
"@interfere/node": "^0.0.1-canary.4",
|
|
59
|
+
"@opentelemetry/api": "^1.9.1",
|
|
59
60
|
"@opentelemetry/instrumentation": "^0.218.0",
|
|
60
61
|
"@opentelemetry/instrumentation-nestjs-core": "^0.64.0"
|
|
61
62
|
},
|