@nathapp/nestjs-observability 4.0.0 → 4.0.2

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.
Files changed (45) hide show
  1. package/dist/metrics/http-metrics.interceptor.d.ts +12 -0
  2. package/dist/metrics/http-metrics.interceptor.js +15 -4
  3. package/dist/metrics/http-metrics.interceptor.js.map +1 -1
  4. package/dist/metrics/index.d.ts +1 -1
  5. package/dist/metrics/index.js +2 -1
  6. package/dist/metrics/index.js.map +1 -1
  7. package/dist/module/observability.module.d.ts +7 -0
  8. package/dist/module/observability.module.js +23 -16
  9. package/dist/module/observability.module.js.map +1 -1
  10. package/package.json +6 -6
  11. package/.eslintrc.js +0 -8
  12. package/.nax/features/nestjs-observability/.nax-acceptance.test.ts +0 -797
  13. package/.turbo/turbo-build.log +0 -4
  14. package/CHANGELOG.md +0 -43
  15. package/lib/constant/index.ts +0 -1
  16. package/lib/constant/observability.constants.ts +0 -21
  17. package/lib/index.ts +0 -17
  18. package/lib/interface/index.ts +0 -2
  19. package/lib/interface/observability-module-options.interface.ts +0 -47
  20. package/lib/interface/tracing-bootstrap-options.interface.ts +0 -17
  21. package/lib/metrics/http-metrics.interceptor.ts +0 -174
  22. package/lib/metrics/index.ts +0 -7
  23. package/lib/metrics/metrics.providers.ts +0 -134
  24. package/lib/module/index.ts +0 -1
  25. package/lib/module/observability.module.ts +0 -236
  26. package/lib/tracing/index.ts +0 -4
  27. package/lib/tracing/init-tracing.ts +0 -92
  28. package/lib/tracing/shutdown.ts +0 -28
  29. package/lib/tracing/trace-context.interceptor.ts +0 -42
  30. package/lib/tracing/trace-internal.ts +0 -19
  31. package/lib/tracing/trace.decorator.ts +0 -63
  32. package/lib/tracing/trace.service.ts +0 -48
  33. package/test/jest-nax.json +0 -27
  34. package/test/jest-test.json +0 -28
  35. package/test/metrics/http-metrics.interceptor.spec.ts +0 -453
  36. package/test/metrics/metrics.providers.spec.ts +0 -97
  37. package/test/module/observability.module.spec.ts +0 -229
  38. package/test/tracing/build-node-sdk.spec.ts +0 -224
  39. package/test/tracing/init-tracing.idempotency.spec.ts +0 -64
  40. package/test/tracing/init-tracing.shutdown.spec.ts +0 -88
  41. package/test/tracing/shutdown.spec.ts +0 -109
  42. package/test/tracing/trace-context.interceptor.spec.ts +0 -221
  43. package/test/tracing/trace.decorator.spec.ts +0 -153
  44. package/test/tracing/trace.service.spec.ts +0 -205
  45. package/tsconfig.json +0 -9
