@nathapp/nestjs-observability 4.0.0 → 4.0.1

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 (36) hide show
  1. package/package.json +6 -6
  2. package/.eslintrc.js +0 -8
  3. package/.nax/features/nestjs-observability/.nax-acceptance.test.ts +0 -797
  4. package/.turbo/turbo-build.log +0 -4
  5. package/CHANGELOG.md +0 -43
  6. package/lib/constant/index.ts +0 -1
  7. package/lib/constant/observability.constants.ts +0 -21
  8. package/lib/index.ts +0 -17
  9. package/lib/interface/index.ts +0 -2
  10. package/lib/interface/observability-module-options.interface.ts +0 -47
  11. package/lib/interface/tracing-bootstrap-options.interface.ts +0 -17
  12. package/lib/metrics/http-metrics.interceptor.ts +0 -174
  13. package/lib/metrics/index.ts +0 -7
  14. package/lib/metrics/metrics.providers.ts +0 -134
  15. package/lib/module/index.ts +0 -1
  16. package/lib/module/observability.module.ts +0 -236
  17. package/lib/tracing/index.ts +0 -4
  18. package/lib/tracing/init-tracing.ts +0 -92
  19. package/lib/tracing/shutdown.ts +0 -28
  20. package/lib/tracing/trace-context.interceptor.ts +0 -42
  21. package/lib/tracing/trace-internal.ts +0 -19
  22. package/lib/tracing/trace.decorator.ts +0 -63
  23. package/lib/tracing/trace.service.ts +0 -48
  24. package/test/jest-nax.json +0 -27
  25. package/test/jest-test.json +0 -28
  26. package/test/metrics/http-metrics.interceptor.spec.ts +0 -453
  27. package/test/metrics/metrics.providers.spec.ts +0 -97
  28. package/test/module/observability.module.spec.ts +0 -229
  29. package/test/tracing/build-node-sdk.spec.ts +0 -224
  30. package/test/tracing/init-tracing.idempotency.spec.ts +0 -64
  31. package/test/tracing/init-tracing.shutdown.spec.ts +0 -88
  32. package/test/tracing/shutdown.spec.ts +0 -109
  33. package/test/tracing/trace-context.interceptor.spec.ts +0 -221
  34. package/test/tracing/trace.decorator.spec.ts +0 -153
  35. package/test/tracing/trace.service.spec.ts +0 -205
  36. package/tsconfig.json +0 -9
