@interfere/nest 0.0.1-canary.2 → 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 +23 -3
- package/dist/init.cjs +1 -1
- package/dist/init.d.cts +15 -16
- package/dist/init.d.mts +15 -16
- 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 -1
- package/dist/package.mjs +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -13,9 +13,9 @@ 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
|
-
init({ serviceName: "my-api" });
|
|
18
|
+
init({ serviceName: "my-api", debug: true });
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
```ts
|
|
@@ -40,4 +40,24 @@ import { InterfereModule } from "@interfere/nest";
|
|
|
40
40
|
export class AppModule {}
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
## Build & Deploy
|
|
44
|
+
|
|
45
|
+
Add a `postbuild` script so source maps are uploaded and the release is registered with the collector:
|
|
46
|
+
|
|
47
|
+
```json
|
|
48
|
+
{
|
|
49
|
+
"scripts": {
|
|
50
|
+
"build": "tsc",
|
|
51
|
+
"postbuild": "interfere sourcemaps upload ./dist"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Environment Variables
|
|
57
|
+
|
|
58
|
+
| Variable | Where | Purpose |
|
|
59
|
+
|---|---|---|
|
|
60
|
+
| `INTERFERE_PUBLIC_KEY` | Runtime | Routes spans to your surface (`interfere_pk_*`) |
|
|
61
|
+
| `INTERFERE_API_KEY` | CI / Build | Uploads source maps and registers releases (`interfere_ak_*`) |
|
|
62
|
+
|
|
63
|
+
Full docs at <https://interfere.com/docs>.
|
package/dist/init.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const
|
|
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
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
import { InitOptions as InitOptions$1 } from "@interfere/node";
|
|
1
|
+
import { InitOptions, InitOptions as InitOptions$1 } from "@interfere/node";
|
|
2
2
|
|
|
3
3
|
//#region src/init.d.ts
|
|
4
|
-
interface InitOptions extends InitOptions$1 {
|
|
5
|
-
/**
|
|
6
|
-
* Log a one-line confirmation to `stdout` on successful init.
|
|
7
|
-
* Useful during integration to verify the SDK is wired up.
|
|
8
|
-
* Default `false`.
|
|
9
|
-
*/
|
|
10
|
-
readonly debug?: boolean;
|
|
11
|
-
}
|
|
12
4
|
/**
|
|
13
|
-
* Bootstraps `@interfere/node` and registers
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* `
|
|
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.
|
|
18
17
|
*/
|
|
19
|
-
declare function init(options?: InitOptions): void;
|
|
18
|
+
declare function init(options?: InitOptions$1): void;
|
|
20
19
|
//#endregion
|
|
21
|
-
export { InitOptions, init };
|
|
20
|
+
export { type InitOptions, init };
|
|
22
21
|
//# sourceMappingURL=init.d.cts.map
|
package/dist/init.d.mts
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
import { InitOptions as InitOptions$1 } from "@interfere/node";
|
|
1
|
+
import { InitOptions, InitOptions as InitOptions$1 } from "@interfere/node";
|
|
2
2
|
|
|
3
3
|
//#region src/init.d.ts
|
|
4
|
-
interface InitOptions extends InitOptions$1 {
|
|
5
|
-
/**
|
|
6
|
-
* Log a one-line confirmation to `stdout` on successful init.
|
|
7
|
-
* Useful during integration to verify the SDK is wired up.
|
|
8
|
-
* Default `false`.
|
|
9
|
-
*/
|
|
10
|
-
readonly debug?: boolean;
|
|
11
|
-
}
|
|
12
4
|
/**
|
|
13
|
-
* Bootstraps `@interfere/node` and registers
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* `
|
|
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.
|
|
18
17
|
*/
|
|
19
|
-
declare function init(options?: InitOptions): void;
|
|
18
|
+
declare function init(options?: InitOptions$1): void;
|
|
20
19
|
//#endregion
|
|
21
|
-
export { InitOptions, init };
|
|
20
|
+
export { type InitOptions, init };
|
|
22
21
|
//# sourceMappingURL=init.d.mts.map
|
package/dist/init.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
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
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var name=`@interfere/nest`,version=`0.0.1-canary.
|
|
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
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var name=`@interfere/nest`,version=`0.0.1-canary.
|
|
1
|
+
var name=`@interfere/nest`,version=`0.0.1-canary.4`;export{name,version};
|
|
2
2
|
//# sourceMappingURL=package.mjs.map
|
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
|
},
|