@@ -1,236 +0,0 @@
1
- import { DynamicModule, Module, Provider } from '@nestjs/common';
2
- import { APP_INTERCEPTOR } from '@nestjs/core';
3
- import { PrometheusModule } from '@willsoto/nestjs-prometheus';
4
- import { ConfigurableModuleClass } from '@nathapp/nestjs-common';
5
- import { RequestContextService } from '@nathapp/nestjs-logging';
6
- import {
7
- DEFAULT_DURATION_BUCKETS,
8
- DEFAULT_METRICS_PATH,
9
- OBSERVABILITY_MODULE_OPTIONS,
10
- } from '../constant';
11
- import {
12
- ObservabilityAsyncModuleOptions,
13
- ObservabilityModuleOptions,
14
- } from '../interface';
15
- import { HttpMetricsInterceptor } from '../metrics/http-metrics.interceptor';
16
- import {
17
- buildRedMetricProviders,
18
- buildRedMetricProvidersFromOptionsToken,
19
- PROM_METRIC_HTTP_REQUEST_DURATION_SECONDS,
20
- PROM_METRIC_HTTP_REQUEST_ERRORS_TOTAL,
21
- PROM_METRIC_HTTP_REQUESTS_TOTAL,
22
- } from '../metrics/metrics.providers';
23
- import { TraceContextInterceptor } from '../tracing/trace-context.interceptor';
24
- import { TraceService } from '../tracing/trace.service';
25
-
26
- const isTraceEnabled = (opts: ObservabilityModuleOptions | undefined): boolean =>
27
- opts?.tracing?.enabled !== false;
28
-
29
- const isMetricsEnabled = (opts: ObservabilityModuleOptions | undefined): boolean =>
30
- opts?.metrics?.enabled !== false;
31
-
32
- const isCorrelationBridgeEnabled = (opts: ObservabilityModuleOptions | undefined): boolean =>
33
- opts?.tracing?.correlationBridge !== false;
34
-
35
- const resolvePrefix = (opts: ObservabilityModuleOptions | undefined): string =>
36
- opts?.metrics?.prefix ?? '';
37
-
38
- const resolvePath = (opts: ObservabilityModuleOptions | undefined): string =>
39
- opts?.metrics?.path ?? DEFAULT_METRICS_PATH;
40
-
41
- const resolveBuckets = (opts: ObservabilityModuleOptions | undefined): number[] =>
42
- opts?.metrics?.buckets ?? DEFAULT_DURATION_BUCKETS;
43
-
44
- const resolveIgnoreRoutes = (opts: ObservabilityModuleOptions | undefined): string[] =>
45
- opts?.metrics?.ignoreRoutes ?? [];
46
-
47
- const buildPrometheusOptions = (opts: ObservabilityModuleOptions): {
48
- path: string;
49
- defaultMetrics: { enabled: boolean };
50
- } => ({
51
- path: resolvePath(opts),
52
- defaultMetrics: { enabled: opts.metrics?.defaultMetrics !== false },
53
- });
54
-
55
- /**
56
- * Global module wiring Prometheus metrics + OTel trace helpers.
57
- *
58
- * Wires (per design): PrometheusModule (path/defaultMetrics), RED metric providers,
59
- * HttpMetricsInterceptor + TraceContextInterceptor as APP_INTERCEPTORs, TraceService, and
60
- * RequestContextService for the ALS bridge. Mirrors AuditModule's register/registerAsync.
61
- */
62
- @Module({
63
- providers: [TraceService, RequestContextService],
64
- exports: [TraceService, RequestContextService],
65
- })
66
- export class ObservabilityModule extends ConfigurableModuleClass<ObservabilityModuleOptions>(
67
- OBSERVABILITY_MODULE_OPTIONS,
68
- ) {
69
- static register(options?: ObservabilityModuleOptions): DynamicModule {
70
- const opts = options ?? {};
71
- const base = super.register(opts);
72
- const metricsEnabled = isMetricsEnabled(opts);
73
- return {
74
- ...base,
75
- module: ObservabilityModule,
76
- global: true,
77
- imports: [
78
- ...(metricsEnabled
79
- ? [PrometheusModule.register(buildPrometheusOptions(opts))]
80
- : []),
81
- ...(base.imports ?? []),
82
- ],
83
- providers: [
84
- ...(base.providers ?? []),
85
- ...(metricsEnabled
86
- ? buildRedMetricProviders(resolvePrefix(opts), resolveBuckets(opts))
87
- : []),
88
- ...buildInterceptors(opts),
89
- ],
90
- exports: [...(base.exports ?? [])],
91
- };
92
- }
93
-
94
- static registerAsync(options: ObservabilityAsyncModuleOptions): DynamicModule {
95
- if (!options.useFactory) {
96
- throw new Error(
97
- 'ObservabilityModule.registerAsync requires `useFactory`. ' +
98
- '`useClass` and `useExisting` are not supported.',
99
- );
100
- }
101
- const base = super.registerAsync(options);
102
- return {
103
- ...base,
104
- module: ObservabilityModule,
105
- global: true,
106
- imports: [
107
- PrometheusModule.registerAsync({
108
- useFactory: async (...args: unknown[]) => {
109
- const factoryOptions = await options.useFactory!(...args);
110
- return isMetricsEnabled(factoryOptions)
111
- ? buildPrometheusOptions(factoryOptions)
112
- : { path: DEFAULT_METRICS_PATH, defaultMetrics: { enabled: false } };
113
- },
114
- inject: options.inject ?? [],
115
- }),
116
- ...(base.imports ?? []),
117
- ...(options.imports ?? []),
118
- ],
119
- providers: [
120
- ...(base.providers ?? []),
121
- ...buildRedMetricProvidersFromOptionsToken(),
122
- ...buildInterceptorsAsync(),
123
- ],
124
- exports: [...(base.exports ?? [])],
125
- };
126
- }
127
- }
128
-
129
- /**
130
- * Sync (register) path: options are resolved synchronously, so we build concrete
131
- * Counter/Histogram instances using the resolved prefix/buckets, register
132
- * HttpMetricsInterceptor + TraceContextInterceptor as regular providers (so
133
- * consumers can also `app.get(...)` them), and expose them via APP_INTERCEPTOR.
134
- */
135
- const buildInterceptors = (opts: ObservabilityModuleOptions): Provider[] => {
136
- const providers: Provider[] = [];
137
-
138
- if (isMetricsEnabled(opts)) {
139
- providers.push({
140
- provide: HttpMetricsInterceptor,
141
- inject: [
142
- PROM_METRIC_HTTP_REQUESTS_TOTAL,
143
- PROM_METRIC_HTTP_REQUEST_ERRORS_TOTAL,
144
- PROM_METRIC_HTTP_REQUEST_DURATION_SECONDS,
145
- ],
146
- useFactory: (
147
- requests: import('prom-client').Counter<string> | undefined,
148
- errors: import('prom-client').Counter<string> | undefined,
149
- duration: import('prom-client').Histogram<string> | undefined,
150
- ) => {
151
- const interceptor = new HttpMetricsInterceptor(requests, errors, duration);
152
- interceptor.setIgnoreRoutes(resolveIgnoreRoutes(opts));
153
- return interceptor;
154
- },
155
- });
156
- providers.push({
157
- provide: APP_INTERCEPTOR,
158
- useExisting: HttpMetricsInterceptor,
159
- });
160
- }
161
-
162
- if (isTraceEnabled(opts) && isCorrelationBridgeEnabled(opts)) {
163
- providers.push({
164
- provide: TraceContextInterceptor,
165
- inject: [RequestContextService],
166
- useFactory: (context: RequestContextService) =>
167
- new TraceContextInterceptor(context),
168
- });
169
- providers.push({
170
- provide: APP_INTERCEPTOR,
171
- useExisting: TraceContextInterceptor,
172
- });
173
- }
174
-
175
- return providers;
176
- };
177
-
178
- /**
179
- * Async (registerAsync) path: options are resolved via the injected factory at
180
- * DI time. RED metrics + the two interceptors are all bound to factories that
181
- * read OBSERVABILITY_MODULE_OPTIONS so the resolved values drive the wiring.
182
- *
183
- * Mirrors `buildInterceptors` (sync): when metrics or tracing are disabled, the
184
- * class provider returns `null` from its factory so DI skips wiring an actual
185
- * interceptor instance and APP_INTERCEPTOR registration has nothing to expose.
186
- */
187
- const buildInterceptorsAsync = (): Provider[] => [
188
- {
189
- provide: HttpMetricsInterceptor,
190
- inject: [
191
- OBSERVABILITY_MODULE_OPTIONS,
192
- PROM_METRIC_HTTP_REQUESTS_TOTAL,
193
- PROM_METRIC_HTTP_REQUEST_ERRORS_TOTAL,
194
- PROM_METRIC_HTTP_REQUEST_DURATION_SECONDS,
195
- ],
196
- useFactory: (
197
- options: ObservabilityModuleOptions | undefined,
198
- requests: import('prom-client').Counter<string> | undefined,
199
- errors: import('prom-client').Counter<string> | undefined,
200
- duration: import('prom-client').Histogram<string> | undefined,
201
- ) => {
202
- if (!isMetricsEnabled(options)) return null;
203
- const interceptor = new HttpMetricsInterceptor(requests, errors, duration);
204
- interceptor.setIgnoreRoutes(resolveIgnoreRoutes(options));
205
- return interceptor;
206
- },
207
- },
208
- {
209
- provide: APP_INTERCEPTOR,
210
- inject: [OBSERVABILITY_MODULE_OPTIONS, HttpMetricsInterceptor],
211
- useFactory: (
212
- options: ObservabilityModuleOptions | undefined,
213
- interceptor: HttpMetricsInterceptor | null,
214
- ) => (isMetricsEnabled(options) ? interceptor : null),
215
- },
216
- {
217
- provide: TraceContextInterceptor,
218
- inject: [OBSERVABILITY_MODULE_OPTIONS, RequestContextService],
219
- useFactory: (
220
- options: ObservabilityModuleOptions | undefined,
221
- context: RequestContextService,
222
- ) => {
223
- if (!isTraceEnabled(options) || !isCorrelationBridgeEnabled(options)) return null;
224
- return new TraceContextInterceptor(context);
225
- },
226
- },
227
- {
228
- provide: APP_INTERCEPTOR,
229
- inject: [OBSERVABILITY_MODULE_OPTIONS, TraceContextInterceptor],
230
- useFactory: (
231
- options: ObservabilityModuleOptions | undefined,
232
- interceptor: TraceContextInterceptor | null,
233
- ) =>
234
- isTraceEnabled(options) && isCorrelationBridgeEnabled(options) ? interceptor : null,
235
- },
236
- ];
@@ -1,4 +0,0 @@
1
- export * from './init-tracing';
2
- export * from './trace.service';
3
- export * from './trace.decorator';
4
- export * from './trace-context.interceptor';
@@ -1,92 +0,0 @@
1
- import type { Instrumentation } from '@opentelemetry/instrumentation';
2
- import { ConsoleSpanExporter } from '@opentelemetry/sdk-trace-base';
3
- import type { Sampler } from '@opentelemetry/sdk-trace-base';
4
- import {
5
- AlwaysOffSampler,
6
- AlwaysOnSampler,
7
- TraceIdRatioBasedSampler,
8
- } from '@opentelemetry/sdk-trace-base';
9
- import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
10
- import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';
11
- import { NodeSDK } from '@opentelemetry/sdk-node';
12
- import { resourceFromAttributes } from '@opentelemetry/resources';
13
- import type { TracingBootstrapOptions } from '../interface';
14
- import { registerShutdown } from './shutdown';
15
-
16
- export type { TracingBootstrapOptions };
17
-
18
- export { registerShutdown } from './shutdown';
19
-
20
- const chooseSampler = (ratio: number | undefined): Sampler => {
21
- if (ratio === undefined) return new AlwaysOnSampler();
22
- if (!Number.isFinite(ratio) || ratio < 0 || ratio > 1) {
23
- throw new Error(`samplingRatio must be a finite number in [0, 1], received ${ratio}`);
24
- }
25
- if (ratio === 0) return new AlwaysOffSampler();
26
- if (ratio === 1) return new AlwaysOnSampler();
27
- return new TraceIdRatioBasedSampler(ratio);
28
- };
29
-
30
- const chooseTraceExporter = (
31
- opts: TracingBootstrapOptions,
32
- ): ConsoleSpanExporter | OTLPTraceExporter | undefined => {
33
- const exporter = opts.exporter ?? 'otlp';
34
- switch (exporter) {
35
- case 'console':
36
- return new ConsoleSpanExporter();
37
- case 'otlp':
38
- return new OTLPTraceExporter({ url: opts.otlpUrl });
39
- case 'none':
40
- return undefined;
41
- default: {
42
- const exhaustive: never = exporter;
43
- throw new Error(`unknown exporter ${String(exhaustive)}`);
44
- }
45
- }
46
- };
47
-
48
- const buildInstrumentations = (opts: TracingBootstrapOptions): unknown[] => {
49
- if (opts.instrumentations !== undefined) return opts.instrumentations;
50
- return getNodeAutoInstrumentations();
51
- };
52
-
53
- /**
54
- * Default SDK factory: builds a configured OpenTelemetry {@link NodeSDK} from the
55
- * supplied bootstrap options. Exposed so consumers (and tests) can swap it out via
56
- * {@link initTracing}'s optional `sdkFactory` argument.
57
- */
58
- export function buildNodeSdk(opts: TracingBootstrapOptions): NodeSDK {
59
- const resource = resourceFromAttributes({ 'service.name': opts.serviceName });
60
- return new NodeSDK({
61
- resource,
62
- sampler: chooseSampler(opts.samplingRatio),
63
- traceExporter: chooseTraceExporter(opts),
64
- instrumentations: buildInstrumentations(opts) as Instrumentation[],
65
- });
66
- }
67
-
68
- type SdkLike = Pick<NodeSDK, 'start' | 'shutdown'>;
69
-
70
- let started = false;
71
-
72
- /**
73
- * Starts the OpenTelemetry NodeSDK. MUST be called as the very first statements of
74
- * `main.ts`, before any `@nestjs/*` or `AppModule` import, so auto-instrumentation can
75
- * patch modules at require time. Idempotent (a second call is a no-op) and best-effort
76
- * (exporter/start failures are warn-logged, never thrown) — app boot always proceeds.
77
- */
78
- export function initTracing(
79
- opts: TracingBootstrapOptions,
80
- sdkFactory: (options: TracingBootstrapOptions) => SdkLike = buildNodeSdk,
81
- ): void {
82
- if (started) return;
83
- try {
84
- const sdk: SdkLike = sdkFactory(opts);
85
- sdk.start();
86
- registerShutdown(() => sdk.shutdown());
87
- started = true;
88
- } catch (err) {
89
- const message = err instanceof Error ? err.message : String(err);
90
- process.stderr.write(`[nestjs-observability] WARN tracing init failed; continuing without tracing: ${message}\n`);
91
- }
92
- }
@@ -1,28 +0,0 @@
1
- /** Argument type for registerShutdown — async-safe best-effort shutdown hook. */
2
- export type ShutdownHandler = () => Promise<void> | void;
3
-
4
- /**
5
- * Registers a process-level shutdown handler that runs once on SIGTERM, SIGINT, or
6
- * `beforeExit`. Multiple handlers may be registered; all run, but each subscriber
7
- * is invoked at most once per process (de-duplicated against prior SIGTERM/SIGINT).
8
- *
9
- * Best-effort by design — handler errors are swallowed at the call site; do not
10
- * depend on successful flush from this entry point. Intended for OTel SDK flush
11
- * and other best-effort cleanup work that must not crash a process on exit.
12
- */
13
- export function registerShutdown(handler: ShutdownHandler): void {
14
- let invoked = false;
15
- const run = (): void => {
16
- if (invoked) return;
17
- invoked = true;
18
- Promise.resolve()
19
- .then(() => handler())
20
- .catch(() => {
21
- // intentional: best-effort shutdown, errors must not crash exit
22
- });
23
- };
24
-
25
- process.once('SIGTERM', run);
26
- process.once('SIGINT', run);
27
- process.once('beforeExit', run);
28
- }
@@ -1,42 +0,0 @@
1
- import {
2
- CallHandler,
3
- ExecutionContext,
4
- Injectable,
5
- NestInterceptor,
6
- } from '@nestjs/common';
7
- import { trace } from '@opentelemetry/api';
8
- import { RequestContextService } from '@nathapp/nestjs-logging';
9
- import { Observable } from 'rxjs';
10
- import { CORRELATION_ID_ATTRIBUTE } from '../constant/observability.constants';
11
-
12
- /**
13
- * Bidirectional bridge between the nestjs-logging correlation context and the active
14
- * OTel span: sets the request correlation id as a span attribute, and writes the active
15
- * trace_id/span_id back into the ALS store so downstream logs carry them. No-op when
16
- * there is no active context, no active span, or nestjs-logging is not wired.
17
- *
18
- * Best-effort by design: a failure inside this interceptor must never break the
19
- * request it observes.
20
- */
21
- @Injectable()
22
- export class TraceContextInterceptor implements NestInterceptor {
23
- constructor(private readonly requestContext: RequestContextService) {}
24
-
25
- intercept(_context: ExecutionContext, next: CallHandler): Observable<unknown> {
26
- try {
27
- const span = trace.getActiveSpan();
28
- if (span) {
29
- const correlationId = this.requestContext.get('requestId');
30
- if (correlationId) {
31
- span.setAttribute(CORRELATION_ID_ATTRIBUTE, correlationId);
32
- }
33
- const { traceId, spanId } = span.spanContext();
34
- this.requestContext.set('traceId', traceId);
35
- this.requestContext.set('spanId', spanId);
36
- }
37
- } catch {
38
- /* swallow — correlation bridging is best-effort */
39
- }
40
- return next.handle();
41
- }
42
- }
@@ -1,19 +0,0 @@
1
- import { SpanStatusCode } from '@opentelemetry/api';
2
- import type { Span } from '@opentelemetry/api';
3
-
4
- export function isPromiseLike(value: unknown): value is PromiseLike<unknown> {
5
- return (
6
- typeof value === 'object' &&
7
- value !== null &&
8
- typeof (value as { then?: unknown }).then === 'function'
9
- );
10
- }
11
-
12
- export function recordError(span: Span, err: unknown): void {
13
- const exception: string | Error = err instanceof Error ? err : String(err);
14
- span.recordException(exception);
15
- span.setStatus({
16
- code: SpanStatusCode.ERROR,
17
- message: err instanceof Error ? err.message : String(err),
18
- });
19
- }
@@ -1,63 +0,0 @@
1
- import { trace } from '@opentelemetry/api';
2
- import type { Span } from '@opentelemetry/api';
3
- import { isPromiseLike, recordError } from './trace-internal';
4
-
5
- /**
6
- * Method decorator that wraps the decorated method in an active OTel span named after
7
- * the class/method (or a supplied name).
8
- */
9
- export function Trace(spanName?: string): MethodDecorator {
10
- return (target, propertyKey, descriptor: PropertyDescriptor) => {
11
- const original = descriptor.value as (...args: unknown[]) => unknown;
12
- if (typeof original !== 'function') return descriptor;
13
-
14
- const resolvedName =
15
- spanName ??
16
- `${(target as { constructor?: { name?: string } }).constructor?.name ?? 'Anonymous'}.${String(propertyKey)}`;
17
-
18
- descriptor.value = function (this: unknown, ...args: unknown[]): unknown {
19
- const tracer = trace.getTracer('@nathapp/nestjs-observability');
20
- const ctx: { span: Span | null } = { span: null };
21
- let result: unknown;
22
- try {
23
- result = tracer.startActiveSpan(resolvedName, (span) => {
24
- ctx.span = span;
25
- return original.apply(this, args);
26
- });
27
- } catch (err) {
28
- if (ctx.span) {
29
- recordError(ctx.span, err);
30
- ctx.span.end();
31
- ctx.span = null;
32
- }
33
- throw err;
34
- }
35
-
36
- if (isPromiseLike(result)) {
37
- return result.then(
38
- (value) => {
39
- if (ctx.span) {
40
- ctx.span.end();
41
- ctx.span = null;
42
- }
43
- return value;
44
- },
45
- (err: unknown) => {
46
- if (ctx.span) {
47
- recordError(ctx.span, err);
48
- ctx.span.end();
49
- ctx.span = null;
50
- }
51
- throw err;
52
- },
53
- );
54
- }
55
-
56
- ctx.span?.end();
57
- ctx.span = null;
58
- return result;
59
- };
60
-
61
- return descriptor;
62
- };
63
- }
@@ -1,48 +0,0 @@
1
- import { Injectable } from '@nestjs/common';
2
- import { trace } from '@opentelemetry/api';
3
- import type { Tracer } from '@opentelemetry/api';
4
- import { isPromiseLike, recordError } from './trace-internal';
5
-
6
- /**
7
- * Thin wrapper over the OTel tracer for manual spans. Wraps work in an active span,
8
- * always ends the span in a finally, and records exceptions before rethrowing.
9
- */
10
- @Injectable()
11
- export class TraceService {
12
- private readonly tracer: Tracer;
13
-
14
- constructor() {
15
- this.tracer = trace.getTracer('@nathapp/nestjs-observability');
16
- }
17
-
18
- startActiveSpan<T>(name: string, fn: () => Promise<T> | T): Promise<T> {
19
- return new Promise<T>((resolve, reject) => {
20
- this.tracer.startActiveSpan(name, (span) => {
21
- try {
22
- const result = fn();
23
- if (isPromiseLike(result)) {
24
- result.then(
25
- (value) => {
26
- span.end();
27
- resolve(value);
28
- },
29
- (err: unknown) => {
30
- recordError(span, err);
31
- span.end();
32
- reject(err);
33
- },
34
- );
35
- } else {
36
- span.end();
37
- resolve(result);
38
- }
39
- } catch (err) {
40
- recordError(span, err);
41
- span.end();
42
- reject(err);
43
- }
44
- return undefined;
45
- });
46
- });
47
- }
48
- }
@@ -1,27 +0,0 @@
1
- {
2
- "moduleFileExtensions": ["js", "json", "ts", "d.ts"],
3
- "rootDir": "../",
4
- "testEnvironment": "node",
5
- "testMatch": ["**/.nax/**/*.test.ts"],
6
- "transform": {
7
- "^.+\\.(t)s$": [
8
- "ts-jest",
9
- {
10
- "diagnostics": true,
11
- "tsconfig": {
12
- "esModuleInterop": true,
13
- "emitDecoratorMetadata": true,
14
- "experimentalDecorators": true
15
- }
16
- }
17
- ]
18
- },
19
- "collectCoverageFrom": [
20
- "lib/**/*.ts",
21
- "!lib/**/*.spec.ts",
22
- "!lib/**/*.d.ts",
23
- "!**/node_modules/**"
24
- ],
25
- "forceExit": true,
26
- "maxWorkers": 1
27
- }
@@ -1,28 +0,0 @@
1
- {
2
- "moduleFileExtensions": [
3
- "js",
4
- "json",
5
- "ts",
6
- "d.ts"
7
- ],
8
- "rootDir": "../",
9
- "testEnvironment": "node",
10
- "testRegex": ".spec.ts$",
11
- "transform": {
12
- "^.+\\.(t)s$": [
13
- "ts-jest",
14
- {
15
- "diagnostics": true
16
- }
17
- ]
18
- },
19
- "collectCoverageFrom": [
20
- "lib/**/*.ts",
21
- "!lib/**/*.spec.ts",
22
- "!lib/**/*.d.ts",
23
- "!lib/**/index.ts",
24
- "!lib/**/*.interface.ts",
25
- "!**/node_modules/**"
26
- ],
27
- "coverageProvider": "v8"
28
- }