@@ -1,4 +0,0 @@
1
-
2
- > @nathapp/nestjs-observability@4.0.0 build
3
- > rimraf dist && tsc -p tsconfig.json
4
-
package/CHANGELOG.md DELETED
@@ -1,43 +0,0 @@
1
- # @nathapp/nestjs-observability
2
-
3
- ## 4.0.0
4
-
5
- ### Major Changes
6
-
7
- - 2319e9d: BREAKING: drop NestJS 8/9 peer ranges and require Node ^20.19.0 || >=22.12.0. Support NestJS 12. Peer ranges now cover NestJS 10, 11 and 12 (Node ^20.19.0 || >=22.12.0 is required because NestJS 12 is ESM-only). The configurable module builder no longer deep-imports a directory that is unresolvable on NestJS 12, and TwoFactorGuard / TwoFactorForceGuard redeclare their constructor DI metadata because NestJS 12 no longer inherits @Optional() from base classes.
8
-
9
- Other consumer-facing changes:
10
-
11
- - `@nathapp/nestjs-health`: `@nestjs/terminus` moved from `dependencies` to `peerDependencies` (`^11.0.0 || ^12.0.0`) so NestJS 12 apps can use terminus 12. Install `@nestjs/terminus` in your app.
12
- - Optional-package loading (`loadPackage`) now throws a descriptive `Error` (original error on `cause`) instead of logging and calling `process.exit(1)` when an optional package is missing.
13
-
14
- ## 4.0.0-rc.0
15
-
16
- ### Major Changes
17
-
18
- - c3aeb46: BREAKING: drop NestJS 8/9 peer ranges and require Node ^20.19.0 || >=22.12.0. Support NestJS 12. Peer ranges now cover NestJS 10, 11 and 12 (Node ^20.19.0 || >=22.12.0 is required because NestJS 12 is ESM-only). The configurable module builder no longer deep-imports a directory that is unresolvable on NestJS 12, and TwoFactorGuard / TwoFactorForceGuard redeclare their constructor DI metadata because NestJS 12 no longer inherits @Optional() from base classes.
19
-
20
- Other consumer-facing changes:
21
-
22
- - `@nathapp/nestjs-health`: `@nestjs/terminus` moved from `dependencies` to `peerDependencies` (`^11.0.0 || ^12.0.0`) so NestJS 12 apps can use terminus 12. Install `@nestjs/terminus` in your app.
23
- - Optional-package loading (`loadPackage`) now throws a descriptive `Error` (original error on `cause`) instead of logging and calling `process.exit(1)` when an optional package is missing.
24
-
25
- ### Patch Changes
26
-
27
- - Updated dependencies [c3aeb46]
28
- - @nathapp/nestjs-common@4.0.0-rc.0
29
- - @nathapp/nestjs-logging@4.0.0-rc.0
30
-
31
- ## 3.3.0
32
-
33
- ### Minor Changes
34
-
35
- - a27440f: 3.3.0 milestone release. The `@nathapp/nestjs-*` packages now version and publish in lockstep at a unified version.
36
-
37
- - **nestjs-csrf**: first public release — stateless double-submit-cookie CSRF guard (zero-dep HMAC, Express + Fastify, Bearer coexist skip, `@SkipCsrf()`, auto-binds `APP_GUARD`).
38
- - **nestjs-health**: first public release — terminus aggregator over cache/prisma/queue with k8s liveness/readiness probes via a dynamic controller factory.
39
- - **nestjs-idempotency**: first public release — `@Idempotent()` interceptor (zero-dep sha256 fingerprint, Express + Fastify, 409-in-flight, 2xx replay, fingerprint mismatch 422, fail-closed on store error).
40
- - **nestjs-observability**: first public release — Prometheus RED metrics + OpenTelemetry tracing joined to the logging ALS; `initTracing()` pre-bootstrap hook.
41
- - **nestjs-outbox**: first public release — transactional outbox relay (at-least-once via `ITransactionManager`, lease-claim + backoff, dead-letter).
42
- - **nestjs-storage**: migrated from aws-sdk v2 to v3 (zero runtime dep via `import type` + lazy `loadPackage`); NFSStorage stub replaced with an S3-style HTTP file-service client.
43
- - **nestjs-cache**: `delByPattern` now routes through Redis SCAN instead of an O(n) key sweep, with glob-detection and multi-tier iterator support.
@@ -1 +0,0 @@
1
- export * from './observability.constants';
@@ -1,21 +0,0 @@
1
- /** Options token consumed by ObservabilityModule (ConfigurableModuleClass). */
2
- export const OBSERVABILITY_MODULE_OPTIONS = 'OBSERVABILITY_MODULE_OPTIONS';
3
-
4
- /** OTel span attribute key used to carry the request correlation id onto spans. */
5
- export const CORRELATION_ID_ATTRIBUTE = 'app.correlation_id';
6
-
7
- /** Default Prometheus scrape path when metrics.path is not supplied. */
8
- export const DEFAULT_METRICS_PATH = '/metrics';
9
-
10
- /** Names of the built-in RED HTTP metrics. */
11
- export const HTTP_REQUESTS_TOTAL = 'http_requests_total';
12
- export const HTTP_REQUEST_ERRORS_TOTAL = 'http_request_errors_total';
13
- export const HTTP_REQUEST_DURATION_SECONDS = 'http_request_duration_seconds';
14
-
15
- /**
16
- * Default duration histogram buckets (seconds) when metrics.buckets is not supplied.
17
- * Standard latency ladder from 5ms to 10s.
18
- */
19
- export const DEFAULT_DURATION_BUCKETS = [
20
- 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10,
21
- ];
package/lib/index.ts DELETED
@@ -1,17 +0,0 @@
1
- export * from './constant';
2
- export * from './interface';
3
- export * from './metrics';
4
- export * from './tracing';
5
- export * from './module';
6
-
7
- /**
8
- * Re-exported from @willsoto/nestjs-prometheus so consumers register custom metrics
9
- * without taking a direct dependency on it.
10
- */
11
- export {
12
- makeCounterProvider,
13
- makeGaugeProvider,
14
- makeHistogramProvider,
15
- makeSummaryProvider,
16
- InjectMetric,
17
- } from '@willsoto/nestjs-prometheus';
@@ -1,2 +0,0 @@
1
- export * from './observability-module-options.interface';
2
- export * from './tracing-bootstrap-options.interface';
@@ -1,47 +0,0 @@
1
- import type { ModuleMetadata, Type } from '@nestjs/common';
2
-
3
- /** Metrics (Prometheus) options. Omit fields to accept the defaults. */
4
- export interface MetricsOptions {
5
- /** Enable the RED HTTP interceptor and the /metrics endpoint. Default true. */
6
- enabled?: boolean;
7
- /** Collect default Node/process metrics (prom-client). Default true. */
8
- defaultMetrics?: boolean;
9
- /** Prometheus scrape path. Default '/metrics'. */
10
- path?: string;
11
- /** Prefix applied to all metric names. Default '' (no prefix). */
12
- prefix?: string;
13
- /** Duration histogram buckets in seconds. Default DEFAULT_DURATION_BUCKETS. */
14
- buckets?: number[];
15
- /** Routes excluded from RED metrics (e.g. ['/metrics', '/health']). */
16
- ignoreRoutes?: string[];
17
- }
18
-
19
- /** In-app tracing options (helpers + ALS bridge). The SDK itself is started by initTracing(). */
20
- export interface TracingOptions {
21
- /** Enable the trace-context interceptor and TraceService. Default true. */
22
- enabled?: boolean;
23
- /** Bridge the correlation id <-> active span both ways. Default true. */
24
- correlationBridge?: boolean;
25
- }
26
-
27
- /** Override options for ObservabilityModule. */
28
- export interface ObservabilityModuleOptions {
29
- metrics?: MetricsOptions;
30
- tracing?: TracingOptions;
31
- }
32
-
33
- /** Factory contract for the `useClass`/`useExisting` async path; method name matches the
34
- * in-repo ConfigurableModuleBuilder default ('createOptions'). */
35
- export interface ObservabilityModuleOptionsFactory {
36
- createOptions(): Promise<ObservabilityModuleOptions> | ObservabilityModuleOptions;
37
- }
38
-
39
- /** Async registration options for ObservabilityModule. */
40
- export interface ObservabilityAsyncModuleOptions extends Pick<ModuleMetadata, 'imports'> {
41
- useExisting?: Type<ObservabilityModuleOptionsFactory>;
42
- useClass?: Type<ObservabilityModuleOptionsFactory>;
43
- useFactory?: (
44
- ...args: any[]
45
- ) => Promise<ObservabilityModuleOptions> | ObservabilityModuleOptions;
46
- inject?: any[];
47
- }
@@ -1,17 +0,0 @@
1
- /** Options for initTracing() — the pre-bootstrap OpenTelemetry NodeSDK setup. */
2
- export interface TracingBootstrapOptions {
3
- /** Logical service name reported on every span (OTel resource service.name). */
4
- serviceName: string;
5
- /** Span exporter. 'otlp' -> OTLP/HTTP, 'console' -> dev stdout, 'none' -> no export. Default 'otlp'. */
6
- exporter?: 'otlp' | 'console' | 'none';
7
- /** OTLP/HTTP endpoint used when exporter === 'otlp'. */
8
- otlpUrl?: string;
9
- /** Head sampling ratio in [0, 1]. Default 1.0 (sample everything). */
10
- samplingRatio?: number;
11
- /**
12
- * Advanced: override the auto-instrumentation set. When omitted, the full
13
- * `@opentelemetry/auto-instrumentations-node` default set is enabled (HTTP,
14
- * express/fastify, and every other supported library instrumentation).
15
- */
16
- instrumentations?: unknown[];
17
- }
@@ -1,174 +0,0 @@
1
- import {
2
- CallHandler,
3
- ExecutionContext,
4
- HttpException,
5
- Inject,
6
- Injectable,
7
- NestInterceptor,
8
- Optional,
9
- } from '@nestjs/common';
10
- import { Observable } from 'rxjs';
11
- import { catchError, tap } from 'rxjs/operators';
12
- import {
13
- PROM_METRIC_HTTP_REQUEST_DURATION_SECONDS,
14
- PROM_METRIC_HTTP_REQUEST_ERRORS_TOTAL,
15
- PROM_METRIC_HTTP_REQUESTS_TOTAL,
16
- } from './metrics.providers';
17
-
18
- interface HttpMetric {
19
- inc?: (labels: Record<string, string>) => void;
20
- observe?: (labels: Record<string, string>, value: number) => void;
21
- }
22
-
23
- interface RequestLike {
24
- method?: string;
25
- url?: string;
26
- route?: { path?: string };
27
- }
28
-
29
- interface ResponseLike {
30
- statusCode?: number;
31
- raw?: { statusCode?: number };
32
- }
33
-
34
- const safeExecute = (fn: () => void): void => {
35
- try {
36
- fn();
37
- } catch {
38
- /* swallow — metric recording is best-effort */
39
- }
40
- };
41
-
42
- const stripQuery = (url: string): string => {
43
- const qIndex = url.indexOf('?');
44
- return qIndex === -1 ? url : url.slice(0, qIndex);
45
- };
46
-
47
- const resolveRoute = (request: RequestLike | undefined): string => {
48
- const pattern = request?.route?.path;
49
- if (pattern) {
50
- return pattern;
51
- }
52
- const url = request?.url;
53
- if (url) {
54
- return stripQuery(url);
55
- }
56
- return 'UNKNOWN';
57
- };
58
-
59
- const resolveStatus = (context: ExecutionContext, fallback = 200): number => {
60
- try {
61
- const response = context.switchToHttp().getResponse?.() as
62
- | ResponseLike
63
- | undefined;
64
- if (response) {
65
- if (typeof response.statusCode === 'number') {
66
- return response.statusCode;
67
- }
68
- if (typeof response.raw?.statusCode === 'number') {
69
- return response.raw.statusCode;
70
- }
71
- }
72
- return fallback;
73
- } catch {
74
- return fallback;
75
- }
76
- };
77
-
78
- const statusFromError = (err: unknown): number =>
79
- err instanceof HttpException ? err.getStatus() : 500;
80
-
81
- /**
82
- * RED HTTP metrics interceptor: records request count, error count (status >= 500),
83
- * and a duration histogram labelled method/route/status. Recording is best-effort —
84
- * a metrics failure must never break the request. Routes listed in `ignoreRoutes`
85
- * are passed through without any metric being incremented.
86
- *
87
- * Route identity: the `route` label prefers `request.route.path` (the NestJS route
88
- * template, e.g. `/users/:id`) and falls back to `request.url` with the query
89
- * string stripped (e.g. `/users?id=42` → `/users`). This keeps label cardinality
90
- * bounded. As a consequence, `setIgnoreRoutes(['/users/:id'])` matches all concrete
91
- * URLs under that template — entry strings must be route patterns, not URLs.
92
- *
93
- * Instantiation:
94
- * - Direct: `new HttpMetricsInterceptor()`. Call `.setIgnoreRoutes([...])` to skip
95
- * metrics on specific routes.
96
- * - Via Nest DI: Nest resolves each prom-client metric instance under the
97
- * `PROM_METRIC_HTTP_REQUESTS_TOTAL`, `PROM_METRIC_HTTP_REQUEST_ERRORS_TOTAL`, and
98
- * `PROM_METRIC_HTTP_REQUEST_DURATION_SECONDS` tokens (all optional).
99
- *
100
- * Fastify compatibility: `resolveStatus` reads `response.statusCode`, falling back
101
- * to `response.raw.statusCode` for the Fastify adapter.
102
- */
103
- @Injectable()
104
- export class HttpMetricsInterceptor implements NestInterceptor {
105
- private ignoreRoutes: ReadonlySet<string> = new Set();
106
-
107
- constructor(
108
- @Optional() @Inject(PROM_METRIC_HTTP_REQUESTS_TOTAL)
109
- private readonly requests?: HttpMetric,
110
- @Optional() @Inject(PROM_METRIC_HTTP_REQUEST_ERRORS_TOTAL)
111
- private readonly errors?: HttpMetric,
112
- @Optional() @Inject(PROM_METRIC_HTTP_REQUEST_DURATION_SECONDS)
113
- private readonly duration?: HttpMetric,
114
- ) {}
115
-
116
- setIgnoreRoutes(routes: string[]): this {
117
- this.ignoreRoutes = new Set(routes);
118
- return this;
119
- }
120
-
121
- intercept(context: ExecutionContext, next: CallHandler): Observable<unknown> {
122
- if (context.getType() !== 'http') {
123
- // Non-HTTP contexts (rpc, ws, graphql, etc.) have no HTTP request/response
124
- // to inspect; skip HTTP metric recording instead of polluting metrics with
125
- // UNKNOWN method/route and a defaulted 200 status.
126
- return next.handle();
127
- }
128
-
129
- const request = context.switchToHttp().getRequest<RequestLike>();
130
- const method = request?.method ?? 'UNKNOWN';
131
- const route = resolveRoute(request);
132
- const startedAt = process.hrtime.bigint();
133
-
134
- if (this.ignoreRoutes.has(route)) {
135
- return next.handle();
136
- }
137
-
138
- const elapsedSeconds = (): number => {
139
- const ns = process.hrtime.bigint() - startedAt;
140
- return Number(ns) / 1_000_000_000;
141
- };
142
-
143
- const recordRequests = (status: string): void => {
144
- safeExecute(() => this.requests?.inc?.({ method, route, status }));
145
- };
146
-
147
- const recordDuration = (status: string): void => {
148
- safeExecute(() =>
149
- this.duration?.observe?.({ method, route, status }, elapsedSeconds()),
150
- );
151
- };
152
-
153
- const recordErrors = (status: string): void => {
154
- safeExecute(() => this.errors?.inc?.({ method, route, status }));
155
- };
156
-
157
- return next.handle().pipe(
158
- tap(() => {
159
- const status = String(resolveStatus(context));
160
- recordRequests(status);
161
- recordDuration(status);
162
- }),
163
- catchError((err: unknown) => {
164
- const status = String(statusFromError(err));
165
- recordRequests(status);
166
- recordDuration(status);
167
- if (Number(status) >= 500) {
168
- recordErrors(status);
169
- }
170
- throw err;
171
- }),
172
- );
173
- }
174
- }
@@ -1,7 +0,0 @@
1
- export { HttpMetricsInterceptor } from './http-metrics.interceptor';
2
- export {
3
- buildRedMetricProviders,
4
- PROM_METRIC_HTTP_REQUESTS_TOTAL,
5
- PROM_METRIC_HTTP_REQUEST_ERRORS_TOTAL,
6
- PROM_METRIC_HTTP_REQUEST_DURATION_SECONDS,
7
- } from './metrics.providers';
@@ -1,134 +0,0 @@
1
- import type { Provider } from '@nestjs/common';
2
- import { Counter, Histogram } from 'prom-client';
3
- import {
4
- DEFAULT_DURATION_BUCKETS,
5
- HTTP_REQUEST_DURATION_SECONDS,
6
- HTTP_REQUEST_ERRORS_TOTAL,
7
- HTTP_REQUESTS_TOTAL,
8
- OBSERVABILITY_MODULE_OPTIONS,
9
- } from '../constant';
10
- import type { ObservabilityModuleOptions } from '../interface';
11
-
12
- /** DI token under which HttpMetricsInterceptor looks up the requests counter. */
13
- export const PROM_METRIC_HTTP_REQUESTS_TOTAL = 'PROM_METRIC_HTTP_REQUESTS_TOTAL';
14
-
15
- /** DI token under which HttpMetricsInterceptor looks up the errors counter. */
16
- export const PROM_METRIC_HTTP_REQUEST_ERRORS_TOTAL =
17
- 'PROM_METRIC_HTTP_REQUEST_ERRORS_TOTAL';
18
-
19
- /** DI token under which HttpMetricsInterceptor looks up the duration histogram. */
20
- export const PROM_METRIC_HTTP_REQUEST_DURATION_SECONDS =
21
- 'PROM_METRIC_HTTP_REQUEST_DURATION_SECONDS';
22
-
23
- const METHOD_ROUTE_STATUS_LABELS = ['method', 'route', 'status'] as const;
24
-
25
- type RedMetrics = {
26
- requests: Counter<(typeof METHOD_ROUTE_STATUS_LABELS)[number]>;
27
- errors: Counter<(typeof METHOD_ROUTE_STATUS_LABELS)[number]>;
28
- duration: Histogram<(typeof METHOD_ROUTE_STATUS_LABELS)[number]>;
29
- };
30
-
31
- /**
32
- * Constructs the three RED prom-client instances (requests total, errors total,
33
- * duration histogram), honouring the configured prefix and histogram buckets. Shared
34
- * by both the sync (`register`) and async (`registerAsync`) provider builders below
35
- * so the metric names/help/labels are defined in exactly one place.
36
- */
37
- function createRedMetrics(prefix: string, buckets: number[]): RedMetrics {
38
- return {
39
- requests: new Counter({
40
- name: `${prefix}${HTTP_REQUESTS_TOTAL}`,
41
- help: 'Total number of HTTP requests handled, labelled by method/route/status.',
42
- labelNames: [...METHOD_ROUTE_STATUS_LABELS],
43
- }),
44
- errors: new Counter({
45
- name: `${prefix}${HTTP_REQUEST_ERRORS_TOTAL}`,
46
- help: 'Total number of HTTP requests that failed with status >= 500.',
47
- labelNames: [...METHOD_ROUTE_STATUS_LABELS],
48
- }),
49
- duration: new Histogram({
50
- name: `${prefix}${HTTP_REQUEST_DURATION_SECONDS}`,
51
- help: 'HTTP request duration in seconds, labelled by method/route/status.',
52
- labelNames: [...METHOD_ROUTE_STATUS_LABELS],
53
- buckets: [...buckets],
54
- }),
55
- };
56
- }
57
-
58
- /**
59
- * Builds the DI providers for the built-in RED metrics for the sync `register()` path,
60
- * where the prefix/buckets are already resolved.
61
- *
62
- * Each provider is bound under a `PROM_METRIC_<NAME>` token and exposes the live
63
- * prom-client Counter / Histogram instance (with `inc` / `observe` methods
64
- * respectively). HttpMetricsInterceptor looks them up via the same tokens.
65
- */
66
- export function buildRedMetricProviders(prefix: string, buckets: number[]): Provider[] {
67
- const metrics = createRedMetrics(prefix, buckets);
68
- return [
69
- { provide: PROM_METRIC_HTTP_REQUESTS_TOTAL, useValue: metrics.requests },
70
- { provide: PROM_METRIC_HTTP_REQUEST_ERRORS_TOTAL, useValue: metrics.errors },
71
- { provide: PROM_METRIC_HTTP_REQUEST_DURATION_SECONDS, useValue: metrics.duration },
72
- ];
73
- }
74
-
75
- const resolveOptionsPrefix = (options: ObservabilityModuleOptions | undefined): string =>
76
- options?.metrics?.prefix ?? '';
77
-
78
- const resolveOptionsBuckets = (options: ObservabilityModuleOptions | undefined): number[] =>
79
- options?.metrics?.buckets ?? DEFAULT_DURATION_BUCKETS;
80
-
81
- const isOptionsMetricsEnabled = (options: ObservabilityModuleOptions | undefined): boolean =>
82
- options?.metrics?.enabled !== false;
83
-
84
- /**
85
- * Builds the DI providers for the built-in RED metrics for the `registerAsync()` path,
86
- * where the prefix/buckets are only known once `OBSERVABILITY_MODULE_OPTIONS` resolves
87
- * at DI time. Each token constructs only its own metric — sharing a single
88
- * `createRedMetrics()` call across all three tokens would construct (and attempt to
89
- * register) every metric three times over, once per token's factory invocation. When
90
- * `metrics.enabled` resolves to `false`, each factory returns `undefined` instead of
91
- * registering a metric, mirroring the sync `register()` path skipping registration
92
- * entirely.
93
- */
94
- export function buildRedMetricProvidersFromOptionsToken(): Provider[] {
95
- return [
96
- {
97
- provide: PROM_METRIC_HTTP_REQUESTS_TOTAL,
98
- inject: [OBSERVABILITY_MODULE_OPTIONS],
99
- useFactory: (options: ObservabilityModuleOptions | undefined) =>
100
- isOptionsMetricsEnabled(options)
101
- ? new Counter({
102
- name: `${resolveOptionsPrefix(options)}${HTTP_REQUESTS_TOTAL}`,
103
- help: 'Total number of HTTP requests handled, labelled by method/route/status.',
104
- labelNames: [...METHOD_ROUTE_STATUS_LABELS],
105
- })
106
- : undefined,
107
- },
108
- {
109
- provide: PROM_METRIC_HTTP_REQUEST_ERRORS_TOTAL,
110
- inject: [OBSERVABILITY_MODULE_OPTIONS],
111
- useFactory: (options: ObservabilityModuleOptions | undefined) =>
112
- isOptionsMetricsEnabled(options)
113
- ? new Counter({
114
- name: `${resolveOptionsPrefix(options)}${HTTP_REQUEST_ERRORS_TOTAL}`,
115
- help: 'Total number of HTTP requests that failed with status >= 500.',
116
- labelNames: [...METHOD_ROUTE_STATUS_LABELS],
117
- })
118
- : undefined,
119
- },
120
- {
121
- provide: PROM_METRIC_HTTP_REQUEST_DURATION_SECONDS,
122
- inject: [OBSERVABILITY_MODULE_OPTIONS],
123
- useFactory: (options: ObservabilityModuleOptions | undefined) =>
124
- isOptionsMetricsEnabled(options)
125
- ? new Histogram({
126
- name: `${resolveOptionsPrefix(options)}${HTTP_REQUEST_DURATION_SECONDS}`,
127
- help: 'HTTP request duration in seconds, labelled by method/route/status.',
128
- labelNames: [...METHOD_ROUTE_STATUS_LABELS],
129
- buckets: resolveOptionsBuckets(options),
130
- })
131
- : undefined,
132
- },
133
- ];
134
- }
@@ -1 +0,0 @@
1
- export * from './observability.module';