@vtvlive/interactive-apm 0.0.9 → 0.0.11

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/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- export { TracingModule, TracingModuleOptions, TracingModuleAsyncOptions, } from "./modules/tracing.module";
2
1
  export { TracingService } from "./services/tracing.service";
3
2
  export { TracingHelper } from "./utils/tracing.helper";
4
3
  export { ITracingProvider } from "./interfaces/tracing-provider.interface";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,yBAAyB,GAC1B,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAG5D,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAG3E,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EACL,KAAK,EACL,OAAO,EACP,WAAW,EACX,UAAU,EACV,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,aAAa,EACb,cAAc,EACd,aAAa,EACb,KAAK,iBAAiB,EACtB,KAAK,eAAe,GACrB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,yBAAyB,EAAE,MAAM,0CAA0C,CAAC;AACrF,OAAO,EAAE,4BAA4B,EAAE,MAAM,4CAA4C,CAAC;AAG1F,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,sCAAsC,CAAC;AAG9C,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,2BAA2B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAG5D,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAG3E,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EACL,KAAK,EACL,OAAO,EACP,WAAW,EACX,UAAU,EACV,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,aAAa,EACb,cAAc,EACd,aAAa,EACb,KAAK,iBAAiB,EACtB,KAAK,eAAe,GACrB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,yBAAyB,EAAE,MAAM,0CAA0C,CAAC;AACrF,OAAO,EAAE,4BAA4B,EAAE,MAAM,4CAA4C,CAAC;AAG1F,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,sCAAsC,CAAC;AAG9C,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,2BAA2B,CAAC"}
package/dist/index.js CHANGED
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
+ // Core exports — no NestJS dependency required
3
+ // For NestJS module integration, use: import { TracingModule } from '@vtvlive/interactive-apm/nestjs'
2
4
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.shouldUseOpenTelemetry = exports.initOpenTelemetry = exports.shouldUseElasticApm = exports.getElasticApmAgent = exports.isElasticApmStarted = exports.initElasticApm = exports.TRACING_PROVIDER_TOKEN = exports.TracingProviderFactory = exports.createTracingProvider = exports.OpenTelemetryTracingProvider = exports.ElasticApmTracingProvider = exports.OtlpTransport = exports.SpanKind = exports.ApmProvider = exports.TracingHelper = exports.TracingService = exports.TracingModule = void 0;
4
- // Core exports - NestJS integration
5
- var tracing_module_1 = require("./modules/tracing.module");
6
- Object.defineProperty(exports, "TracingModule", { enumerable: true, get: function () { return tracing_module_1.TracingModule; } });
5
+ exports.shouldUseOpenTelemetry = exports.initOpenTelemetry = exports.shouldUseElasticApm = exports.getElasticApmAgent = exports.isElasticApmStarted = exports.initElasticApm = exports.TRACING_PROVIDER_TOKEN = exports.TracingProviderFactory = exports.createTracingProvider = exports.OpenTelemetryTracingProvider = exports.ElasticApmTracingProvider = exports.OtlpTransport = exports.SpanKind = exports.ApmProvider = exports.TracingHelper = exports.TracingService = void 0;
7
6
  // Services
8
7
  var tracing_service_1 = require("./services/tracing.service");
9
8
  Object.defineProperty(exports, "TracingService", { enumerable: true, get: function () { return tracing_service_1.TracingService; } });
