@vtvlive/interactive-apm 0.0.4 → 0.0.6
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/init/elastic-apm-init.d.ts.map +1 -1
- package/dist/init/elastic-apm-init.js +3 -1
- package/dist/providers/elastic-apm.tracing-provider.d.ts.map +1 -1
- package/dist/providers/elastic-apm.tracing-provider.js +2 -1
- package/dist/types/apm-provider.type.d.ts +2 -0
- package/dist/types/apm-provider.type.d.ts.map +1 -1
- package/dist/types/apm.types.d.ts +3 -33
- package/dist/types/apm.types.d.ts.map +1 -1
- package/dist/types/apm.types.js +7 -29
- package/dist/types/otlp-transport.type.d.ts +2 -0
- package/dist/types/otlp-transport.type.d.ts.map +1 -1
- package/dist/utils/elastic-apm-compat.d.ts +80 -0
- package/dist/utils/elastic-apm-compat.d.ts.map +1 -0
- package/dist/utils/elastic-apm-compat.js +85 -0
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"elastic-apm-init.d.ts","sourceRoot":"","sources":["../../src/init/elastic-apm-init.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;
|
|
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,G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ApmAgent = getElasticApmAgent;
|
|
23
23
|
const apm_provider_type_1 = require("../types/apm-provider.type");
|
|
24
24
|
const debug_logger_1 = require("../utils/debug-logger");
|
|
25
|
+
const elastic_apm_compat_1 = require("../utils/elastic-apm-compat");
|
|
25
26
|
/**
|
|
26
27
|
* Check if APM should use Elastic APM provider based on configuration
|
|
27
28
|
* @returns true if Elastic APM should be used
|
|
@@ -67,7 +68,8 @@ function initElasticApm(options = {}) {
|
|
|
67
68
|
logLevel: options.logLevel || "error",
|
|
68
69
|
});
|
|
69
70
|
if ((0, debug_logger_1.isDebugEnabled)()) {
|
|
70
|
-
(0,
|
|
71
|
+
const env = (0, elastic_apm_compat_1.getServiceEnvironment)(agent);
|
|
72
|
+
(0, debug_logger_1.infoLog)(`[ElasticAPM] Service: ${agent.getServiceName()}, Environment: ${env}`);
|
|
71
73
|
(0, debug_logger_1.infoLog)("[ElasticAPM] Initialized");
|
|
72
74
|
}
|
|
73
75
|
return agent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"elastic-apm.tracing-provider.d.ts","sourceRoot":"","sources":["../../src/providers/elastic-apm.tracing-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAC5E,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"elastic-apm.tracing-provider.d.ts","sourceRoot":"","sources":["../../src/providers/elastic-apm.tracing-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAC5E,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAU3C;;GAEG;AACH,MAAM,WAAW,eAAgB,SAAQ,KAAK;IAC5C,8BAA8B;IAC9B,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAE3C,wBAAwB;IACxB,OAAO,CAAC,IAAI,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KAAK,EAAE,KAAK,GAAG,IAAI;IAMhC;;OAEG;IACH,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAOvD;;OAEG;IACH,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,GAAG,IAAI,GAAG,IAAI;IAOlC;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAgB/B;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAgBzB;;OAEG;IACH,OAAO,CAAC,mBAAmB;CAe5B"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ElasticApmTracingProvider = void 0;
|
|
4
4
|
const debug_logger_1 = require("../utils/debug-logger");
|
|
5
|
+
const elastic_apm_compat_1 = require("../utils/elastic-apm-compat");
|
|
5
6
|
/**
|
|
6
7
|
* Elastic APM Tracing Provider Implementation
|
|
7
8
|
* Sử dụng elastic-apm-node agent để gửi traces về Elastic APM server
|
|
@@ -76,7 +77,7 @@ class ElasticApmTracingProvider {
|
|
|
76
77
|
if (!transaction) {
|
|
77
78
|
const type = this.mapSpanKindToType(spanKind);
|
|
78
79
|
transaction = this.apm.startTransaction(name, type);
|
|
79
|
-
if (
|
|
80
|
+
if ((0, elastic_apm_compat_1.isTransactionNoOp)(transaction)) {
|
|
80
81
|
return null;
|
|
81
82
|
}
|
|
82
83
|
createdTransaction = true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apm-provider.type.d.ts","sourceRoot":"","sources":["../../src/types/apm-provider.type.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,oBAAY,WAAW;IACrB,uCAAuC;IACvC,aAAa,kBAAkB;IAC/B,gCAAgC;IAChC,WAAW,gBAAgB;CAC5B;AAED;;GAEG;AACH,oBAAY,QAAQ;IAClB,yBAAyB;IACzB,QAAQ,aAAa;IACrB,kDAAkD;IAClD,MAAM,WAAW;IACjB,iDAAiD;IACjD,MAAM,WAAW;IACjB,uBAAuB;IACvB,QAAQ,aAAa;IACrB,uBAAuB;IACvB,QAAQ,aAAa;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,oBAAoB;IACpB,QAAQ,CAAC,EAAE,WAAW,GAAG,MAAM,CAAC;IAChC,2BAA2B;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,6BAA6B;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wDAAwD;IACxD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sCAAsC;IACtC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qDAAqD;IACrD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,sBAAsB;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB"}
|
|
1
|
+
{"version":3,"file":"apm-provider.type.d.ts","sourceRoot":"","sources":["../../src/types/apm-provider.type.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,oBAAY,WAAW;IACrB,uCAAuC;IACvC,aAAa,kBAAkB;IAC/B,gCAAgC;IAChC,WAAW,gBAAgB;CAC5B;AAED,+BAA+B;AAC/B,MAAM,MAAM,eAAe,GAAG,GAAG,WAAW,EAAE,CAAC;AAE/C;;GAEG;AACH,oBAAY,QAAQ;IAClB,yBAAyB;IACzB,QAAQ,aAAa;IACrB,kDAAkD;IAClD,MAAM,WAAW;IACjB,iDAAiD;IACjD,MAAM,WAAW;IACjB,uBAAuB;IACvB,QAAQ,aAAa;IACrB,uBAAuB;IACvB,QAAQ,aAAa;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,oBAAoB;IACpB,QAAQ,CAAC,EAAE,WAAW,GAAG,MAAM,CAAC;IAChC,2BAA2B;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,6BAA6B;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wDAAwD;IACxD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sCAAsC;IACtC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qDAAqD;IACrD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,sBAAsB;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB"}
|
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
* Defines common types that work with both Elastic APM and OpenTelemetry providers.
|
|
5
5
|
* This provides type safety and IntelliSense for users of this package.
|
|
6
6
|
*/
|
|
7
|
+
import { ApmProvider, type ApmProviderType, SpanKind } from "./apm-provider.type";
|
|
8
|
+
import { OtlpTransport, type OtlpTransportType } from "./otlp-transport.type";
|
|
9
|
+
export { ApmProvider, type ApmProviderType, SpanKind, OtlpTransport, type OtlpTransportType };
|
|
7
10
|
/**
|
|
8
11
|
* Common Span interface - works with both Elastic APM and OpenTelemetry
|
|
9
12
|
*/
|
|
@@ -50,16 +53,6 @@ export interface SpanOptions {
|
|
|
50
53
|
/** Parent span context */
|
|
51
54
|
parent?: ISpan;
|
|
52
55
|
}
|
|
53
|
-
/**
|
|
54
|
-
* Span kind enumeration
|
|
55
|
-
*/
|
|
56
|
-
export declare enum SpanKind {
|
|
57
|
-
INTERNAL = 0,
|
|
58
|
-
SERVER = 1,
|
|
59
|
-
CLIENT = 2,
|
|
60
|
-
PRODUCER = 3,
|
|
61
|
-
CONSUMER = 4
|
|
62
|
-
}
|
|
63
56
|
/**
|
|
64
57
|
* Common APM Provider configuration
|
|
65
58
|
*/
|
|
@@ -103,29 +96,6 @@ export interface IOpenTelemetryConfig extends IApmProviderConfig {
|
|
|
103
96
|
/** Enable console exporter */
|
|
104
97
|
enableConsoleExporter?: boolean;
|
|
105
98
|
}
|
|
106
|
-
/**
|
|
107
|
-
* OTLP Transport types
|
|
108
|
-
*/
|
|
109
|
-
export declare enum OtlpTransport {
|
|
110
|
-
HTTP = "http",
|
|
111
|
-
GRPC = "grpc",
|
|
112
|
-
PROTO = "proto"
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* OTLP Transport type string
|
|
116
|
-
*/
|
|
117
|
-
export type OtlpTransportType = `${OtlpTransport}`;
|
|
118
|
-
/**
|
|
119
|
-
* APM Provider types
|
|
120
|
-
*/
|
|
121
|
-
export declare enum ApmProvider {
|
|
122
|
-
ELASTIC = "elastic-apm",
|
|
123
|
-
OPENTELEMETRY = "opentelemetry"
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* APM Provider type string
|
|
127
|
-
*/
|
|
128
|
-
export type ApmProviderType = `${ApmProvider}`;
|
|
129
99
|
/**
|
|
130
100
|
* Export result from span export
|
|
131
101
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apm.types.d.ts","sourceRoot":"","sources":["../../src/types/apm.types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"apm.types.d.ts","sourceRoot":"","sources":["../../src/types/apm.types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,WAAW,EAAE,KAAK,eAAe,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAClF,OAAO,EAAE,aAAa,EAAE,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAG9E,OAAO,EAAE,WAAW,EAAE,KAAK,eAAe,EAAE,QAAQ,EAAE,aAAa,EAAE,KAAK,iBAAiB,EAAE,CAAC;AAE9F;;GAEG;AACH,MAAM,WAAW,KAAK;IACpB,gBAAgB;IAChB,IAAI,EAAE,MAAM,CAAC;IAEb,mBAAmB;IACnB,GAAG,IAAI,IAAI,CAAC;IAEZ,mCAAmC;IACnC,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,EAAE,GAAG,SAAS,GAAG,IAAI,CAAC;IAEzF,+BAA+B;IAC/B,QAAQ,CAAC,CAAC,IAAI,E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;AACH,MAAM,WAAW,aAAa;IAC5B,mBAAmB;IACnB,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,GAAG,IAAI,CAAC;IAExE,4BAA4B;IAC5B,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1B,6BAA6B;IAC7B,UAAU,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B"}
|
package/dist/types/apm.types.js
CHANGED
|
@@ -6,32 +6,10 @@
|
|
|
6
6
|
* This provides type safety and IntelliSense for users of this package.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
SpanKind[SpanKind["SERVER"] = 1] = "SERVER";
|
|
17
|
-
SpanKind[SpanKind["CLIENT"] = 2] = "CLIENT";
|
|
18
|
-
SpanKind[SpanKind["PRODUCER"] = 3] = "PRODUCER";
|
|
19
|
-
SpanKind[SpanKind["CONSUMER"] = 4] = "CONSUMER";
|
|
20
|
-
})(SpanKind || (exports.SpanKind = SpanKind = {}));
|
|
21
|
-
/**
|
|
22
|
-
* OTLP Transport types
|
|
23
|
-
*/
|
|
24
|
-
var OtlpTransport;
|
|
25
|
-
(function (OtlpTransport) {
|
|
26
|
-
OtlpTransport["HTTP"] = "http";
|
|
27
|
-
OtlpTransport["GRPC"] = "grpc";
|
|
28
|
-
OtlpTransport["PROTO"] = "proto";
|
|
29
|
-
})(OtlpTransport || (exports.OtlpTransport = OtlpTransport = {}));
|
|
30
|
-
/**
|
|
31
|
-
* APM Provider types
|
|
32
|
-
*/
|
|
33
|
-
var ApmProvider;
|
|
34
|
-
(function (ApmProvider) {
|
|
35
|
-
ApmProvider["ELASTIC"] = "elastic-apm";
|
|
36
|
-
ApmProvider["OPENTELEMETRY"] = "opentelemetry";
|
|
37
|
-
})(ApmProvider || (exports.ApmProvider = ApmProvider = {}));
|
|
9
|
+
exports.OtlpTransport = exports.SpanKind = exports.ApmProvider = void 0;
|
|
10
|
+
// Import enums from their source files
|
|
11
|
+
const apm_provider_type_1 = require("./apm-provider.type");
|
|
12
|
+
Object.defineProperty(exports, "ApmProvider", { enumerable: true, get: function () { return apm_provider_type_1.ApmProvider; } });
|
|
13
|
+
Object.defineProperty(exports, "SpanKind", { enumerable: true, get: function () { return apm_provider_type_1.SpanKind; } });
|
|
14
|
+
const otlp_transport_type_1 = require("./otlp-transport.type");
|
|
15
|
+
Object.defineProperty(exports, "OtlpTransport", { enumerable: true, get: function () { return otlp_transport_type_1.OtlpTransport; } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otlp-transport.type.d.ts","sourceRoot":"","sources":["../../src/types/otlp-transport.type.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,oBAAY,aAAa;IACvB,IAAI,SAAS;IACb,IAAI,SAAS;IACb,KAAK,UAAU;CAChB"}
|
|
1
|
+
{"version":3,"file":"otlp-transport.type.d.ts","sourceRoot":"","sources":["../../src/types/otlp-transport.type.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,oBAAY,aAAa;IACvB,IAAI,SAAS;IACb,IAAI,SAAS;IACb,KAAK,UAAU;CAChB;AAED,iCAAiC;AACjC,MAAM,MAAM,iBAAiB,GAAG,GAAG,aAAa,EAAE,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Elastic APM Compatibility Layer
|
|
3
|
+
*
|
|
4
|
+
* Provides compatibility functions for working with both elastic-apm-node v3 and v4.
|
|
5
|
+
*
|
|
6
|
+
* Key differences:
|
|
7
|
+
* - v4: agent.getServiceEnvironment() method
|
|
8
|
+
* - v3: agent.conf.environment property
|
|
9
|
+
* - v4: startTransaction() never returns null (returns no-op Transaction instead)
|
|
10
|
+
* - v3: startTransaction() can return null
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Elastic APM Agent interface for compatibility
|
|
14
|
+
*/
|
|
15
|
+
interface IElasticApmAgent {
|
|
16
|
+
isStarted(): boolean;
|
|
17
|
+
start(config?: unknown): IElasticApmAgent;
|
|
18
|
+
startTransaction(name: string, type: string): ITransaction | null;
|
|
19
|
+
startSpan(name: string, type: string): ISpan | null;
|
|
20
|
+
captureError(error: Error): void;
|
|
21
|
+
setTransactionName(name: string): void;
|
|
22
|
+
setLabel(key: string, value: string | number): void;
|
|
23
|
+
flush?(): Promise<void>;
|
|
24
|
+
shutdown?(): Promise<void>;
|
|
25
|
+
getServiceName?(): string | undefined;
|
|
26
|
+
getServiceEnvironment?(): string;
|
|
27
|
+
conf?: {
|
|
28
|
+
environment?: string;
|
|
29
|
+
[key: string]: unknown;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Transaction interface for compatibility
|
|
34
|
+
*/
|
|
35
|
+
interface ITransaction {
|
|
36
|
+
end(): void;
|
|
37
|
+
name?: string;
|
|
38
|
+
type?: string | null;
|
|
39
|
+
ended?: boolean;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Span interface for compatibility
|
|
43
|
+
*/
|
|
44
|
+
interface ISpan {
|
|
45
|
+
end(): void;
|
|
46
|
+
name?: string;
|
|
47
|
+
ended?: boolean;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Get the service environment from the APM agent.
|
|
51
|
+
*
|
|
52
|
+
* In v4: uses agent.getServiceEnvironment()
|
|
53
|
+
* In v3: uses agent.conf.environment
|
|
54
|
+
*
|
|
55
|
+
* @param agent The Elastic APM agent instance
|
|
56
|
+
* @returns The environment string, or empty string if not available
|
|
57
|
+
*/
|
|
58
|
+
export declare function getServiceEnvironment(agent: IElasticApmAgent | null): string;
|
|
59
|
+
/**
|
|
60
|
+
* Check if a transaction is a no-op (does nothing).
|
|
61
|
+
*
|
|
62
|
+
* In v3: transaction can be null
|
|
63
|
+
* In v4: transaction is never null, but can be a no-op with ended: true
|
|
64
|
+
*
|
|
65
|
+
* @param transaction The transaction to check
|
|
66
|
+
* @returns true if the transaction is a no-op or null
|
|
67
|
+
*/
|
|
68
|
+
export declare function isTransactionNoOp(transaction: ITransaction | null | undefined): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Check if a span is a no-op (does nothing).
|
|
71
|
+
*
|
|
72
|
+
* In v3: span can be null
|
|
73
|
+
* In v4: span can be null or a no-op
|
|
74
|
+
*
|
|
75
|
+
* @param span The span to check
|
|
76
|
+
* @returns true if the span is a no-op or null
|
|
77
|
+
*/
|
|
78
|
+
export declare function isSpanNoOp(span: ISpan | null | undefined): boolean;
|
|
79
|
+
export {};
|
|
80
|
+
//# sourceMappingURL=elastic-apm-compat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elastic-apm-compat.d.ts","sourceRoot":"","sources":["../../src/utils/elastic-apm-compat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;GAEG;AACH,UAAU,gBAAgB;IACxB,SAAS,IAAI,OAAO,CAAC;IACrB,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,gBAAgB,CAAC;IAC1C,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI,CAAC;IAClE,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,KAAK,GAAG,IAAI,CAAC;IACpD,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACjC,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACvC,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IACpD,KAAK,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACxB,QAAQ,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,cAAc,CAAC,IAAI,MAAM,GAAG,SAAS,CAAC;IACtC,qBAAqB,CAAC,IAAI,MAAM,CAAC;IACjC,IAAI,CAAC,EAAE;QACL,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,CAAC;CACH;AAED;;GAEG;AACH,UAAU,YAAY;IACpB,GAAG,IAAI,IAAI,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,UAAU,KAAK;IACb,GAAG,IAAI,IAAI,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI,GAAG,MAAM,CAoB5E;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,YAAY,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAavF;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,KAAK,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAYlE"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Elastic APM Compatibility Layer
|
|
4
|
+
*
|
|
5
|
+
* Provides compatibility functions for working with both elastic-apm-node v3 and v4.
|
|
6
|
+
*
|
|
7
|
+
* Key differences:
|
|
8
|
+
* - v4: agent.getServiceEnvironment() method
|
|
9
|
+
* - v3: agent.conf.environment property
|
|
10
|
+
* - v4: startTransaction() never returns null (returns no-op Transaction instead)
|
|
11
|
+
* - v3: startTransaction() can return null
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.getServiceEnvironment = getServiceEnvironment;
|
|
15
|
+
exports.isTransactionNoOp = isTransactionNoOp;
|
|
16
|
+
exports.isSpanNoOp = isSpanNoOp;
|
|
17
|
+
/**
|
|
18
|
+
* Get the service environment from the APM agent.
|
|
19
|
+
*
|
|
20
|
+
* In v4: uses agent.getServiceEnvironment()
|
|
21
|
+
* In v3: uses agent.conf.environment
|
|
22
|
+
*
|
|
23
|
+
* @param agent The Elastic APM agent instance
|
|
24
|
+
* @returns The environment string, or empty string if not available
|
|
25
|
+
*/
|
|
26
|
+
function getServiceEnvironment(agent) {
|
|
27
|
+
if (!agent) {
|
|
28
|
+
return "";
|
|
29
|
+
}
|
|
30
|
+
// Try v4 API first
|
|
31
|
+
if (typeof agent.getServiceEnvironment === "function") {
|
|
32
|
+
try {
|
|
33
|
+
return agent.getServiceEnvironment();
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
// Fall through to v3 API
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
// Try v3 API
|
|
40
|
+
if (agent.conf && typeof agent.conf.environment === "string") {
|
|
41
|
+
return agent.conf.environment;
|
|
42
|
+
}
|
|
43
|
+
return "";
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Check if a transaction is a no-op (does nothing).
|
|
47
|
+
*
|
|
48
|
+
* In v3: transaction can be null
|
|
49
|
+
* In v4: transaction is never null, but can be a no-op with ended: true
|
|
50
|
+
*
|
|
51
|
+
* @param transaction The transaction to check
|
|
52
|
+
* @returns true if the transaction is a no-op or null
|
|
53
|
+
*/
|
|
54
|
+
function isTransactionNoOp(transaction) {
|
|
55
|
+
// v3: null or undefined means no transaction
|
|
56
|
+
if (transaction === null || transaction === undefined) {
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
// v4: no-op transactions have ended: true
|
|
60
|
+
// Check if the transaction is already ended (indicates no-op)
|
|
61
|
+
if (typeof transaction === "object" && transaction.ended === true) {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Check if a span is a no-op (does nothing).
|
|
68
|
+
*
|
|
69
|
+
* In v3: span can be null
|
|
70
|
+
* In v4: span can be null or a no-op
|
|
71
|
+
*
|
|
72
|
+
* @param span The span to check
|
|
73
|
+
* @returns true if the span is a no-op or null
|
|
74
|
+
*/
|
|
75
|
+
function isSpanNoOp(span) {
|
|
76
|
+
// v3: null or undefined means no span
|
|
77
|
+
if (span === null || span === undefined) {
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
// v4: no-op spans have ended: true
|
|
81
|
+
if (typeof span === "object" && span.ended === true) {
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
return false;
|
|
85
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vtvlive/interactive-apm",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
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",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@opentelemetry/sdk-node": ">=0.200.0",
|
|
49
49
|
"@opentelemetry/sdk-trace-base": ">=1.0.0",
|
|
50
50
|
"@opentelemetry/semantic-conventions": ">=1.0.0",
|
|
51
|
-
"elastic-apm-node": ">=3.0.0"
|
|
51
|
+
"elastic-apm-node": ">=3.0.0 <5.0.0"
|
|
52
52
|
},
|
|
53
53
|
"peerDependenciesMeta": {
|
|
54
54
|
"@nestjs/common": {
|