@@ -1 +1 @@
1
- {"version":3,"file":"elastic-apm-init.d.ts","sourceRoot":"","sources":["../../src/init/elastic-apm-init.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAMH,MAAM,WAAW,qBAAqB;IACpC,2BAA2B;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sCAAsC;IACtC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sBAAsB;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,6BAA6B;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oBAAoB;IACpB,QAAQ,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,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AAE,GAAG,IAAI,CAAC;IACrE,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG;QAAE,GAAG,IAAI,IAAI,CAAA;KAAE,GAAG,IAAI,CAAC;IAC9D,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACjC,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACvC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB,GAAG,IAAI,CAWP"}
@@ -23,6 +23,7 @@ exports.getElasticApmAgent = getElasticApmAgent;
23
23
  const apm_provider_type_1 = require("../types/apm-provider.type");
24
24
  const debug_logger_1 = require("../utils/debug-logger");
25
25
  const elastic_apm_compat_1 = require("../utils/elastic-apm-compat");
26
+ const check_packages_1 = require("../utils/check-packages");
26
27
  /**
27
28
  * Check if APM should use Elastic APM provider based on configuration
28
29
  * @returns true if Elastic APM should be used
@@ -38,6 +39,8 @@ function shouldUseElasticApm() {
38
39
  * @returns The APM agent instance
39
40
  */
40
41
  function initElasticApm(options = {}) {
42
+ // Fail fast with a clear message if elastic-apm-node is not installed.
43
+ (0, check_packages_1.checkElasticApmPackages)();
41
44
  // @ts-ignore - Optional peer dependency
42
45
  const apm = require("elastic-apm-node");
43
46
  // If already started, return the instance
@@ -1 +1 @@
1
- {"version":3,"file":"opentelemetry-init.d.ts","sourceRoot":"","sources":["../../src/init/opentelemetry-init.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAgD7D,MAAM,WAAW,wBAAwB;IACvC,2BAA2B;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wBAAwB;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,sCAAsC;IACtC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mEAAmE;IACnE,aAAa,CAAC,EAAE,MAAM,CAAC;IACv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ACxB,6BAA6B;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4CAA4C;IAC5C,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,kCAAkC;IAClC,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,qCAAqC;IACrC,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC,8DAA8D;IAC9D,aAAa,CAAC,EAAE,aAAa,GAAG,MAAM,CAAC;CACxC;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,IAAI,OAAO,CAGhD;AAwCD;;;;;GAKG;AACH,wBAAsB,iBAAiB,CAAC,OAAO,GAAE,wBAA6B,GAAG,OAAO,CAAC;IACvF,KAAK,IAAI,IAAI,CAAC;IACd,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,KAAK,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACzB,CAAC,CAuND"}
@@ -55,13 +55,29 @@ const apm_provider_type_1 = require("../types/apm-provider.type");
55
55
  const otlp_transport_type_1 = require("../types/otlp-transport.type");
56
56
  const debug_logger_1 = require("../utils/debug-logger");
57
57
  const debug_exporter_wrapper_1 = require("../utils/debug-exporter-wrapper");
58
- // @ts-ignore - Optional peer dependency
59
- const api_1 = require("@opentelemetry/api");
58
+ const check_packages_1 = require("../utils/check-packages");
60
59
  /**
61
60
  * Transaction Name Processor for OpenTelemetry
62
61
  * Sets transaction names to format: "GET /api/healthcheck/ping"
63
62
  */
64
63
  class TransactionNameProcessor {
64
+ constructor() {
65
+ this.cachedSpanKindServer = null;
66
+ }
67
+ getSpanKindServer() {
68
+ if (this.cachedSpanKindServer === null) {
69
+ try {
70
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
71
+ const { SpanKind } = require("@opentelemetry/api");
72
+ this.cachedSpanKindServer = SpanKind.SERVER;
73
+ }
74
+ catch {
75
+ // @opentelemetry/api not available
76
+ return null;
77
+ }
78
+ }
79
+ return this.cachedSpanKindServer;
80
+ }
65
81
  onStart(_span) {
66
82
  // No-op - moved to onEnd to read final http.route
67
83
  }
@@ -73,8 +89,9 @@ class TransactionNameProcessor {
73
89
  }
74
90
  onEnd(_span) {
75
91
  const span = _span;
76
- // Only process root spans (SERVER spans without parent)
77
- if (span.parent || span.kind !== api_1.SpanKind.SERVER) {
92
+ const serverKind = this.getSpanKindServer();
93
+ // Only process root SERVER spans without parent
94
+ if (serverKind === null || span.parent || span.kind !== serverKind) {
78
95
  return;
79
96
  }
80
97
  // Get HTTP attributes (http.route is often set after routing completes)
@@ -135,16 +152,22 @@ function normalizeEndpoint(endpoint, isGrpc) {
135
152
  * @returns The NodeSDK instance
136
153
  */
137
154
  async function initOpenTelemetry(options = {}) {
155
+ // Determine transport early so the package check validates the right exporter.
156
+ const rawTransport = (options.otlpTransport ||
157
+ process.env.ELASTIC_OTLP_TRANSPORT ||
158
+ otlp_transport_type_1.OtlpTransport.HTTP).toLowerCase();
159
+ // Fail fast with a clear message if required packages are not installed.
160
+ (0, check_packages_1.checkOpenTelemetryPackages)(rawTransport);
138
161
  // @ts-ignore - Optional peer dependency
139
- const { NodeSDK } = await Promise.resolve().then(() => __importStar(require("@opentelemetry/sdk-node")));
162
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
163
+ const { NodeSDK } = (await Promise.resolve().then(() => __importStar(require("@opentelemetry/sdk-node"))));
140
164
  // @ts-ignore - Optional peer dependency
141
- const { resourceFromAttributes } = await Promise.resolve().then(() => __importStar(require("@opentelemetry/resources")));
165
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
166
+ const { resourceFromAttributes } = (await Promise.resolve().then(() => __importStar(require("@opentelemetry/resources"))));
142
167
  const serviceName = options.serviceName || process.env.ELASTIC_APM_SERVICE_NAME || "interactive-backend";
143
168
  const environment = options.environment || process.env.ELASTIC_APM_ENVIRONMENT || "development";
144
169
  // Determine transport type (HTTP, gRPC, or PROTO)
145
- const transportType = (options.otlpTransport ||
146
- process.env.ELASTIC_OTLP_TRANSPORT ||
147
- otlp_transport_type_1.OtlpTransport.HTTP).toLowerCase();
170
+ const transportType = rawTransport;
148
171
  const isGrpc = transportType === otlp_transport_type_1.OtlpTransport.GRPC || transportType === "grpc";
149
172
  const isProto = transportType === otlp_transport_type_1.OtlpTransport.PROTO || transportType === "proto";
150
173
  // Get endpoint from config or env (same endpoint for both transports)
@@ -236,16 +259,16 @@ async function initOpenTelemetry(options = {}) {
236
259
  const { ExpressInstrumentation } = await Promise.resolve().then(() => __importStar(require("@opentelemetry/instrumentation-express")));
237
260
  instrumentations.push(new ExpressInstrumentation());
238
261
  }
239
- console.log('[DEBUG] About to load Redis instrumentation...');
262
+ console.log("[DEBUG] About to load Redis instrumentation...");
240
263
  try {
241
264
  const { IORedisInstrumentation } = await Promise.resolve().then(() => __importStar(require("@opentelemetry/instrumentation-ioredis")));
242
- console.log('[DEBUG] Redis import successful');
265
+ console.log("[DEBUG] Redis import successful");
243
266
  instrumentations.push(new IORedisInstrumentation());
244
- console.log('[DEBUG] Redis instrumentation added');
267
+ console.log("[DEBUG] Redis instrumentation added");
245
268
  (0, debug_logger_1.infoLog)("[OpenTelemetry] Redis instrumentation enabled");
246
269
  }
247
270
  catch (err) {
248
- console.error('[DEBUG] Redis instrumentation failed:', err);
271
+ console.error("[DEBUG] Redis instrumentation failed:", err);
249
272
  (0, debug_logger_1.infoLog)("[OpenTelemetry] Redis instrumentation not available");
250
273
  }
251
274
  // Resource attributes
@@ -1,4 +1,4 @@
1
- import { DynamicModule, Type, ForwardReference } from "@nestjs/common";
1
+ import type { DynamicModule, Type, ForwardReference } from "@nestjs/common";
2
2
  import { ApmProvider } from "../types/apm-provider.type";
3
3
  /**
4
4
  * Options for configuring TracingModule
@@ -1 +1 @@
1
- {"version":3,"file":"tracing.module.d.ts","sourceRoot":"","sources":["../../src/modules/tracing.module.ts"],"names":[],"mappings":"AAEA,OAAO,EAAkB,aAAa,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAMvF,OAAO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C,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;CAC7C"}
@@ -1,47 +1,6 @@
1
1
  "use strict";
2
- var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
3
- function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
4
- var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
5
- var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
6
- var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
7
- var _, done = false;
8
- for (var i = decorators.length - 1; i >= 0; i--) {
9
- var context = {};
10
- for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
11
- for (var p in contextIn.access) context.access[p] = contextIn.access[p];
12
- context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
13
- var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
14
- if (kind === "accessor") {
15
- if (result === void 0) continue;
16
- if (result === null || typeof result !== "object") throw new TypeError("Object expected");
17
- if (_ = accept(result.get)) descriptor.get = _;
18
- if (_ = accept(result.set)) descriptor.set = _;
19
- if (_ = accept(result.init)) initializers.unshift(_);
20
- }
21
- else if (_ = accept(result)) {
22
- if (kind === "field") initializers.unshift(_);
23
- else descriptor[key] = _;
24
- }
25
- }
26
- if (target) Object.defineProperty(target, contextIn.name, descriptor);
27
- done = true;
28
- };
29
- var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
30
- var useValue = arguments.length > 2;
31
- for (var i = 0; i < initializers.length; i++) {
32
- value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
33
- }
34
- return useValue ? value : void 0;
35
- };
36
- var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
37
- if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
38
- return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
39
- };
40
2
  Object.defineProperty(exports, "__esModule", { value: true });
41
3
  exports.TracingModule = void 0;
42
- // @ts-ignore - Optional peer dependency
43
- // @ts-ignore - Optional peer dependency
44
- const common_1 = require("@nestjs/common");
45
4
  const tracing_service_1 = require("../services/tracing.service");
46
5
  const tracing_provider_factory_1 = require("../factories/tracing-provider.factory");
47
6
  /**
@@ -89,75 +48,72 @@ const tracing_provider_factory_1 = require("../factories/tracing-provider.factor
89
48
  * }
90
49
  * }
91
50
  */
92
- let TracingModule = (() => {
93
- let _classDecorators = [(0, common_1.Global)(), (0, common_1.Module)({})];
94
- let _classDescriptor;
95
- let _classExtraInitializers = [];
96
- let _classThis;
97
- var TracingModule = _classThis = class {
98
- /**
99
- * Register module with synchronous options
100
- */
101
- static register(options = {}) {
102
- const tracingProvider = (0, tracing_provider_factory_1.createTracingProvider)(options);
103
- return {
104
- module: TracingModule,
105
- providers: [
106
- {
107
- provide: tracing_provider_factory_1.TRACING_PROVIDER_TOKEN,
108
- useValue: tracingProvider,
109
- },
110
- {
111
- provide: tracing_service_1.TracingService,
112
- useFactory: (provider) => new tracing_service_1.TracingService(provider),
113
- inject: [tracing_provider_factory_1.TRACING_PROVIDER_TOKEN],
114
- },
115
- ],
116
- exports: [tracing_service_1.TracingService],
117
- };
118
- }
119
- /**
120
- * Register module with asynchronous options (using ConfigService)
121
- */
122
- static registerAsync(options = {}) {
123
- return {
124
- module: TracingModule,
125
- imports: options.imports || [],
126
- providers: [
127
- {
128
- provide: tracing_provider_factory_1.TRACING_PROVIDER_TOKEN,
129
- useFactory: async (...args) => {
130
- const config = options.useFactory ? await options.useFactory(...args) : {};
131
- const provider = (0, tracing_provider_factory_1.createTracingProvider)(config);
132
- // Auto-initialize if configured
133
- if (config.autoInit !== false) {
134
- // Check if provider has initialize method (not in interface)
135
- if ("initialize" in provider && typeof provider.initialize === "function") {
136
- await provider.initialize();
137
- }
51
+ class TracingModule {
52
+ /**
53
+ * Register module with synchronous options
54
+ */
55
+ static register(options = {}) {
56
+ const tracingProvider = (0, tracing_provider_factory_1.createTracingProvider)(options);
57
+ return {
58
+ module: TracingModule,
59
+ providers: [
60
+ {
61
+ provide: tracing_provider_factory_1.TRACING_PROVIDER_TOKEN,
62
+ useValue: tracingProvider,
63
+ },
64
+ {
65
+ provide: tracing_service_1.TracingService,
66
+ useFactory: (provider) => new tracing_service_1.TracingService(provider),
67
+ inject: [tracing_provider_factory_1.TRACING_PROVIDER_TOKEN],
68
+ },
69
+ ],
70
+ exports: [tracing_service_1.TracingService],
71
+ };
72
+ }
73
+ /**
74
+ * Register module with asynchronous options (using ConfigService)
75
+ */
76
+ static registerAsync(options = {}) {
77
+ return {
78
+ module: TracingModule,
79
+ imports: options.imports || [],
80
+ providers: [
81
+ {
82
+ provide: tracing_provider_factory_1.TRACING_PROVIDER_TOKEN,
83
+ useFactory: async (...args) => {
84
+ const config = options.useFactory ? await options.useFactory(...args) : {};
85
+ const provider = (0, tracing_provider_factory_1.createTracingProvider)(config);
86
+ // Auto-initialize if configured
87
+ if (config.autoInit !== false) {
88
+ // Check if provider has initialize method (not in interface)
89
+ if ("initialize" in provider && typeof provider.initialize === "function") {
90
+ await provider.initialize();
138
91
  }
139
- return provider;
140
- },
141
- inject: options.inject || [],
142
- },
143
- {
144
- provide: tracing_service_1.TracingService,
145
- useFactory: (provider) => new tracing_service_1.TracingService(provider),
146
- inject: [tracing_provider_factory_1.TRACING_PROVIDER_TOKEN],
92
+ }
93
+ return provider;
147
94
  },
148
- ],
149
- exports: [tracing_service_1.TracingService],
150
- };
151
- }
152
- };
153
- __setFunctionName(_classThis, "TracingModule");
154
- (() => {
155
- const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
156
- __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
157
- TracingModule = _classThis = _classDescriptor.value;
158
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
159
- __runInitializers(_classThis, _classExtraInitializers);
160
- })();
161
- return TracingModule = _classThis;
162
- })();
95
+ inject: options.inject || [],
96
+ },
97
+ {
98
+ provide: tracing_service_1.TracingService,
99
+ useFactory: (provider) => new tracing_service_1.TracingService(provider),
100
+ inject: [tracing_provider_factory_1.TRACING_PROVIDER_TOKEN],
101
+ },
102
+ ],
103
+ exports: [tracing_service_1.TracingService],
104
+ };
105
+ }
106
+ }
163
107
  exports.TracingModule = TracingModule;
108
+ // Apply NestJS module decorators at runtime when @nestjs/common is available.
109
+ // Safe no-op when running without NestJS — TracingModule then works as a plain class
110
+ // with static register() / registerAsync() factory methods only.
111
+ try {
112
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
113
+ const { Module, Global } = require("@nestjs/common");
114
+ Module({})(TracingModule);
115
+ Global()(TracingModule);
116
+ }
117
+ catch {
118
+ // @nestjs/common not installed — decorators skipped
119
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * NestJS integration entry point.
3
+ *
4
+ * Use this path when integrating with NestJS. Requires `@nestjs/common` to be installed.
5
+ *
6
+ * @example
7
+ * // app.module.ts
8
+ * import { TracingModule } from '@vtvlive/interactive-apm/nestjs';
9
+ *
10
+ * @Module({
11
+ * imports: [
12
+ * TracingModule.register({ provider: 'opentelemetry', serviceName: 'my-service' }),
13
+ * ],
14
+ * })
15
+ * export class AppModule {}
16
+ *
17
+ * @example
18
+ * // In a service or controller
19
+ * import { TracingService } from '@vtvlive/interactive-apm/nestjs';
20
+ *
21
+ * constructor(private readonly tracing: TracingService) {}
22
+ */
23
+ export * from "./index";
24
+ export { TracingModule } from "./modules/tracing.module";
25
+ export type { TracingModuleOptions, TracingModuleAsyncOptions } from "./modules/tracing.module";
26
+ //# sourceMappingURL=nestjs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nestjs.d.ts","sourceRoot":"","sources":["../src/nestjs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,cAAc,SAAS,CAAC;AAGxB,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,YAAY,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC"}
package/dist/nestjs.js ADDED
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ /**
3
+ * NestJS integration entry point.
4
+ *
5
+ * Use this path when integrating with NestJS. Requires `@nestjs/common` to be installed.
6
+ *
7
+ * @example
8
+ * // app.module.ts
9
+ * import { TracingModule } from '@vtvlive/interactive-apm/nestjs';
10
+ *
11
+ * @Module({
12
+ * imports: [
13
+ * TracingModule.register({ provider: 'opentelemetry', serviceName: 'my-service' }),
14
+ * ],
15
+ * })
16
+ * export class AppModule {}
17
+ *
18
+ * @example
19
+ * // In a service or controller
20
+ * import { TracingService } from '@vtvlive/interactive-apm/nestjs';
21
+ *
22
+ * constructor(private readonly tracing: TracingService) {}
23
+ */
24
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
25
+ if (k2 === undefined) k2 = k;
26
+ var desc = Object.getOwnPropertyDescriptor(m, k);
27
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
28
+ desc = { enumerable: true, get: function() { return m[k]; } };
29
+ }
30
+ Object.defineProperty(o, k2, desc);
31
+ }) : (function(o, m, k, k2) {
32
+ if (k2 === undefined) k2 = k;
33
+ o[k2] = m[k];
34
+ }));
35
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
36
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.TracingModule = void 0;
40
+ // Re-export everything from the main (NestJS-free) entry point
41
+ __exportStar(require("./index"), exports);
42
+ // NestJS-specific exports — these require @nestjs/common to be installed
43
+ var tracing_module_1 = require("./modules/tracing.module");
44
+ Object.defineProperty(exports, "TracingModule", { enumerable: true, get: function () { return tracing_module_1.TracingModule; } });
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Upfront package availability checks.
3
+ *
4
+ * Each check function uses require.resolve() — which does NOT load the module,
5
+ * only verifies its path can be found — so it's safe to call before any actual
6
+ * imports happen. Throws an Error with install instructions when packages are
7
+ * missing.
8
+ */
9
+ /**
10
+ * Verify that the minimum set of OpenTelemetry packages are present.
11
+ * Throws with a clear install command when any required package is missing.
12
+ */
13
+ export declare function checkOpenTelemetryPackages(transportType?: string): void;
14
+ /**
15
+ * Verify that `elastic-apm-node` is present.
16
+ * Throws with a clear install command when the package is missing.
17
+ */
18
+ export declare function checkElasticApmPackages(): void;
19
+ //# sourceMappingURL=check-packages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-packages.d.ts","sourceRoot":"","sources":["../../src/utils/check-packages.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAWH;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAkDvE;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,IAAI,IAAI,CAW9C"}
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ /**
3
+ * Upfront package availability checks.
4
+ *
5
+ * Each check function uses require.resolve() — which does NOT load the module,
6
+ * only verifies its path can be found — so it's safe to call before any actual
7
+ * imports happen. Throws an Error with install instructions when packages are
8
+ * missing.
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.checkOpenTelemetryPackages = checkOpenTelemetryPackages;
12
+ exports.checkElasticApmPackages = checkElasticApmPackages;
13
+ function isPackageAvailable(pkg) {
14
+ try {
15
+ require.resolve(pkg);
16
+ return true;
17
+ }
18
+ catch {
19
+ return false;
20
+ }
21
+ }
22
+ /**
23
+ * Verify that the minimum set of OpenTelemetry packages are present.
24
+ * Throws with a clear install command when any required package is missing.
25
+ */
26
+ function checkOpenTelemetryPackages(transportType) {
27
+ const core = [
28
+ "@opentelemetry/api",
29
+ "@opentelemetry/sdk-node",
30
+ "@opentelemetry/resources",
31
+ "@opentelemetry/sdk-trace-base",
32
+ ];
33
+ const missing = core.filter(pkg => !isPackageAvailable(pkg));
34
+ // Validate that the exporter matching the chosen transport is present.
35
+ // We only require the one that will actually be used.
36
+ const transport = (transportType || "http").toLowerCase();
37
+ if (transport === "grpc") {
38
+ if (!isPackageAvailable("@opentelemetry/exporter-trace-otlp-grpc")) {
39
+ missing.push("@opentelemetry/exporter-trace-otlp-grpc");
40
+ }
41
+ }
42
+ else if (transport === "proto") {
43
+ if (!isPackageAvailable("@opentelemetry/exporter-trace-otlp-proto")) {
44
+ missing.push("@opentelemetry/exporter-trace-otlp-proto");
45
+ }
46
+ }
47
+ else {
48
+ // Default: HTTP
49
+ if (!isPackageAvailable("@opentelemetry/exporter-trace-otlp-http")) {
50
+ missing.push("@opentelemetry/exporter-trace-otlp-http");
51
+ }
52
+ }
53
+ if (missing.length === 0)
54
+ return;
55
+ const installCmd = "npm install " +
56
+ [
57
+ "@opentelemetry/api",
58
+ "@opentelemetry/sdk-node",
59
+ "@opentelemetry/resources",
60
+ "@opentelemetry/sdk-trace-base",
61
+ "@opentelemetry/exporter-trace-otlp-http",
62
+ ].join(" ");
63
+ throw new Error("Cannot initialize OpenTelemetry: the following required packages are not installed:\n" +
64
+ missing.map(p => ` - ${p}`).join("\n") +
65
+ "\n\n" +
66
+ "Run the following command to install them:\n" +
67
+ ` ${installCmd}\n` +
68
+ "\n" +
69
+ "For gRPC transport also add: @opentelemetry/exporter-trace-otlp-grpc\n" +
70
+ "For PROTO transport also add: @opentelemetry/exporter-trace-otlp-proto");
71
+ }
72
+ /**
73
+ * Verify that `elastic-apm-node` is present.
74
+ * Throws with a clear install command when the package is missing.
75
+ */
76
+ function checkElasticApmPackages() {
77
+ if (isPackageAvailable("elastic-apm-node"))
78
+ return;
79
+ throw new Error("Cannot initialize Elastic APM: the required package `elastic-apm-node` is not installed.\n\n" +
80
+ "Run the following command to install it:\n" +
81
+ " npm install elastic-apm-node\n" +
82
+ "\n" +
83
+ "Note: elastic-apm-node must be loaded before any other module — " +
84
+ "require/import it at the very top of your application entry point.");
85
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"tracing.helper.d.ts","sourceRoot":"","sources":["../../src/utils/tracing.helper.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,IAAI,EAA4C,MAAM,oBAAoB,CAAC;AACpG,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAwCtD;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAC,MAAM,CAAsC;IAC3D,OAAO,CAAC,MAAM,CAAC,WAAW,CAAoD;IAE9E;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW;IAO1B;;OAEG;IACH,MAAM,CAAC,kBAAkB,IAAI,IAAI;IAIjC;;;;;;OAMG;IACH,MAAM,CAAC,SAAS,CACd,IAAI,EAAE,MAAM,EACZ,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,EAC5C,QAAQ,GAAE,QAA4B,GACrC,IAAI;IAWP,OAAO,CAAC,MAAM,CAAC,yBAAyB;IAiBxC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,sBAAsB;IAiBrC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,mBAAmB;IAsFlC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,4BAA4B;IAqB3C;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAsBpC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,cAAc;IAe7B;;;;;;OAMG;WACU,mBAAmB,CAAC,CAAC,EAChC,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,CAA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ACH,OAAO,CAAC,MAAM,CAAC,sBAAsB;IAiBrC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,mBAAmB;IAwFlC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,4BAA4B;IAqB3C;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAsBpC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,cAAc;IAe7B;;;;;;OAMG;WACU,mBAAmB,CAAC,CAAC,EAChC,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,CAAC,IAAI,EAAE,IAAI,GAAG,SAAS,KAAK,OAAO,CAAC,CAAC,CAAC,EAC1C,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,GAC3C,OAAO,CAAC,CAAC,CAAC;IA2Cb;;;OAGG;IACH,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAsBvC;;;;OAIG;IACH,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAwB9D;;;OAGG;IACH,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI;IA2BjC;;;OAGG;IACH,MAAM,CAAC,aAAa,IAAI,IAAI,GAAG,SAAS;IAqBxC;;;OAGG;IACH,MAAM,CAAC,UAAU,IAAI,MAAM,GAAG,SAAS;CAqBxC"}
@@ -148,14 +148,16 @@ class TracingHelper {
148
148
  const span = apmSpan;
149
149
  // Add OpenTelemetry-compatible methods to elastic-apm span
150
150
  // This allows code using TracingHelper to work with both providers
151
- if (span && typeof apmSpan.setLabel === 'function') {
151
+ if (span && typeof apmSpan.setLabel === "function") {
152
152
  const originalSetLabel = apmSpan.setLabel.bind(apmSpan);
153
153
  // Add setAttribute method that maps to setLabel
154
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
154
155
  span.setAttribute = (key, value) => {
155
156
  originalSetLabel(key, String(value));
156
157
  return span; // Return span for chaining
157
158
  };
158
159
  // Add setAttributes method for batch setting
160
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
159
161
  span.setAttributes = (attrs) => {
160
162
  for (const [k, v] of Object.entries(attrs)) {
161
163
  originalSetLabel(k, String(v));
package/package.json CHANGED
@@ -1,10 +1,26 @@
1
1
  {
2
2
  "name": "@vtvlive/interactive-apm",
3
- "version": "0.0.9",
3
+ "version": "0.0.11",
4
4
  "description": "APM integration package supporting both Elastic APM and OpenTelemetry with NestJS integration",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
- "exports": "./dist/index.js",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "default": "./dist/index.js"
11
+ },
12
+ "./nestjs": {
13
+ "types": "./dist/nestjs.d.ts",
14
+ "default": "./dist/nestjs.js"
15
+ }
16
+ },
17
+ "typesVersions": {
18
+ "*": {
19
+ "nestjs": [
20
+ "dist/nestjs.d.ts"
21
+ ]
22
+ }
23
+ },
8
24
  "keywords": [
9
25
  "apm",
10
26
  "elastic-apm",
@@ -136,4 +152,4 @@
136
152
  "files": [
137
153
  "dist"
138
154
  ]
139
- }
155
+ }