@safaricom-mxl/node-sdk 0.0.19 → 0.0.21
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/LICENSE +201 -0
- package/dist/gcp.cjs +1 -1
- package/dist/gcp.mjs +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.mjs +2 -2
- package/dist/{initSDK-CNO4UIyE.cjs → initSDK-CPCU4L5z.cjs} +1 -1
- package/dist/{initSDK-CEoKmErG.mjs → initSDK-DJtki_L0.mjs} +2 -2
- package/dist/{initSDK-CEoKmErG.mjs.map → initSDK-DJtki_L0.mjs.map} +1 -1
- package/dist/logger/evlog.cjs +2 -2
- package/dist/logger/evlog.mjs +2 -2
- package/dist/logger/nest.cjs +1 -1
- package/dist/logger/nest.mjs +1 -1
- package/dist/logger/pino.cjs +1 -1
- package/dist/logger/pino.mjs +1 -1
- package/dist/logger/winston.cjs +1 -1
- package/dist/logger/winston.mjs +1 -1
- package/dist/{otelLogger-Bt7O4s1o.mjs → otelLogger-C_p4pOdm.mjs} +2 -2
- package/dist/{otelLogger-Bt7O4s1o.mjs.map → otelLogger-C_p4pOdm.mjs.map} +1 -1
- package/dist/{otelLogger-aeFdkNPQ.cjs → otelLogger-YG7L3G5Q.cjs} +1 -1
- package/dist/tracing.cjs +1 -1
- package/dist/tracing.mjs +1 -1
- package/package.json +30 -30
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/dist/gcp.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
let _opentelemetry_api = require("@opentelemetry/api");
|
|
3
3
|
let _opentelemetry_semantic_conventions_incubating = require("@opentelemetry/semantic-conventions/incubating");
|
|
4
|
-
const require_initSDK = require("./initSDK-
|
|
4
|
+
const require_initSDK = require("./initSDK-CPCU4L5z.cjs");
|
|
5
5
|
// src/gcp.ts
|
|
6
6
|
function registerGCPCloudFunctionEventHandler(handler, sdkConfig = {}) {
|
|
7
7
|
require_initSDK.initSDK(sdkConfig);
|
package/dist/gcp.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SpanKind, context, trace } from "@opentelemetry/api";
|
|
2
2
|
import { ATTR_MESSAGING_DESTINATION_NAME, ATTR_MESSAGING_MESSAGE_BODY_SIZE, ATTR_MESSAGING_MESSAGE_ID, ATTR_MESSAGING_OPERATION_TYPE, ATTR_MESSAGING_SYSTEM_NAME, MESSAGING_OPERATION_TYPE_VALUE_PROCESS, MESSAGING_SYSTEM_NAME_VALUE_GCP_PUBSUB } from "@opentelemetry/semantic-conventions/incubating";
|
|
3
|
-
import { r as initSDK } from "./initSDK-
|
|
3
|
+
import { r as initSDK } from "./initSDK-DJtki_L0.mjs";
|
|
4
4
|
// src/gcp.ts
|
|
5
5
|
function registerGCPCloudFunctionEventHandler(handler, sdkConfig = {}) {
|
|
6
6
|
initSDK(sdkConfig);
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_initSDK = require("./initSDK-
|
|
3
|
-
const require_otelLogger = require("./otelLogger-
|
|
2
|
+
const require_initSDK = require("./initSDK-CPCU4L5z.cjs");
|
|
3
|
+
const require_otelLogger = require("./otelLogger-YG7L3G5Q.cjs");
|
|
4
4
|
const require_gcp = require("./gcp.cjs");
|
|
5
5
|
const require_recordException = require("./recordException-zcmSkhl5.cjs");
|
|
6
6
|
const require_integrations_express = require("./integrations/express.cjs");
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as getActiveSDKConfig, c as setTraceAttributes$1, i as shutdown, o as resolveSDKConfig, r as initSDK, s as getTraceAttributes, t as forceFlush } from "./initSDK-
|
|
2
|
-
import { t as OTelLogger } from "./otelLogger-
|
|
1
|
+
import { a as getActiveSDKConfig, c as setTraceAttributes$1, i as shutdown, o as resolveSDKConfig, r as initSDK, s as getTraceAttributes, t as forceFlush } from "./initSDK-DJtki_L0.mjs";
|
|
2
|
+
import { t as OTelLogger } from "./otelLogger-C_p4pOdm.mjs";
|
|
3
3
|
import { registerGCPCloudFunctionEventHandler } from "./gcp.mjs";
|
|
4
4
|
import { t as recordException } from "./recordException-D4LkyJPb.mjs";
|
|
5
5
|
import { expressErrorHandler, setupExpressErrorHandler } from "./integrations/express.mjs";
|
|
@@ -8,7 +8,7 @@ let node_events = require("node:events");
|
|
|
8
8
|
let _opentelemetry_exporter_metrics_otlp_grpc = require("@opentelemetry/exporter-metrics-otlp-grpc");
|
|
9
9
|
let _opentelemetry_exporter_metrics_otlp_proto = require("@opentelemetry/exporter-metrics-otlp-proto");
|
|
10
10
|
let _opentelemetry_sdk_metrics = require("@opentelemetry/sdk-metrics");
|
|
11
|
-
const require_otelLogger = require("./otelLogger-
|
|
11
|
+
const require_otelLogger = require("./otelLogger-YG7L3G5Q.cjs");
|
|
12
12
|
let _opentelemetry_exporter_trace_otlp_grpc = require("@opentelemetry/exporter-trace-otlp-grpc");
|
|
13
13
|
let _opentelemetry_exporter_trace_otlp_proto = require("@opentelemetry/exporter-trace-otlp-proto");
|
|
14
14
|
let node_module = require("node:module");
|
|
@@ -7,7 +7,7 @@ import { EventEmitter } from "node:events";
|
|
|
7
7
|
import { OTLPMetricExporter } from "@opentelemetry/exporter-metrics-otlp-grpc";
|
|
8
8
|
import { OTLPMetricExporter as OTLPMetricExporter$1 } from "@opentelemetry/exporter-metrics-otlp-proto";
|
|
9
9
|
import { PeriodicExportingMetricReader } from "@opentelemetry/sdk-metrics";
|
|
10
|
-
import { a as parseHeaderAttributeMap, c as DEFAULT_METRIC_EXPORT_TIMEOUT_MS, d as DEFAULT_TRACE_TIMEOUT_MS, f as NODE_SDK_NAME, i as getStringFromEnv, n as resolveOtlpExporterUrl, o as parseOtlpHeaders, p as NODE_SDK_VERSION, r as getBooleanFromEnv, s as DEFAULT_METRIC_EXPORT_INTERVAL_MS, t as OTelLogger } from "./otelLogger-
|
|
10
|
+
import { a as parseHeaderAttributeMap, c as DEFAULT_METRIC_EXPORT_TIMEOUT_MS, d as DEFAULT_TRACE_TIMEOUT_MS, f as NODE_SDK_NAME, i as getStringFromEnv, n as resolveOtlpExporterUrl, o as parseOtlpHeaders, p as NODE_SDK_VERSION, r as getBooleanFromEnv, s as DEFAULT_METRIC_EXPORT_INTERVAL_MS, t as OTelLogger } from "./otelLogger-C_p4pOdm.mjs";
|
|
11
11
|
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-grpc";
|
|
12
12
|
import { OTLPTraceExporter as OTLPTraceExporter$1 } from "@opentelemetry/exporter-trace-otlp-proto";
|
|
13
13
|
import { createRequire } from "node:module";
|
|
@@ -1124,4 +1124,4 @@ function getControl() {
|
|
|
1124
1124
|
}
|
|
1125
1125
|
export { getActiveSDKConfig as a, setTraceAttributes as c, shutdown as i, getInitializedOTelLogger as n, resolveSDKConfig as o, initSDK as r, getTraceAttributes as s, forceFlush as t };
|
|
1126
1126
|
|
|
1127
|
-
//# sourceMappingURL=initSDK-
|
|
1127
|
+
//# sourceMappingURL=initSDK-DJtki_L0.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initSDK-CEoKmErG.mjs","names":["OTLPMetricExporterGRPC","OTLPMetricExporterHTTP","OTLPTraceExporterGRPC","OTLPTraceExporterHTTP"],"sources":["../src/context/AbstractAsyncHooksContextManager.ts","../src/context/MutableAsyncLocalStorageContextManager.ts","../src/context/contextManager.ts","../src/exporters/metricReader.ts","../src/exporters/traceExporter.ts","../src/instrumentations/exceptions/sentry.ts","../src/instrumentations/console.ts","../src/instrumentations/exceptions/ExceptionInstrumentation.ts","../src/instrumentations/http.ts","../src/processors/CompositeSpanProcessor.ts","../src/processors/FilterWhenDrainedSpanProcessor.ts","../src/processors/NodeSpanProcessor.ts","../src/profiling/ProfilingSpanProcessor.ts","../src/profiling/span-timeline.ts","../src/profiling/cpu-profile.ts","../src/profiling/profiling.ts","../src/resources/nodeSdkResource.ts","../src/sdk/config.ts","../src/sdk/sampler.ts","../src/sdk/state.ts","../src/sdk/initSDK.ts"],"sourcesContent":["/* eslint-disable */\nimport { Context, ContextManager } from '@opentelemetry/api';\nimport { EventEmitter } from 'node:events';\n\ntype Func<T = unknown> = (...args: unknown[]) => T;\n\ninterface PatchMap {\n [name: string]: WeakMap<Func, Func>;\n}\n\nconst ADD_LISTENER_METHODS = [\n 'addListener' as const,\n 'on' as const,\n 'once' as const,\n 'prependListener' as const,\n 'prependOnceListener' as const,\n];\n\nexport abstract class AbstractAsyncHooksContextManager\n implements ContextManager\n{\n abstract active(): Context;\n\n abstract with<A extends unknown[], F extends (...args: A) => ReturnType<F>>(\n context: Context,\n fn: F,\n thisArg?: ThisParameterType<F>,\n ...args: A\n ): ReturnType<F>;\n\n abstract enable(): this;\n\n abstract disable(): this;\n\n bind<T>(context: Context, target: T): T {\n if (target instanceof EventEmitter) {\n return this._bindEventEmitter(context, target);\n }\n if (typeof target === 'function') {\n return this._bindFunction(context, target);\n }\n return target;\n }\n\n private _bindFunction<T extends Function>(context: Context, target: T): T {\n const manager = this;\n const contextWrapper = function (this: never, ...args: unknown[]) {\n return manager.with(context, () => target.apply(this, args));\n };\n Object.defineProperty(contextWrapper, 'length', {\n enumerable: false,\n configurable: true,\n writable: false,\n value: target.length,\n });\n return contextWrapper as never;\n }\n\n private _bindEventEmitter<T extends EventEmitter>(\n context: Context,\n ee: T,\n ): T {\n const map = this._getPatchMap(ee);\n if (map !== undefined) {\n return ee;\n }\n this._createPatchMap(ee);\n\n ADD_LISTENER_METHODS.forEach((methodName) => {\n if (ee[methodName] === undefined) {\n return;\n }\n ee[methodName] = this._patchAddListener(ee, ee[methodName], context);\n });\n if (typeof ee.removeListener === 'function') {\n ee.removeListener = this._patchRemoveListener(ee, ee.removeListener);\n }\n if (typeof ee.off === 'function') {\n ee.off = this._patchRemoveListener(ee, ee.off);\n }\n if (typeof ee.removeAllListeners === 'function') {\n ee.removeAllListeners = this._patchRemoveAllListeners(\n ee,\n ee.removeAllListeners,\n );\n }\n return ee;\n }\n\n private _patchRemoveListener(ee: EventEmitter, original: Function) {\n const contextManager = this;\n return function (this: never, event: string, listener: Func) {\n const events = contextManager._getPatchMap(ee)?.[event];\n if (events === undefined) {\n return original.call(this, event, listener);\n }\n const patchedListener = events.get(listener);\n return original.call(this, event, patchedListener || listener);\n };\n }\n\n private _patchRemoveAllListeners(ee: EventEmitter, original: Function) {\n const contextManager = this;\n return function (this: never, event: string) {\n const map = contextManager._getPatchMap(ee);\n if (map !== undefined) {\n if (arguments.length === 0) {\n contextManager._createPatchMap(ee);\n } else if (map[event] !== undefined) {\n delete map[event];\n }\n }\n return original.apply(this, arguments);\n };\n }\n\n private _patchAddListener(\n ee: EventEmitter,\n original: Function,\n context: Context,\n ) {\n const contextManager = this;\n return function (this: never, event: string, listener: Func) {\n if (contextManager._wrapped) {\n return original.call(this, event, listener);\n }\n let map = contextManager._getPatchMap(ee);\n if (map === undefined) {\n map = contextManager._createPatchMap(ee);\n }\n let listeners = map[event];\n if (listeners === undefined) {\n listeners = new WeakMap();\n map[event] = listeners;\n }\n const patchedListener = contextManager.bind(context, listener);\n listeners.set(listener, patchedListener);\n contextManager._wrapped = true;\n try {\n return original.call(this, event, patchedListener);\n } finally {\n contextManager._wrapped = false;\n }\n };\n }\n\n private _createPatchMap(ee: EventEmitter): PatchMap {\n const map = Object.create(null) as PatchMap;\n (ee as any)[this._kOtListeners] = map;\n return map;\n }\n\n private _getPatchMap(ee: EventEmitter): PatchMap | undefined {\n return (ee as never)[this._kOtListeners];\n }\n\n private readonly _kOtListeners = Symbol('OtListeners');\n private _wrapped = false;\n}\n","import { Context, ROOT_CONTEXT } from '@opentelemetry/api';\nimport { AsyncLocalStorage } from 'node:async_hooks';\nimport { AbstractAsyncHooksContextManager } from './AbstractAsyncHooksContextManager.ts';\n\nexport type MutableContextStore = {\n context?: Context;\n mutableContext?: {\n traceAttributes: Map<string, unknown>;\n };\n};\n\nexport class MutableAsyncLocalStorageContextManager extends AbstractAsyncHooksContextManager {\n private readonly asyncLocalStorage: AsyncLocalStorage<MutableContextStore>;\n\n constructor() {\n super();\n this.asyncLocalStorage = new AsyncLocalStorage<MutableContextStore>();\n }\n\n active(): Context {\n return this.asyncLocalStorage.getStore()?.context ?? ROOT_CONTEXT;\n }\n\n with<A extends unknown[], F extends (...args: A) => ReturnType<F>>(\n context: Context,\n fn: F,\n thisArg?: ThisParameterType<F>,\n ...args: A\n ): ReturnType<F> {\n const mutableContext = this.asyncLocalStorage.getStore()?.mutableContext ?? {\n traceAttributes: new Map<string, unknown>(),\n };\n const callback = thisArg == null ? fn : fn.bind(thisArg);\n return this.asyncLocalStorage.run(\n { context, mutableContext },\n callback as never,\n ...args,\n );\n }\n\n getMutableContext() {\n return this.asyncLocalStorage.getStore()?.mutableContext;\n }\n\n enable(): this {\n return this;\n }\n\n disable(): this {\n this.asyncLocalStorage.disable();\n return this;\n }\n}\n","import { Attributes } from '@opentelemetry/api';\nimport { MutableAsyncLocalStorageContextManager } from './MutableAsyncLocalStorageContextManager.ts';\n\nlet mutableContextManager: MutableAsyncLocalStorageContextManager | undefined;\n\nexport function setMutableContextManager(\n manager: MutableAsyncLocalStorageContextManager | undefined,\n) {\n mutableContextManager = manager;\n}\n\nexport function getMutableContextManager() {\n return mutableContextManager;\n}\n\nexport function setTraceAttributes(attributes: Attributes) {\n const mutableContext = mutableContextManager?.getMutableContext();\n if (!mutableContext) {\n return;\n }\n for (const [key, value] of Object.entries(attributes)) {\n mutableContext.traceAttributes.set(key, value);\n }\n}\n\nexport function getTraceAttributes(): Attributes {\n const mutableContext = mutableContextManager?.getMutableContext();\n if (!mutableContext) {\n return {};\n }\n return Object.fromEntries(mutableContext.traceAttributes) as Attributes;\n}\n","import { OTLPMetricExporter as OTLPMetricExporterGRPC } from '@opentelemetry/exporter-metrics-otlp-grpc';\nimport { OTLPMetricExporter as OTLPMetricExporterHTTP } from '@opentelemetry/exporter-metrics-otlp-proto';\nimport { PeriodicExportingMetricReader } from '@opentelemetry/sdk-metrics';\nimport {\n DEFAULT_METRIC_EXPORT_INTERVAL_MS,\n DEFAULT_METRIC_EXPORT_TIMEOUT_MS,\n} from '../constants/index.ts';\nimport type { ResolvedSDKConfig } from '../sdk/types.ts';\nimport { parseOtlpHeaders } from '../utils/env.ts';\nimport { resolveOtlpExporterUrl } from './urls.ts';\n\nexport function createMetricReader(config: ResolvedSDKConfig) {\n const url = resolveOtlpExporterUrl({\n kind: 'metric',\n endpoint: config.otlpEndpoint,\n });\n const headers = parseOtlpHeaders(config.otlpHeaders);\n\n const exporter =\n config.otlpProtocol === 'grpc'\n ? new OTLPMetricExporterGRPC({ url, headers })\n : new OTLPMetricExporterHTTP({ url, headers });\n\n return new PeriodicExportingMetricReader({\n exporter,\n exportIntervalMillis: DEFAULT_METRIC_EXPORT_INTERVAL_MS,\n exportTimeoutMillis: DEFAULT_METRIC_EXPORT_TIMEOUT_MS,\n });\n}\n","import { OTLPTraceExporter as OTLPTraceExporterGRPC } from '@opentelemetry/exporter-trace-otlp-grpc';\nimport { OTLPTraceExporter as OTLPTraceExporterHTTP } from '@opentelemetry/exporter-trace-otlp-proto';\nimport {\n DEFAULT_TRACE_TIMEOUT_MS,\n} from '../constants/index.ts';\nimport type { ResolvedSDKConfig } from '../sdk/types.ts';\nimport { parseOtlpHeaders } from '../utils/env.ts';\nimport { resolveOtlpExporterUrl } from './urls.ts';\n\nexport function createTraceExporter(config: ResolvedSDKConfig) {\n const url = resolveOtlpExporterUrl({\n kind: 'trace',\n endpoint: config.otlpEndpoint,\n explicitUrl: config.traceExporterUrl,\n });\n const headers = parseOtlpHeaders(config.otlpHeaders);\n\n if (config.otlpProtocol === 'grpc') {\n return new OTLPTraceExporterGRPC({\n url,\n timeoutMillis: DEFAULT_TRACE_TIMEOUT_MS,\n headers,\n } as ConstructorParameters<typeof OTLPTraceExporterGRPC>[0]);\n }\n\n return new OTLPTraceExporterHTTP({\n url,\n timeoutMillis: DEFAULT_TRACE_TIMEOUT_MS,\n headers,\n });\n}\n","import { createRequire } from 'node:module';\n\nconst require = createRequire(import.meta.url);\n\nexport type SentryBridge = {\n captureException: (error: unknown) => void;\n};\n\nexport function createSentryBridge(\n enabled: boolean,\n): SentryBridge | undefined {\n if (!enabled) {\n return undefined;\n }\n\n try {\n const sentry = require('@sentry/node');\n return {\n captureException(error: unknown) {\n sentry.captureException(error);\n },\n };\n } catch {\n return undefined;\n }\n}\n","import opentelemetry, { Attributes } from '@opentelemetry/api';\nimport {\n InstrumentationBase,\n InstrumentationConfig,\n InstrumentationNodeModuleDefinition,\n} from '@opentelemetry/instrumentation';\nimport isObject from 'lodash.isobject';\nimport isPlainObject from 'lodash.isplainobject';\nimport { getTraceAttributes } from '../context/index.ts';\nimport { OTelLogger } from '../logger/otelLogger.ts';\nimport { parseWinstonLog } from '../logger/winston.ts';\nimport type { ResolvedSDKConfig } from '../sdk/types.ts';\n\nconst PACKAGE_NAME = '@safaricom-mxl/instrumentation-console';\nconst PACKAGE_VERSION = '0.0.4';\n\nfunction parseConsoleArgs(args: unknown[]) {\n const stringified: unknown[] = [];\n let firstObject: Record<string, unknown> | undefined;\n\n for (const arg of args) {\n if (isObject(arg)) {\n if (!firstObject && isPlainObject(arg)) {\n firstObject = arg as Record<string, unknown>;\n }\n try {\n stringified.push(JSON.stringify(arg));\n } catch {\n // ignore\n }\n continue;\n }\n stringified.push(arg);\n }\n\n return firstObject\n ? {\n ...firstObject,\n ...(args.length > 1 ? { message: stringified.join(' ') } : {}),\n }\n : stringified.join(' ');\n}\n\nexport interface ConsoleInstrumentationConfig extends InstrumentationConfig {\n config: ResolvedSDKConfig;\n}\n\nexport class ConsoleInstrumentation extends InstrumentationBase {\n private readonly otelLogger: OTelLogger;\n\n constructor(config: ConsoleInstrumentationConfig) {\n super(PACKAGE_NAME, PACKAGE_VERSION, config);\n this.otelLogger = new OTelLogger({ config: config.config });\n }\n\n private patchConsoleMethod(type: string, ...args: unknown[]) {\n const level = type === 'log' ? 'info' : type;\n const parsed = parseWinstonLog(\n {\n message: parseConsoleArgs(args),\n level,\n } as never,\n );\n const activeSpan = opentelemetry.trace.getActiveSpan();\n const spanContext = activeSpan?.spanContext();\n let attributes: Attributes = {\n ...parsed.meta,\n ...(spanContext\n ? {\n trace_id: spanContext.traceId,\n span_id: spanContext.spanId,\n trace_flags: spanContext.traceFlags,\n }\n : {}),\n };\n if ((this.getConfig() as ConsoleInstrumentationConfig).config.betaMode) {\n attributes = { ...attributes, ...getTraceAttributes() };\n }\n this.otelLogger.postMessage(parsed.level, parsed.message, attributes);\n }\n\n private wrapHandler(\n type: 'debug' | 'log' | 'info' | 'warn' | 'error',\n original: (...args: unknown[]) => unknown,\n ) {\n return (...args: unknown[]) => {\n this.patchConsoleMethod(type, ...args);\n return original.apply(this, args);\n };\n }\n\n private onPatch(moduleExports: Console) {\n this._wrap(moduleExports, 'debug', (original) =>\n this.wrapHandler('debug', original),\n );\n this._wrap(moduleExports, 'log', (original) => this.wrapHandler('log', original));\n this._wrap(moduleExports, 'info', (original) =>\n this.wrapHandler('info', original),\n );\n this._wrap(moduleExports, 'warn', (original) =>\n this.wrapHandler('warn', original),\n );\n this._wrap(moduleExports, 'error', (original) =>\n this.wrapHandler('error', original),\n );\n return moduleExports;\n }\n\n private onUnpatch(moduleExports: Console) {\n this._unwrap(moduleExports, 'debug');\n this._unwrap(moduleExports, 'log');\n this._unwrap(moduleExports, 'info');\n this._unwrap(moduleExports, 'warn');\n this._unwrap(moduleExports, 'error');\n }\n\n init() {\n return [\n new InstrumentationNodeModuleDefinition(\n 'console',\n ['*'],\n (moduleExports: Console) => this.onPatch(moduleExports),\n (moduleExports: Console) => {\n this.onUnpatch(moduleExports);\n return moduleExports;\n },\n ),\n ];\n }\n}\n","import {\n InstrumentationBase,\n type InstrumentationConfig,\n} from '@opentelemetry/instrumentation';\nimport { recordException } from './recordException.ts';\n\nexport type ExceptionInstrumentationConfig = {\n captureExceptionHook?: (error: unknown) => void;\n forceFlush?: () => Promise<void>;\n unhandledRejectionMode?: 'none' | 'warn' | 'strict';\n exitEvenIfOtherHandlersAreRegistered?: boolean;\n} & InstrumentationConfig;\n\nexport class ExceptionInstrumentation extends InstrumentationBase {\n private forceFlush?: () => Promise<void>;\n private uncaughtExceptionListener?: (error: Error) => void;\n private unhandledRejectionListener?: (reason: unknown) => void;\n\n constructor(config: ExceptionInstrumentationConfig = {}) {\n super('@safaricom-mxl/instrumentation-exception', '0.0.4', config);\n this.forceFlush = config.forceFlush;\n }\n\n init() {\n return;\n }\n\n override enable() {\n const config = this.getConfig() as ExceptionInstrumentationConfig;\n const rejectionMode = config.unhandledRejectionMode ?? 'warn';\n\n this.uncaughtExceptionListener = (error: Error) => {\n config.captureExceptionHook?.(error);\n void recordException(error).finally(() => {\n void (config.forceFlush?.() ?? this.forceFlush?.());\n });\n if (config.exitEvenIfOtherHandlersAreRegistered) {\n process.exitCode = 1;\n }\n };\n\n this.unhandledRejectionListener = (reason: unknown) => {\n config.captureExceptionHook?.(reason);\n void recordException(reason).finally(() => {\n if (rejectionMode === 'warn') {\n console.warn(\n 'Unhandled promise rejection captured by MXL Node SDK. ' +\n 'Set unhandledRejectionMode=strict to terminate the process.',\n );\n }\n if (rejectionMode === 'strict') {\n void (config.forceFlush?.() ?? this.forceFlush?.()).finally(() => {\n process.exitCode = 1;\n });\n }\n });\n };\n\n process.on('uncaughtException', this.uncaughtExceptionListener);\n process.on('unhandledRejection', this.unhandledRejectionListener);\n }\n\n override disable() {\n if (this.uncaughtExceptionListener) {\n process.off('uncaughtException', this.uncaughtExceptionListener);\n }\n if (this.unhandledRejectionListener) {\n process.off('unhandledRejection', this.unhandledRejectionListener);\n }\n this.uncaughtExceptionListener = undefined;\n this.unhandledRejectionListener = undefined;\n }\n}\n","import { Span, diag } from '@opentelemetry/api';\nimport * as http from 'node:http';\nimport { PassThrough, Readable } from 'node:stream';\nimport zlib from 'node:zlib';\n\nconst SENSITIVE_DATA_SUBSTITUTE = '[Filtered]';\n\nconst DEFAULT_DENYLIST = [\n 'password',\n 'passwd',\n 'secret',\n 'api_key',\n 'apikey',\n 'auth',\n 'credentials',\n 'private_key',\n 'token',\n 'session',\n 'cookie',\n 'authorization',\n 'x_api_key',\n '_csrf',\n 'phpsessid',\n 'xsrf-token',\n];\n\nfunction captureSelectedHeaders(\n span: Span,\n prefix: 'request' | 'response',\n headers: string[],\n getter: (header: string) => unknown,\n) {\n for (const header of headers) {\n const value = getter(header);\n if (Array.isArray(value)) {\n span.setAttribute(`http.${prefix}.header.${header.toLowerCase()}`, value.join(','));\n } else if (value != null) {\n span.setAttribute(\n `http.${prefix}.header.${header.toLowerCase()}`,\n String(value),\n );\n }\n }\n}\n\nexport function splitCommaSeparatedStrings(headers?: string) {\n return headers?.split(',').map((header) => header.trim()).filter(Boolean);\n}\n\nexport function getShouldRecordBody(defaultFilter?: string) {\n return (body: string) => {\n const lowerCaseBody = body.toLowerCase();\n const keywords =\n splitCommaSeparatedStrings(defaultFilter)?.map((item) => item.toLowerCase()) ??\n DEFAULT_DENYLIST;\n return !keywords.some((keyword) => lowerCaseBody.includes(keyword));\n };\n}\n\nfunction interceptReadableStream(stream: Readable, passThrough: PassThrough) {\n const emit = stream.emit;\n stream.emit = function (\n this: Readable,\n event: string | symbol,\n ...args: unknown[]\n ) {\n if (event === 'data') passThrough.write(args[0]);\n else if (event === 'end') passThrough.end();\n return emit.call(this, event, ...args);\n } as typeof stream.emit;\n return stream;\n}\n\nfunction captureBodyAttribute({\n targetSpan,\n attributeName,\n body,\n shouldRecordBody,\n}: {\n targetSpan: Span;\n attributeName: 'http.request.body' | 'http.response.body';\n body: string;\n shouldRecordBody: (body: string) => boolean;\n}) {\n if (!targetSpan.isRecording()) return;\n targetSpan.setAttribute(\n attributeName,\n shouldRecordBody(body) ? body : SENSITIVE_DATA_SUBSTITUTE,\n );\n}\n\nfunction handleOutgoingClientRequest({\n request,\n span,\n shouldRecordBody,\n captureHeaders,\n}: {\n request: http.ClientRequest;\n span: Span;\n shouldRecordBody: (body: string) => boolean;\n captureHeaders?: string;\n}) {\n try {\n const headers = splitCommaSeparatedStrings(captureHeaders) ?? request.getRawHeaderNames();\n captureSelectedHeaders(span, 'request', headers, (header) =>\n request.getHeader(header),\n );\n } catch (error) {\n diag.debug('Failed to capture outgoing request headers', error);\n }\n\n const chunks: Buffer[] = [];\n const oldWrite = request.write.bind(request);\n request.write = ((data: unknown) => {\n chunks.push(Buffer.isBuffer(data) ? data : Buffer.from(String(data)));\n return oldWrite(data as never);\n }) as never;\n\n const oldEnd = request.end.bind(request);\n request.end = ((data: unknown) => {\n if (data != null) {\n chunks.push(Buffer.isBuffer(data) ? data : Buffer.from(String(data)));\n }\n if (chunks.length > 0) {\n captureBodyAttribute({\n targetSpan: span,\n attributeName: 'http.request.body',\n body: Buffer.concat(chunks).toString('utf8'),\n shouldRecordBody,\n });\n }\n return oldEnd(data as never);\n }) as never;\n}\n\nfunction handleIncomingServerRequest({\n request,\n span,\n shouldRecordBody,\n captureHeaders,\n headerAttributeMap,\n}: {\n request: http.IncomingMessage;\n span: Span;\n shouldRecordBody: (body: string) => boolean;\n captureHeaders?: string;\n headerAttributeMap?: Record<string, string>;\n}) {\n try {\n const headers = splitCommaSeparatedStrings(captureHeaders) ?? Object.keys(request.headers);\n captureSelectedHeaders(span, 'request', headers, (header) => request.headers[header]);\n } catch (error) {\n diag.debug('Failed to capture incoming request headers', error);\n }\n\n if (headerAttributeMap) {\n for (const [headerName, attributeName] of Object.entries(headerAttributeMap)) {\n const value = request.headers[headerName];\n if (Array.isArray(value)) {\n span.setAttribute(attributeName, value.join(','));\n } else if (value) {\n span.setAttribute(attributeName, value);\n }\n }\n }\n\n const chunks: Buffer[] = [];\n const passThrough = new PassThrough();\n passThrough.on('data', (chunk) => {\n chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk)));\n });\n passThrough.on('end', () => {\n if (chunks.length === 0) {\n return;\n }\n captureBodyAttribute({\n targetSpan: span,\n attributeName: 'http.request.body',\n body: Buffer.concat(chunks).toString('utf8'),\n shouldRecordBody,\n });\n });\n interceptReadableStream(request, passThrough);\n}\n\nfunction handleIncomingServerResponse({\n response,\n span,\n shouldRecordBody,\n captureHeaders,\n}: {\n response: http.ServerResponse;\n span: Span;\n shouldRecordBody: (body: string) => boolean;\n captureHeaders?: string;\n}) {\n const chunks: Buffer[] = [];\n const oldWrite = response.write.bind(response);\n response.write = ((data: unknown) => {\n chunks.push(Buffer.isBuffer(data) ? data : Buffer.from(String(data)));\n return oldWrite(data as never);\n }) as never;\n\n const oldEnd = response.end.bind(response);\n response.end = ((data: unknown) => {\n if (data != null) {\n chunks.push(Buffer.isBuffer(data) ? data : Buffer.from(String(data)));\n }\n if (chunks.length > 0) {\n const payload = Buffer.concat(chunks);\n const isGzip = response.getHeader('content-encoding') === 'gzip';\n const body = (isGzip ? zlib.gunzipSync(payload) : payload).toString('utf8');\n captureBodyAttribute({\n targetSpan: span,\n attributeName: 'http.response.body',\n body,\n shouldRecordBody,\n });\n }\n\n try {\n const headers = splitCommaSeparatedStrings(captureHeaders) ?? response.getHeaderNames();\n captureSelectedHeaders(span, 'response', headers, (header) =>\n response.getHeader(header),\n );\n } catch (error) {\n diag.debug('Failed to capture incoming response headers', error);\n }\n return oldEnd(data as never);\n }) as never;\n}\n\nfunction handleOutgoingClientResponse({\n response,\n span,\n shouldRecordBody,\n captureHeaders,\n}: {\n response: http.IncomingMessage;\n span: Span;\n shouldRecordBody: (body: string) => boolean;\n captureHeaders?: string;\n}) {\n try {\n const headers = splitCommaSeparatedStrings(captureHeaders) ?? Object.keys(response.headers);\n captureSelectedHeaders(span, 'response', headers, (header) => response.headers[header]);\n } catch (error) {\n diag.debug('Failed to capture outgoing response headers', error);\n }\n\n const chunks: Buffer[] = [];\n const passThrough = new PassThrough();\n passThrough.on('data', (chunk) => {\n chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk)));\n });\n passThrough.on('end', () => {\n if (chunks.length === 0) {\n return;\n }\n const payload = Buffer.concat(chunks);\n const isGzip = response.headers['content-encoding'] === 'gzip';\n const body = (isGzip ? zlib.gunzipSync(payload) : payload).toString('utf8');\n captureBodyAttribute({\n targetSpan: span,\n attributeName: 'http.response.body',\n body,\n shouldRecordBody,\n });\n });\n interceptReadableStream(response, passThrough);\n}\n\nexport function getAdvancedHttpInstrumentationConfig({\n captureBodyKeywordsFilter,\n captureHeadersClientRequest,\n captureHeadersClientResponse,\n captureHeadersServerRequest,\n captureHeadersServerResponse,\n headerAttributeMap,\n}: {\n captureBodyKeywordsFilter?: string;\n captureHeadersClientRequest?: string;\n captureHeadersClientResponse?: string;\n captureHeadersServerRequest?: string;\n captureHeadersServerResponse?: string;\n headerAttributeMap?: Record<string, string>;\n}) {\n const shouldRecordBody = getShouldRecordBody(captureBodyKeywordsFilter);\n\n return {\n requestHook(span: Span, request: http.ClientRequest | http.IncomingMessage) {\n if (request instanceof http.ClientRequest) {\n handleOutgoingClientRequest({\n request,\n span,\n shouldRecordBody,\n captureHeaders: captureHeadersClientRequest,\n });\n } else {\n handleIncomingServerRequest({\n request,\n span,\n shouldRecordBody,\n captureHeaders: captureHeadersServerRequest,\n headerAttributeMap,\n });\n }\n },\n responseHook(span: Span, response: http.ServerResponse | http.IncomingMessage) {\n if (response instanceof http.ServerResponse) {\n handleIncomingServerResponse({\n response,\n span,\n shouldRecordBody,\n captureHeaders: captureHeadersServerResponse,\n });\n } else {\n handleOutgoingClientResponse({\n response,\n span,\n shouldRecordBody,\n captureHeaders: captureHeadersClientResponse,\n });\n }\n },\n };\n}\n","import { Context, diag } from '@opentelemetry/api';\nimport type { ReadableSpan, Span, SpanProcessor } from '@opentelemetry/sdk-trace-base';\n\nexport class CompositeSpanProcessor implements SpanProcessor {\n constructor(private readonly processors: SpanProcessor[]) {}\n\n forceFlush() {\n return Promise.all(\n this.processors.map((processor) =>\n processor.forceFlush().catch((error) => {\n diag.error('@safaricom-mxl/node-sdk: forceFlush failed', error);\n }),\n ),\n ).then(() => undefined);\n }\n\n shutdown() {\n return Promise.all(\n this.processors.map((processor) =>\n processor.shutdown().catch((error) => {\n diag.error('@safaricom-mxl/node-sdk: shutdown failed', error);\n }),\n ),\n ).then(() => undefined);\n }\n\n onStart(span: Span, parentContext: Context) {\n for (const processor of this.processors) {\n processor.onStart(span, parentContext);\n }\n }\n\n onEnd(span: ReadableSpan) {\n for (const processor of this.processors) {\n processor.onEnd(span);\n }\n }\n}\n","import { Context } from '@opentelemetry/api';\nimport type { ReadableSpan, Span, SpanProcessor } from '@opentelemetry/sdk-trace-base';\n\nexport class FilterWhenDrainedSpanProcessor implements SpanProcessor {\n private drained = false;\n\n constructor(private readonly delegate: SpanProcessor) {}\n\n drain() {\n this.drained = true;\n }\n\n onStart(span: Span, parentContext: Context) {\n if (this.drained) {\n return;\n }\n this.delegate.onStart(span, parentContext);\n }\n\n onEnd(span: ReadableSpan) {\n if (this.drained) {\n return;\n }\n this.delegate.onEnd(span);\n }\n\n forceFlush() {\n return this.delegate.forceFlush();\n }\n\n shutdown() {\n this.drained = true;\n return this.delegate.shutdown();\n }\n}\n","import { Context } from '@opentelemetry/api';\nimport { BatchSpanProcessor, Span, SpanExporter } from '@opentelemetry/sdk-trace-base';\nimport { getTraceAttributes } from '../context/index.ts';\n\nexport class NodeSpanProcessor extends BatchSpanProcessor {\n constructor(exporter: SpanExporter) {\n super(exporter);\n }\n\n private applyTraceAttributes(span: Span) {\n const attributes = getTraceAttributes();\n for (const [key, value] of Object.entries(attributes)) {\n if (span.attributes[key] == null) {\n span.setAttribute(key, value as never);\n }\n }\n }\n\n onStart(span: Span, parentContext: Context) {\n this.applyTraceAttributes(span);\n super.onStart(span, parentContext);\n }\n\n onEnd(span: Span) {\n // Best effort: some instrumentations end spans with a stale context.\n // We temporarily re-open to append inherited attributes before export.\n (span as unknown as { _ended?: boolean })._ended = false;\n this.applyTraceAttributes(span);\n (span as unknown as { _ended?: boolean })._ended = true;\n super.onEnd(span);\n }\n}\n","import type { Context } from '@opentelemetry/api';\nimport { TraceFlags } from '@opentelemetry/api';\nimport type {\n ReadableSpan,\n Span,\n SpanProcessor,\n} from '@opentelemetry/sdk-trace-base';\nimport type { SpanTimeline } from './span-timeline.ts';\n\nexport class ProfilingSpanProcessor implements SpanProcessor {\n readonly #timeline: SpanTimeline;\n readonly #stack: Array<{ traceId: string; spanId: string } | undefined> = [];\n\n constructor(timeline: SpanTimeline) {\n this.#timeline = timeline;\n }\n\n onStart(span: Span, _parentContext: Context): void {\n const context = span.spanContext();\n const current =\n (context.traceFlags & TraceFlags.SAMPLED) === TraceFlags.SAMPLED\n ? { traceId: context.traceId, spanId: context.spanId }\n : undefined;\n this.#stack.push(current);\n this.#timeline.note(current);\n }\n\n onEnd(_span: ReadableSpan): void {\n this.#stack.pop();\n this.#timeline.note(this.#stack.at(-1));\n }\n\n forceFlush(): Promise<void> {\n return Promise.resolve();\n }\n\n shutdown(): Promise<void> {\n return Promise.resolve();\n }\n}\n","export interface TimelineSpan {\n readonly traceId: string;\n readonly spanId: string;\n}\n\nexport interface SpanEvents {\n readonly times: Float64Array;\n readonly spans: ReadonlyArray<TimelineSpan | undefined>;\n readonly length: number;\n readonly overflowed: boolean;\n}\n\nexport interface SpanTimeline {\n readonly note: (span: TimelineSpan | undefined) => void;\n readonly setRecording: (recording: boolean) => void;\n readonly drain: () => SpanEvents;\n}\n\nexport const SPAN_EVENT_CAPACITY = 1 << 17;\n\nexport const makeSpanTimeline = (\n options: { readonly capacity?: number; readonly now?: () => number } = {},\n): SpanTimeline => {\n const capacity = options.capacity ?? SPAN_EVENT_CAPACITY;\n const now = options.now ?? (() => performance.now());\n let times = new Float64Array(capacity);\n let spans: Array<TimelineSpan | undefined> = [];\n let length = 0;\n let overflowed = false;\n let recording = false;\n let current: TimelineSpan | undefined;\n\n const push = (span: TimelineSpan | undefined): void => {\n if (length >= capacity) {\n overflowed = true;\n return;\n }\n times[length] = now();\n spans[length] = span;\n length += 1;\n };\n\n return {\n note: (span) => {\n current = span;\n if (recording) push(span);\n },\n setRecording: (next) => {\n if (next && !recording && current !== undefined) push(current);\n recording = next;\n },\n drain: () => {\n const drained: SpanEvents = { times, spans, length, overflowed };\n times = new Float64Array(capacity);\n spans = [];\n length = 0;\n overflowed = false;\n if (recording && current !== undefined) push(current);\n return drained;\n },\n };\n};\n\nexport const spanAt = (\n events: SpanEvents,\n timeMs: number,\n): TimelineSpan | undefined => {\n if (\n events.length === 0 ||\n timeMs < (events.times[0] ?? Number.POSITIVE_INFINITY)\n ) {\n return undefined;\n }\n const last = events.length - 1;\n if (events.overflowed && timeMs > (events.times[last] ?? 0)) {\n return undefined;\n }\n let low = 0;\n let high = last;\n while (low < high) {\n const middle = (low + high + 1) >>> 1;\n if ((events.times[middle] ?? Number.POSITIVE_INFINITY) <= timeMs)\n low = middle;\n else high = middle - 1;\n }\n return events.spans[low];\n};\n","import type { SpanEvents } from './span-timeline.ts';\nimport { spanAt } from './span-timeline.ts';\n\nexport interface CpuProfile {\n readonly nodes: ReadonlyArray<{\n readonly id: number;\n readonly callFrame: {\n readonly functionName: string;\n readonly url: string;\n readonly lineNumber: number;\n };\n readonly children?: ReadonlyArray<number> | undefined;\n }>;\n readonly startTime: number;\n readonly samples?: ReadonlyArray<number> | undefined;\n readonly timeDeltas?: ReadonlyArray<number> | undefined;\n}\n\nexport interface EncodeCpuProfileOptions {\n readonly resource: unknown;\n readonly startedAtPerfMs: number;\n readonly startedAtEpochMs: number;\n readonly durationMs: number;\n readonly samplingIntervalMicros: number;\n readonly spanEvents?: SpanEvents | undefined;\n readonly profileId: string;\n}\n\nexport interface ProfilesExport {\n readonly resourceProfiles: ReadonlyArray<unknown>;\n readonly dictionary: unknown;\n}\n\nconst IDLE = '(idle)';\nconst ROOT = '(root)';\nconst FILE_SCHEME = 'file://';\n\nconst nanos = (epochMs: number): string =>\n (BigInt(Math.round(epochMs * 1000)) * 1000n).toString();\n\nclass Interner<T> {\n readonly table: Array<T>;\n readonly #index = new Map<string, number>();\n\n constructor(zero: T) {\n this.table = [zero];\n }\n\n intern(key: string, make: () => T): number {\n const existing = this.#index.get(key);\n if (existing !== undefined) return existing;\n const index = this.table.length;\n this.table.push(make());\n this.#index.set(key, index);\n return index;\n }\n}\n\ninterface Group {\n readonly nodeId: number;\n readonly linkIndex: number;\n valueNanos: number;\n firstEpochMs: number;\n}\n\nexport const encodeCpuProfile = (\n profile: CpuProfile,\n options: EncodeCpuProfileOptions,\n): ProfilesExport | undefined => {\n const samples = profile.samples ?? [];\n const deltas = profile.timeDeltas ?? [];\n const nodes = new Map(profile.nodes.map((node) => [node.id, node]));\n const parents = new Map<number, number>();\n for (const node of profile.nodes) {\n for (const child of node.children ?? []) parents.set(child, node.id);\n }\n\n const strings = new Interner<string>('');\n const string = (value: string): number =>\n value === '' ? 0 : strings.intern(value, () => value);\n const functions = new Interner<Record<string, number>>({});\n const locations = new Interner<Record<string, unknown>>({});\n const stacks = new Interner<Record<string, unknown>>({});\n const links = new Interner<Record<string, string>>({});\n\n const locationOf = (nodeId: number): number | undefined => {\n const frame = nodes.get(nodeId)?.callFrame;\n if (frame === undefined || frame.functionName === ROOT) return undefined;\n const file = frame.url.startsWith(FILE_SCHEME)\n ? frame.url.slice(FILE_SCHEME.length)\n : frame.url;\n const line = frame.lineNumber >= 0 ? frame.lineNumber + 1 : 0;\n const key = `${frame.functionName}\\u0000${file}\\u0000${line}`;\n return locations.intern(key, () => ({\n lines: [\n {\n functionIndex: functions.intern(key, () => ({\n nameStrindex: string(\n frame.functionName === '' ? '(anonymous)' : frame.functionName,\n ),\n filenameStrindex: string(file),\n startLine: line,\n })),\n line,\n },\n ],\n }));\n };\n\n const stackOf = (nodeId: number): number =>\n stacks.intern(String(nodeId), () => {\n const locationIndices: Array<number> = [];\n for (\n let current: number | undefined = nodeId;\n current !== undefined;\n current = parents.get(current)\n ) {\n const location = locationOf(current);\n if (location !== undefined) locationIndices.push(location);\n }\n return { locationIndices };\n });\n\n const maxSampleMicros = options.samplingIntervalMicros;\n const groups = new Map<string, Group>();\n let elapsedMicros = 0;\n for (let index = 0; index < samples.length; index++) {\n elapsedMicros += deltas[index] ?? 0;\n const nodeId = samples[index];\n if (\n nodeId === undefined ||\n nodes.get(nodeId)?.callFrame.functionName === IDLE\n ) {\n continue;\n }\n const valueMicros = Math.min(\n Math.max(deltas[index + 1] ?? options.samplingIntervalMicros, 0),\n maxSampleMicros,\n );\n const offsetMs = elapsedMicros / 1000;\n const span =\n options.spanEvents === undefined\n ? undefined\n : spanAt(options.spanEvents, options.startedAtPerfMs + offsetMs);\n const linkIndex =\n span === undefined\n ? 0\n : links.intern(span.spanId, () => ({\n traceId: span.traceId,\n spanId: span.spanId,\n }));\n const key = `${nodeId}|${linkIndex}`;\n const group = groups.get(key);\n if (group === undefined) {\n groups.set(key, {\n nodeId,\n linkIndex,\n valueNanos: valueMicros * 1000,\n firstEpochMs: options.startedAtEpochMs + offsetMs,\n });\n } else {\n group.valueNanos += valueMicros * 1000;\n }\n }\n if (groups.size === 0) return undefined;\n\n const cpu = {\n typeStrindex: string('cpu'),\n unitStrindex: string('nanoseconds'),\n };\n const profileSamples = [...groups.values()].map((group) => ({\n stackIndex: stackOf(group.nodeId),\n linkIndex: group.linkIndex,\n values: [String(group.valueNanos)],\n timestampsUnixNano: [nanos(group.firstEpochMs)],\n }));\n\n return {\n resourceProfiles: [\n {\n resource: options.resource,\n scopeProfiles: [\n {\n scope: { name: '@safaricom-mxl/node-sdk/profiling' },\n profiles: [\n {\n sampleType: cpu,\n samples: profileSamples,\n timeUnixNano: nanos(options.startedAtEpochMs),\n durationNano: String(\n Math.round(options.durationMs * 1_000_000),\n ),\n periodType: cpu,\n period: String(options.samplingIntervalMicros * 1000),\n profileId: options.profileId,\n },\n ],\n },\n ],\n },\n ],\n dictionary: {\n mappingTable: [{}],\n locationTable: locations.table,\n functionTable: functions.table,\n linkTable: links.table,\n stringTable: strings.table,\n attributeTable: [{}],\n stackTable: stacks.table,\n },\n };\n};\n","import { Session } from 'node:inspector';\nimport { diag } from '@opentelemetry/api';\nimport type { CpuProfile } from './cpu-profile.ts';\nimport { encodeCpuProfile } from './cpu-profile.ts';\nimport type { SpanTimeline } from './span-timeline.ts';\nimport { SPAN_EVENT_CAPACITY } from './span-timeline.ts';\n\nexport interface ProfilingOptions {\n readonly window?: number | undefined;\n readonly samplingIntervalMicros?: number | undefined;\n readonly linkSpans?: boolean | undefined;\n}\n\nexport const DEFAULT_PROFILE_WINDOW_MS = 60_000;\nconst MIN_PROFILE_WINDOW_MS = 1_000;\nconst MIN_SAMPLING_INTERVAL_MICROS = 100;\nexport const DEFAULT_SAMPLING_INTERVAL_MICROS = 10_000;\nexport const PROFILER_SETUP_TIMEOUT_MS = 5_000;\nexport const PROFILER_COMMAND_TIMEOUT_MS = 5_000;\nconst EXPORT_TIMEOUT_MS = 10_000;\nexport const PROFILES_PATH = '/v1development/profiles';\n\nexport interface CpuProfilerOptions {\n readonly baseUrl: string;\n readonly resource: unknown;\n readonly headers?: Record<string, string> | undefined;\n readonly profiling: ProfilingOptions;\n readonly timeline?: SpanTimeline | undefined;\n readonly shutdownTimeoutMs?: number | undefined;\n}\n\nexport interface CpuProfilerHandle {\n readonly stop: () => Promise<void>;\n}\n\ninterface InspectorReply {\n readonly profile?: CpuProfile;\n}\n\nconst profileWindowMs = (window: number | undefined): number =>\n Math.max(\n MIN_PROFILE_WINDOW_MS,\n window === undefined || !Number.isFinite(window) || window <= 0\n ? DEFAULT_PROFILE_WINDOW_MS\n : window,\n );\n\nconst samplingIntervalOf = (micros: number | undefined): number =>\n micros === undefined || !Number.isFinite(micros) || micros <= 0\n ? DEFAULT_SAMPLING_INTERVAL_MICROS\n : Math.max(MIN_SAMPLING_INTERVAL_MICROS, Math.round(micros));\n\nconst post = (\n session: Session,\n method: string,\n params: Record<string, unknown>,\n timeoutMs: number,\n): Promise<InspectorReply | undefined> =>\n new Promise((resolve, reject) => {\n let settled = false;\n const timer = setTimeout(() => {\n if (settled) return;\n settled = true;\n reject(new Error(`${method} got no answer within ${timeoutMs} ms`));\n }, timeoutMs);\n session.post(method, params, (error, reply) => {\n if (settled) return;\n settled = true;\n clearTimeout(timer);\n if (error) reject(error);\n else resolve(reply as InspectorReply | undefined);\n });\n });\n\nconst randomHex = (bytes: number): string =>\n Buffer.from(crypto.getRandomValues(new Uint8Array(bytes))).toString('hex');\n\nconst withTimeout = <T>(promise: Promise<T>, ms: number, message: string) => {\n const timeout = new Promise<never>((_, reject) => {\n setTimeout(() => reject(new Error(message)), ms);\n });\n return Promise.race([promise, timeout]);\n};\n\nlet profilerHolders = 0;\n\nexport const startCpuProfiler = (\n options: CpuProfilerOptions,\n): CpuProfilerHandle => {\n profilerHolders += 1;\n if (profilerHolders > 1) {\n return {\n stop: async () => {\n profilerHolders = Math.max(0, profilerHolders - 1);\n },\n };\n }\n\n let stopped = false;\n let loop: Promise<void> | undefined;\n let session: Session | undefined;\n const windowMs = profileWindowMs(options.profiling.window);\n const samplingIntervalMicros = samplingIntervalOf(\n options.profiling.samplingIntervalMicros,\n );\n const url = `${options.baseUrl.replace(/\\/$/, '')}${PROFILES_PATH}`;\n let overflowWarned = false;\n\n const send = async (body: unknown) => {\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), EXPORT_TIMEOUT_MS);\n try {\n const response = await fetch(url, {\n method: 'POST',\n headers: {\n 'content-type': 'application/json',\n 'OTLP-Profiles-Development-Version': '1',\n ...options.headers,\n },\n body: JSON.stringify(body),\n signal: controller.signal,\n });\n await response.arrayBuffer();\n } finally {\n clearTimeout(timer);\n }\n };\n\n const run = async () => {\n const inspectorSession = new Session();\n session = inspectorSession;\n inspectorSession.connect();\n const command = (method: string, params: Record<string, unknown> = {}) =>\n post(inspectorSession, method, params, PROFILER_COMMAND_TIMEOUT_MS);\n await withTimeout(\n command('Profiler.enable'),\n PROFILER_SETUP_TIMEOUT_MS,\n 'the inspector did not answer',\n );\n await withTimeout(\n command('Profiler.setSamplingInterval', {\n interval: samplingIntervalMicros,\n }),\n PROFILER_SETUP_TIMEOUT_MS,\n 'the inspector did not answer',\n );\n\n const startWindow = async () => {\n const started = {\n startedAtPerfMs: performance.now(),\n startedAtEpochMs: Date.now(),\n };\n await command('Profiler.start');\n return started;\n };\n\n options.timeline?.setRecording(true);\n let current = await startWindow();\n\n const exportWindow = async (\n started: { startedAtPerfMs: number; startedAtEpochMs: number },\n reply: InspectorReply | undefined,\n spanEvents: ReturnType<SpanTimeline['drain']> | undefined,\n ) => {\n if (spanEvents?.overflowed === true && !overflowWarned) {\n overflowWarned = true;\n diag.warn(\n `@safaricom-mxl/node-sdk: more than ${SPAN_EVENT_CAPACITY} span switches in one window; later samples in it are not linked to spans`,\n );\n }\n const profile = reply?.profile;\n if (profile === undefined) return;\n const body = encodeCpuProfile(profile, {\n resource: options.resource,\n ...started,\n durationMs: performance.now() - started.startedAtPerfMs,\n samplingIntervalMicros,\n spanEvents,\n profileId: randomHex(16),\n });\n if (body !== undefined) await send(body);\n };\n\n while (!stopped) {\n await new Promise((resolve) => setTimeout(resolve, windowMs));\n if (stopped) break;\n const ended = current;\n const reply = await command('Profiler.stop');\n const spanEvents = options.timeline?.drain();\n current = await startWindow();\n await exportWindow(ended, reply, spanEvents).catch((error: unknown) => {\n diag.warn('@safaricom-mxl/node-sdk: profile export failed', error);\n });\n }\n\n const last = await command('Profiler.stop').catch(() => undefined);\n await exportWindow(current, last, options.timeline?.drain()).catch(\n (error: unknown) => {\n diag.warn(\n '@safaricom-mxl/node-sdk: final profile export skipped',\n error,\n );\n },\n );\n };\n\n loop = run().catch((error: unknown) => {\n options.timeline?.setRecording(false);\n diag.warn(\n '@safaricom-mxl/node-sdk: profiling is off: this runtime has no CPU profiler the SDK can drive',\n error,\n );\n });\n\n return {\n stop: async () => {\n stopped = true;\n options.timeline?.setRecording(false);\n profilerHolders = Math.max(0, profilerHolders - 1);\n const timeout = options.shutdownTimeoutMs ?? 3_000;\n await Promise.race([\n loop ?? Promise.resolve(),\n new Promise((resolve) => setTimeout(resolve, timeout)),\n ]);\n try {\n session?.disconnect();\n } catch {\n // Session already closed.\n }\n },\n };\n};\n\nexport const normalizeProfiling = (\n profiling: boolean | ProfilingOptions | undefined,\n): ProfilingOptions | undefined => {\n if (profiling === true) return {};\n if (profiling === false || profiling === undefined) return undefined;\n return profiling;\n};\n","import { resourceFromAttributes, defaultServiceName } from '@opentelemetry/resources';\nimport {\n ATTR_SERVICE_NAME,\n ATTR_SERVICE_VERSION,\n ATTR_TELEMETRY_SDK_NAME,\n ATTR_TELEMETRY_SDK_VERSION,\n} from '@opentelemetry/semantic-conventions';\nimport { NODE_SDK_NAME, NODE_SDK_VERSION } from '../constants/index.ts';\nimport type { ResolvedSDKConfig } from '../sdk/types.ts';\n\nexport function createNodeSdkResource(config: ResolvedSDKConfig) {\n return resourceFromAttributes({\n [ATTR_SERVICE_NAME]: config.serviceName || defaultServiceName(),\n [ATTR_SERVICE_VERSION]: process.env.VERCEL_DEPLOYMENT_ID ?? process.env.npm_package_version,\n [ATTR_TELEMETRY_SDK_NAME]: NODE_SDK_NAME,\n [ATTR_TELEMETRY_SDK_VERSION]: NODE_SDK_VERSION,\n 'telemetry.distro.name': 'mxl-node-sdk',\n 'telemetry.distro.version': NODE_SDK_VERSION,\n ...config.additionalResourceAttributes,\n });\n}\n","import {\n DEFAULT_ADVANCED_NETWORK_CAPTURE,\n DEFAULT_BETA_MODE,\n DEFAULT_CAPTURE_BODY_KEYWORDS_FILTER,\n DEFAULT_CAPTURE_HEADERS_CLIENT_REQUEST,\n DEFAULT_CAPTURE_HEADERS_CLIENT_RESPONSE,\n DEFAULT_CAPTURE_HEADERS_SERVER_REQUEST,\n DEFAULT_CAPTURE_HEADERS_SERVER_RESPONSE,\n DEFAULT_CONSOLE_CAPTURE,\n DEFAULT_EXCEPTION_CAPTURE_ENABLED,\n DEFAULT_OTLP_PROTOCOL,\n DEFAULT_SENTRY_INTEGRATION_ENABLED,\n DEFAULT_SERVICE_NAME,\n DEFAULT_STARTUP_LOGS_ENABLED,\n DEFAULT_STOP_ON_TERMINATION_SIGNALS,\n DEFAULT_TRACE_SAMPLER,\n DEFAULT_TRACE_SAMPLER_ARG,\n} from '../constants/index.ts';\nimport {\n getBooleanFromEnv,\n getStringFromEnv,\n parseHeaderAttributeMap,\n} from '../utils/env.ts';\nimport type { ResolvedSDKConfig, SDKConfig } from './types.ts';\n\nexport function resolveSDKConfig(config: SDKConfig = {}): ResolvedSDKConfig {\n return {\n additionalInstrumentations: config.additionalInstrumentations ?? [],\n additionalResourceAttributes: config.additionalResourceAttributes ?? {},\n advancedNetworkCapture:\n config.advancedNetworkCapture ??\n getBooleanFromEnv('MXL_NODE_ADVANCED_NETWORK_CAPTURE') ??\n DEFAULT_ADVANCED_NETWORK_CAPTURE,\n apiKey: config.apiKey ?? getStringFromEnv('MXL_API_KEY'),\n betaMode:\n config.betaMode ??\n getBooleanFromEnv('MXL_NODE_BETA_MODE') ??\n DEFAULT_BETA_MODE,\n captureBodyKeywordsFilter:\n config.captureBodyKeywordsFilter ??\n getStringFromEnv(\n 'OTEL_INSTRUMENTATION_HTTP_CAPTURE_BODY_KEYWORDS_FILTER',\n ) ??\n DEFAULT_CAPTURE_BODY_KEYWORDS_FILTER,\n captureHeadersClientRequest:\n config.captureHeadersClientRequest ??\n getStringFromEnv(\n 'OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_CLIENT_REQUEST',\n ) ??\n DEFAULT_CAPTURE_HEADERS_CLIENT_REQUEST,\n captureHeadersClientResponse:\n config.captureHeadersClientResponse ??\n getStringFromEnv(\n 'OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_CLIENT_RESPONSE',\n ) ??\n DEFAULT_CAPTURE_HEADERS_CLIENT_RESPONSE,\n captureHeadersServerRequest:\n config.captureHeadersServerRequest ??\n getStringFromEnv(\n 'OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SERVER_REQUEST',\n ) ??\n DEFAULT_CAPTURE_HEADERS_SERVER_REQUEST,\n captureHeadersServerResponse:\n config.captureHeadersServerResponse ??\n getStringFromEnv(\n 'OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SERVER_RESPONSE',\n ) ??\n DEFAULT_CAPTURE_HEADERS_SERVER_RESPONSE,\n consoleCapture:\n config.consoleCapture ??\n getBooleanFromEnv('MXL_NODE_CONSOLE_CAPTURE') ??\n DEFAULT_CONSOLE_CAPTURE,\n contextManager: config.contextManager,\n detectResources: config.detectResources ?? true,\n disableLogs:\n config.disableLogs ?? getStringFromEnv('OTEL_LOGS_EXPORTER') === 'none',\n disableMetrics:\n config.disableMetrics ??\n getStringFromEnv('OTEL_METRICS_EXPORTER') === 'none',\n disableStartupLogs:\n config.disableStartupLogs ??\n !(getBooleanFromEnv('MXL_STARTUP_LOGS') ?? DEFAULT_STARTUP_LOGS_ENABLED),\n disableTracing:\n config.disableTracing ??\n getStringFromEnv('OTEL_TRACES_EXPORTER') === 'none',\n exceptionCaptureEnabled:\n config.exceptionCaptureEnabled ??\n getBooleanFromEnv('MXL_NODE_EXPERIMENTAL_EXCEPTION_CAPTURE') ??\n DEFAULT_EXCEPTION_CAPTURE_ENABLED,\n headerAttributeMap:\n config.headerAttributeMap ??\n parseHeaderAttributeMap(\n getStringFromEnv('MXL_NODE_ROOT_SPAN_HEADER_ATTRIBUTES'),\n ),\n instrumentations: config.instrumentations,\n metricReader: config.metricReader,\n otlpEndpoint:\n config.otlpEndpoint ?? getStringFromEnv('OTEL_EXPORTER_OTLP_ENDPOINT'),\n otlpHeaders:\n config.otlpHeaders ?? getStringFromEnv('OTEL_EXPORTER_OTLP_HEADERS'),\n otlpProtocol:\n config.otlpProtocol ??\n (getStringFromEnv('OTEL_EXPORTER_OTLP_PROTOCOL') as\n | ResolvedSDKConfig['otlpProtocol']\n | undefined) ??\n DEFAULT_OTLP_PROTOCOL,\n profiling: config.profiling,\n sentryIntegrationEnabled:\n config.sentryIntegrationEnabled ??\n getBooleanFromEnv('MXL_NODE_SENTRY_INTEGRATION_ENABLED') ??\n DEFAULT_SENTRY_INTEGRATION_ENABLED,\n serviceName:\n config.serviceName ??\n getStringFromEnv('OTEL_SERVICE_NAME') ??\n DEFAULT_SERVICE_NAME,\n spanLimits: config.spanLimits,\n spanProcessors: config.spanProcessors ?? [],\n stopOnTerminationSignals:\n config.stopOnTerminationSignals ??\n getBooleanFromEnv('MXL_NODE_STOP_ON_TERMINATION_SIGNALS') ??\n DEFAULT_STOP_ON_TERMINATION_SIGNALS,\n traceExporterUrl:\n config.traceExporterUrl ??\n getStringFromEnv('OTEL_EXPORTER_OTLP_TRACES_ENDPOINT'),\n traceSampler:\n config.traceSampler ??\n (getStringFromEnv(\n 'OTEL_TRACES_SAMPLER',\n ) as ResolvedSDKConfig['traceSampler']) ??\n DEFAULT_TRACE_SAMPLER,\n traceSamplerArg:\n config.traceSamplerArg ??\n getStringFromEnv('OTEL_TRACES_SAMPLER_ARG') ??\n DEFAULT_TRACE_SAMPLER_ARG,\n };\n}\n","import { diag } from '@opentelemetry/api';\nimport {\n AlwaysOffSampler,\n AlwaysOnSampler,\n ParentBasedSampler,\n TraceIdRatioBasedSampler,\n} from '@opentelemetry/sdk-trace-base';\nimport type { Sampler } from '@opentelemetry/sdk-trace-base';\nimport type { TraceSamplerName } from './types.ts';\n\nconst DEFAULT_RATIO = 1;\n\nexport function resolveTraceSampler(\n traceSampler: TraceSamplerName | Sampler,\n traceSamplerArg: string,\n): Sampler {\n if (typeof traceSampler !== 'string') {\n return traceSampler;\n }\n\n switch (traceSampler) {\n case 'always_on':\n return new AlwaysOnSampler();\n case 'always_off':\n return new AlwaysOffSampler();\n case 'parentbased_always_on':\n return new ParentBasedSampler({ root: new AlwaysOnSampler() });\n case 'parentbased_always_off':\n return new ParentBasedSampler({ root: new AlwaysOffSampler() });\n case 'traceidratio':\n return new TraceIdRatioBasedSampler(resolveSamplerRatio(traceSamplerArg));\n case 'parentbased_traceidratio':\n return new ParentBasedSampler({\n root: new TraceIdRatioBasedSampler(resolveSamplerRatio(traceSamplerArg)),\n });\n default:\n diag.error(\n `@safaricom-mxl/node-sdk: unknown sampler \"${traceSampler}\", defaulting to always_on`,\n );\n return new AlwaysOnSampler();\n }\n}\n\nfunction resolveSamplerRatio(arg: string): number {\n const parsed = Number(arg);\n if (!Number.isFinite(parsed) || parsed < 0 || parsed > 1) {\n return DEFAULT_RATIO;\n }\n return parsed;\n}\n","import type { ResolvedSDKConfig } from './types.ts';\n\nlet activeConfig: ResolvedSDKConfig | undefined;\n\nexport function setActiveSDKConfig(config: ResolvedSDKConfig | undefined) {\n activeConfig = config;\n}\n\nexport function getActiveSDKConfig() {\n return activeConfig;\n}\n","import { diag } from '@opentelemetry/api';\nimport type { InstrumentationConfigMap } from '@opentelemetry/auto-instrumentations-node';\nimport { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';\nimport { RuntimeNodeInstrumentation } from '@opentelemetry/instrumentation-runtime-node';\nimport { NodeSDK } from '@opentelemetry/sdk-node';\nimport {\n MutableAsyncLocalStorageContextManager,\n setMutableContextManager,\n setTraceAttributes,\n} from '../context/index.ts';\nimport { createMetricReader, createTraceExporter } from '../exporters/index.ts';\nimport { resolveOtlpExporterUrl } from '../exporters/urls.ts';\nimport { createSentryBridge } from '../instrumentations/exceptions/sentry.ts';\nimport {\n ConsoleInstrumentation,\n ExceptionInstrumentation,\n getAdvancedHttpInstrumentationConfig,\n} from '../instrumentations/index.ts';\nimport { OTelLogger } from '../logger/otelLogger.ts';\nimport {\n CompositeSpanProcessor,\n FilterWhenDrainedSpanProcessor,\n NodeSpanProcessor,\n} from '../processors/index.ts';\nimport { ProfilingSpanProcessor } from '../profiling/ProfilingSpanProcessor.ts';\nimport type { CpuProfilerHandle } from '../profiling/profiling.ts';\nimport {\n normalizeProfiling,\n startCpuProfiler,\n} from '../profiling/profiling.ts';\nimport { makeSpanTimeline } from '../profiling/span-timeline.ts';\nimport { createNodeSdkResource } from '../resources/index.ts';\nimport { parseOtlpHeaders } from '../utils/env.ts';\nimport { resolveSDKConfig } from './config.ts';\nimport { resolveTraceSampler } from './sampler.ts';\nimport { setActiveSDKConfig } from './state.ts';\nimport type { SDKConfig, SDKControl } from './types.ts';\n\nlet sdk: NodeSDK | undefined;\nlet logger: OTelLogger | undefined;\nlet contextManager: MutableAsyncLocalStorageContextManager | undefined;\nlet drainableSpanProcessor: FilterWhenDrainedSpanProcessor | undefined;\nlet cpuProfiler: CpuProfilerHandle | undefined;\nlet signalHandlersRegistered = false;\n\nconst terminationHandlers: Array<[NodeJS.Signals, () => void]> = [];\n\nexport function initSDK(config: SDKConfig = {}): SDKControl {\n const resolved = resolveSDKConfig(config);\n setActiveSDKConfig(resolved);\n\n if (sdk) {\n return getControl();\n }\n\n if (!resolved.disableStartupLogs) {\n diag.info('@safaricom-mxl/node-sdk: initializing');\n }\n\n contextManager =\n resolved.contextManager instanceof MutableAsyncLocalStorageContextManager\n ? resolved.contextManager\n : new MutableAsyncLocalStorageContextManager();\n setMutableContextManager(contextManager);\n\n const autoInstrumentationConfig: InstrumentationConfigMap = {\n '@opentelemetry/instrumentation-http': resolved.advancedNetworkCapture\n ? getAdvancedHttpInstrumentationConfig({\n captureBodyKeywordsFilter: resolved.captureBodyKeywordsFilter,\n captureHeadersClientRequest: resolved.captureHeadersClientRequest,\n captureHeadersClientResponse: resolved.captureHeadersClientResponse,\n captureHeadersServerRequest: resolved.captureHeadersServerRequest,\n captureHeadersServerResponse: resolved.captureHeadersServerResponse,\n headerAttributeMap: resolved.headerAttributeMap,\n })\n : { enabled: true },\n '@opentelemetry/instrumentation-fs': { enabled: false },\n ...(resolved.instrumentations ?? {}),\n };\n\n logger = new OTelLogger({ config: resolved });\n const traceExporter = createTraceExporter(resolved);\n const traceProcessor = new NodeSpanProcessor(traceExporter as never);\n const profiling = normalizeProfiling(resolved.profiling);\n const timeline =\n profiling !== undefined &&\n profiling.linkSpans !== false &&\n !resolved.disableTracing\n ? makeSpanTimeline()\n : undefined;\n const spanProcessors = resolved.disableTracing\n ? []\n : [\n (drainableSpanProcessor = new FilterWhenDrainedSpanProcessor(\n new CompositeSpanProcessor([\n traceProcessor,\n ...resolved.spanProcessors,\n ...(timeline === undefined\n ? []\n : [new ProfilingSpanProcessor(timeline)]),\n ]),\n )),\n ];\n\n const instrumentations = [\n ...getNodeAutoInstrumentations(autoInstrumentationConfig),\n new RuntimeNodeInstrumentation(),\n ...(resolved.consoleCapture\n ? [new ConsoleInstrumentation({ config: resolved })]\n : []),\n ...(resolved.exceptionCaptureEnabled\n ? [\n new ExceptionInstrumentation({\n forceFlush,\n captureExceptionHook: createSentryBridge(\n resolved.sentryIntegrationEnabled,\n )?.captureException,\n }),\n ]\n : []),\n ...resolved.additionalInstrumentations,\n ];\n\n sdk = new NodeSDK({\n resource: createNodeSdkResource(resolved),\n contextManager,\n instrumentations,\n metricReaders: resolved.disableMetrics\n ? undefined\n : [resolved.metricReader ?? createMetricReader(resolved)],\n logRecordProcessors: resolved.disableLogs ? [] : [logger.getProcessor()],\n spanProcessors,\n sampler: resolveTraceSampler(\n resolved.traceSampler,\n resolved.traceSamplerArg,\n ),\n spanLimits: resolved.spanLimits,\n } as unknown as ConstructorParameters<typeof NodeSDK>[0]);\n\n sdk.start();\n logger.setGlobalProvider();\n\n if (profiling !== undefined) {\n const tracesUrl = resolveOtlpExporterUrl({\n kind: 'trace',\n endpoint: resolved.otlpEndpoint,\n explicitUrl: resolved.traceExporterUrl,\n });\n cpuProfiler = startCpuProfiler({\n baseUrl: tracesUrl.replace(/\\/v1\\/traces\\/?$/, ''),\n resource: {\n attributes: [\n { key: 'service.name', value: { stringValue: resolved.serviceName } },\n ],\n },\n headers: parseOtlpHeaders(resolved.otlpHeaders),\n profiling,\n timeline,\n });\n }\n\n if (resolved.stopOnTerminationSignals && !signalHandlersRegistered) {\n registerTerminationHandlers();\n }\n\n if (!resolved.disableStartupLogs) {\n diag.info('@safaricom-mxl/node-sdk: initialized');\n }\n\n return getControl();\n}\n\nfunction registerTerminationHandlers() {\n const createTerminationHandler = (signal: NodeJS.Signals) => {\n return () => {\n diag.debug(`@safaricom-mxl/node-sdk: ${signal} received`);\n void shutdown().finally(() => {\n process.exit();\n });\n };\n };\n\n const sigterm = createTerminationHandler('SIGTERM');\n const sigint = createTerminationHandler('SIGINT');\n\n terminationHandlers.push(['SIGTERM', sigterm], ['SIGINT', sigint]);\n process.on('SIGTERM', sigterm);\n process.on('SIGINT', sigint);\n signalHandlersRegistered = true;\n}\n\nexport async function forceFlush() {\n await Promise.all([\n logger?.forceFlush(),\n // The tracer and meter providers are intentionally accessed through the NodeSDK internals.\n // This keeps the flush API small while still forcing all active signals to drain.\n (sdk as any)?._tracerProvider?.forceFlush?.(),\n (sdk as any)?._loggerProvider?.forceFlush?.(),\n (sdk as any)?._meterProvider?.forceFlush?.(),\n ]);\n}\n\nexport function getInitializedOTelLogger() {\n return logger;\n}\n\nexport async function shutdown() {\n if (signalHandlersRegistered) {\n for (const [signal, handler] of terminationHandlers) {\n process.off(signal, handler);\n }\n terminationHandlers.length = 0;\n signalHandlersRegistered = false;\n }\n\n drainableSpanProcessor?.drain();\n await cpuProfiler?.stop();\n cpuProfiler = undefined;\n await Promise.allSettled([logger?.shutdown(), sdk?.shutdown()]);\n sdk = undefined;\n logger = undefined;\n drainableSpanProcessor = undefined;\n setMutableContextManager(undefined);\n setActiveSDKConfig(undefined);\n}\n\nfunction getControl(): SDKControl {\n return {\n forceFlush,\n shutdown,\n setTraceAttributes,\n };\n}\n"],"mapp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AA,CAAS;CAClC,mBAAmB,KAAA,CAAS;AAC9B;AAEA,SAAS,aAAyB;CAChC,OAAO;EACL;EACA;EACA;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"initSDK-DJtki_L0.mjs","names":["OTLPMetricExporterGRPC","OTLPMetricExporterHTTP","OTLPTraceExporterGRPC","OTLPTraceExporterHTTP"],"sources":["../src/context/AbstractAsyncHooksContextManager.ts","../src/context/MutableAsyncLocalStorageContextManager.ts","../src/context/contextManager.ts","../src/exporters/metricReader.ts","../src/exporters/traceExporter.ts","../src/instrumentations/exceptions/sentry.ts","../src/instrumentations/console.ts","../src/instrumentations/exceptions/ExceptionInstrumentation.ts","../src/instrumentations/http.ts","../src/processors/CompositeSpanProcessor.ts","../src/processors/FilterWhenDrainedSpanProcessor.ts","../src/processors/NodeSpanProcessor.ts","../src/profiling/ProfilingSpanProcessor.ts","../src/profiling/span-timeline.ts","../src/profiling/cpu-profile.ts","../src/profiling/profiling.ts","../src/resources/nodeSdkResource.ts","../src/sdk/config.ts","../src/sdk/sampler.ts","../src/sdk/state.ts","../src/sdk/initSDK.ts"],"sourcesContent":["/* eslint-disable */\nimport { Context, ContextManager } from '@opentelemetry/api';\nimport { EventEmitter } from 'node:events';\n\ntype Func<T = unknown> = (...args: unknown[]) => T;\n\ninterface PatchMap {\n [name: string]: WeakMap<Func, Func>;\n}\n\nconst ADD_LISTENER_METHODS = [\n 'addListener' as const,\n 'on' as const,\n 'once' as const,\n 'prependListener' as const,\n 'prependOnceListener' as const,\n];\n\nexport abstract class AbstractAsyncHooksContextManager\n implements ContextManager\n{\n abstract active(): Context;\n\n abstract with<A extends unknown[], F extends (...args: A) => ReturnType<F>>(\n context: Context,\n fn: F,\n thisArg?: ThisParameterType<F>,\n ...args: A\n ): ReturnType<F>;\n\n abstract enable(): this;\n\n abstract disable(): this;\n\n bind<T>(context: Context, target: T): T {\n if (target instanceof EventEmitter) {\n return this._bindEventEmitter(context, target);\n }\n if (typeof target === 'function') {\n return this._bindFunction(context, target);\n }\n return target;\n }\n\n private _bindFunction<T extends Function>(context: Context, target: T): T {\n const manager = this;\n const contextWrapper = function (this: never, ...args: unknown[]) {\n return manager.with(context, () => target.apply(this, args));\n };\n Object.defineProperty(contextWrapper, 'length', {\n enumerable: false,\n configurable: true,\n writable: false,\n value: target.length,\n });\n return contextWrapper as never;\n }\n\n private _bindEventEmitter<T extends EventEmitter>(\n context: Context,\n ee: T,\n ): T {\n const map = this._getPatchMap(ee);\n if (map !== undefined) {\n return ee;\n }\n this._createPatchMap(ee);\n\n ADD_LISTENER_METHODS.forEach((methodName) => {\n if (ee[methodName] === undefined) {\n return;\n }\n ee[methodName] = this._patchAddListener(ee, ee[methodName], context);\n });\n if (typeof ee.removeListener === 'function') {\n ee.removeListener = this._patchRemoveListener(ee, ee.removeListener);\n }\n if (typeof ee.off === 'function') {\n ee.off = this._patchRemoveListener(ee, ee.off);\n }\n if (typeof ee.removeAllListeners === 'function') {\n ee.removeAllListeners = this._patchRemoveAllListeners(\n ee,\n ee.removeAllListeners,\n );\n }\n return ee;\n }\n\n private _patchRemoveListener(ee: EventEmitter, original: Function) {\n const contextManager = this;\n return function (this: never, event: string, listener: Func) {\n const events = contextManager._getPatchMap(ee)?.[event];\n if (events === undefined) {\n return original.call(this, event, listener);\n }\n const patchedListener = events.get(listener);\n return original.call(this, event, patchedListener || listener);\n };\n }\n\n private _patchRemoveAllListeners(ee: EventEmitter, original: Function) {\n const contextManager = this;\n return function (this: never, event: string) {\n const map = contextManager._getPatchMap(ee);\n if (map !== undefined) {\n if (arguments.length === 0) {\n contextManager._createPatchMap(ee);\n } else if (map[event] !== undefined) {\n delete map[event];\n }\n }\n return original.apply(this, arguments);\n };\n }\n\n private _patchAddListener(\n ee: EventEmitter,\n original: Function,\n context: Context,\n ) {\n const contextManager = this;\n return function (this: never, event: string, listener: Func) {\n if (contextManager._wrapped) {\n return original.call(this, event, listener);\n }\n let map = contextManager._getPatchMap(ee);\n if (map === undefined) {\n map = contextManager._createPatchMap(ee);\n }\n let listeners = map[event];\n if (listeners === undefined) {\n listeners = new WeakMap();\n map[event] = listeners;\n }\n const patchedListener = contextManager.bind(context, listener);\n listeners.set(listener, patchedListener);\n contextManager._wrapped = true;\n try {\n return original.call(this, event, patchedListener);\n } finally {\n contextManager._wrapped = false;\n }\n };\n }\n\n private _createPatchMap(ee: EventEmitter): PatchMap {\n const map = Object.create(null) as PatchMap;\n (ee as any)[this._kOtListeners] = map;\n return map;\n }\n\n private _getPatchMap(ee: EventEmitter): PatchMap | undefined {\n return (ee as never)[this._kOtListeners];\n }\n\n private readonly _kOtListeners = Symbol('OtListeners');\n private _wrapped = false;\n}\n","import { Context, ROOT_CONTEXT } from '@opentelemetry/api';\nimport { AsyncLocalStorage } from 'node:async_hooks';\nimport { AbstractAsyncHooksContextManager } from './AbstractAsyncHooksContextManager.ts';\n\nexport type MutableContextStore = {\n context?: Context;\n mutableContext?: {\n traceAttributes: Map<string, unknown>;\n };\n};\n\nexport class MutableAsyncLocalStorageContextManager extends AbstractAsyncHooksContextManager {\n private readonly asyncLocalStorage: AsyncLocalStorage<MutableContextStore>;\n\n constructor() {\n super();\n this.asyncLocalStorage = new AsyncLocalStorage<MutableContextStore>();\n }\n\n active(): Context {\n return this.asyncLocalStorage.getStore()?.context ?? ROOT_CONTEXT;\n }\n\n with<A extends unknown[], F extends (...args: A) => ReturnType<F>>(\n context: Context,\n fn: F,\n thisArg?: ThisParameterType<F>,\n ...args: A\n ): ReturnType<F> {\n const mutableContext = this.asyncLocalStorage.getStore()?.mutableContext ?? {\n traceAttributes: new Map<string, unknown>(),\n };\n const callback = thisArg == null ? fn : fn.bind(thisArg);\n return this.asyncLocalStorage.run(\n { context, mutableContext },\n callback as never,\n ...args,\n );\n }\n\n getMutableContext() {\n return this.asyncLocalStorage.getStore()?.mutableContext;\n }\n\n enable(): this {\n return this;\n }\n\n disable(): this {\n this.asyncLocalStorage.disable();\n return this;\n }\n}\n","import { Attributes } from '@opentelemetry/api';\nimport { MutableAsyncLocalStorageContextManager } from './MutableAsyncLocalStorageContextManager.ts';\n\nlet mutableContextManager: MutableAsyncLocalStorageContextManager | undefined;\n\nexport function setMutableContextManager(\n manager: MutableAsyncLocalStorageContextManager | undefined,\n) {\n mutableContextManager = manager;\n}\n\nexport function getMutableContextManager() {\n return mutableContextManager;\n}\n\nexport function setTraceAttributes(attributes: Attributes) {\n const mutableContext = mutableContextManager?.getMutableContext();\n if (!mutableContext) {\n return;\n }\n for (const [key, value] of Object.entries(attributes)) {\n mutableContext.traceAttributes.set(key, value);\n }\n}\n\nexport function getTraceAttributes(): Attributes {\n const mutableContext = mutableContextManager?.getMutableContext();\n if (!mutableContext) {\n return {};\n }\n return Object.fromEntries(mutableContext.traceAttributes) as Attributes;\n}\n","import { OTLPMetricExporter as OTLPMetricExporterGRPC } from '@opentelemetry/exporter-metrics-otlp-grpc';\nimport { OTLPMetricExporter as OTLPMetricExporterHTTP } from '@opentelemetry/exporter-metrics-otlp-proto';\nimport { PeriodicExportingMetricReader } from '@opentelemetry/sdk-metrics';\nimport {\n DEFAULT_METRIC_EXPORT_INTERVAL_MS,\n DEFAULT_METRIC_EXPORT_TIMEOUT_MS,\n} from '../constants/index.ts';\nimport type { ResolvedSDKConfig } from '../sdk/types.ts';\nimport { parseOtlpHeaders } from '../utils/env.ts';\nimport { resolveOtlpExporterUrl } from './urls.ts';\n\nexport function createMetricReader(config: ResolvedSDKConfig) {\n const url = resolveOtlpExporterUrl({\n kind: 'metric',\n endpoint: config.otlpEndpoint,\n });\n const headers = parseOtlpHeaders(config.otlpHeaders);\n\n const exporter =\n config.otlpProtocol === 'grpc'\n ? new OTLPMetricExporterGRPC({ url, headers })\n : new OTLPMetricExporterHTTP({ url, headers });\n\n return new PeriodicExportingMetricReader({\n exporter,\n exportIntervalMillis: DEFAULT_METRIC_EXPORT_INTERVAL_MS,\n exportTimeoutMillis: DEFAULT_METRIC_EXPORT_TIMEOUT_MS,\n });\n}\n","import { OTLPTraceExporter as OTLPTraceExporterGRPC } from '@opentelemetry/exporter-trace-otlp-grpc';\nimport { OTLPTraceExporter as OTLPTraceExporterHTTP } from '@opentelemetry/exporter-trace-otlp-proto';\nimport {\n DEFAULT_TRACE_TIMEOUT_MS,\n} from '../constants/index.ts';\nimport type { ResolvedSDKConfig } from '../sdk/types.ts';\nimport { parseOtlpHeaders } from '../utils/env.ts';\nimport { resolveOtlpExporterUrl } from './urls.ts';\n\nexport function createTraceExporter(config: ResolvedSDKConfig) {\n const url = resolveOtlpExporterUrl({\n kind: 'trace',\n endpoint: config.otlpEndpoint,\n explicitUrl: config.traceExporterUrl,\n });\n const headers = parseOtlpHeaders(config.otlpHeaders);\n\n if (config.otlpProtocol === 'grpc') {\n return new OTLPTraceExporterGRPC({\n url,\n timeoutMillis: DEFAULT_TRACE_TIMEOUT_MS,\n headers,\n } as ConstructorParameters<typeof OTLPTraceExporterGRPC>[0]);\n }\n\n return new OTLPTraceExporterHTTP({\n url,\n timeoutMillis: DEFAULT_TRACE_TIMEOUT_MS,\n headers,\n });\n}\n","import { createRequire } from 'node:module';\n\nconst require = createRequire(import.meta.url);\n\nexport type SentryBridge = {\n captureException: (error: unknown) => void;\n};\n\nexport function createSentryBridge(\n enabled: boolean,\n): SentryBridge | undefined {\n if (!enabled) {\n return undefined;\n }\n\n try {\n const sentry = require('@sentry/node');\n return {\n captureException(error: unknown) {\n sentry.captureException(error);\n },\n };\n } catch {\n return undefined;\n }\n}\n","import opentelemetry, { Attributes } from '@opentelemetry/api';\nimport {\n InstrumentationBase,\n InstrumentationConfig,\n InstrumentationNodeModuleDefinition,\n} from '@opentelemetry/instrumentation';\nimport isObject from 'lodash.isobject';\nimport isPlainObject from 'lodash.isplainobject';\nimport { getTraceAttributes } from '../context/index.ts';\nimport { OTelLogger } from '../logger/otelLogger.ts';\nimport { parseWinstonLog } from '../logger/winston.ts';\nimport type { ResolvedSDKConfig } from '../sdk/types.ts';\n\nconst PACKAGE_NAME = '@safaricom-mxl/instrumentation-console';\nconst PACKAGE_VERSION = '0.0.4';\n\nfunction parseConsoleArgs(args: unknown[]) {\n const stringified: unknown[] = [];\n let firstObject: Record<string, unknown> | undefined;\n\n for (const arg of args) {\n if (isObject(arg)) {\n if (!firstObject && isPlainObject(arg)) {\n firstObject = arg as Record<string, unknown>;\n }\n try {\n stringified.push(JSON.stringify(arg));\n } catch {\n // ignore\n }\n continue;\n }\n stringified.push(arg);\n }\n\n return firstObject\n ? {\n ...firstObject,\n ...(args.length > 1 ? { message: stringified.join(' ') } : {}),\n }\n : stringified.join(' ');\n}\n\nexport interface ConsoleInstrumentationConfig extends InstrumentationConfig {\n config: ResolvedSDKConfig;\n}\n\nexport class ConsoleInstrumentation extends InstrumentationBase {\n private readonly otelLogger: OTelLogger;\n\n constructor(config: ConsoleInstrumentationConfig) {\n super(PACKAGE_NAME, PACKAGE_VERSION, config);\n this.otelLogger = new OTelLogger({ config: config.config });\n }\n\n private patchConsoleMethod(type: string, ...args: unknown[]) {\n const level = type === 'log' ? 'info' : type;\n const parsed = parseWinstonLog(\n {\n message: parseConsoleArgs(args),\n level,\n } as never,\n );\n const activeSpan = opentelemetry.trace.getActiveSpan();\n const spanContext = activeSpan?.spanContext();\n let attributes: Attributes = {\n ...parsed.meta,\n ...(spanContext\n ? {\n trace_id: spanContext.traceId,\n span_id: spanContext.spanId,\n trace_flags: spanContext.traceFlags,\n }\n : {}),\n };\n if ((this.getConfig() as ConsoleInstrumentationConfig).config.betaMode) {\n attributes = { ...attributes, ...getTraceAttributes() };\n }\n this.otelLogger.postMessage(parsed.level, parsed.message, attributes);\n }\n\n private wrapHandler(\n type: 'debug' | 'log' | 'info' | 'warn' | 'error',\n original: (...args: unknown[]) => unknown,\n ) {\n return (...args: unknown[]) => {\n this.patchConsoleMethod(type, ...args);\n return original.apply(this, args);\n };\n }\n\n private onPatch(moduleExports: Console) {\n this._wrap(moduleExports, 'debug', (original) =>\n this.wrapHandler('debug', original),\n );\n this._wrap(moduleExports, 'log', (original) => this.wrapHandler('log', original));\n this._wrap(moduleExports, 'info', (original) =>\n this.wrapHandler('info', original),\n );\n this._wrap(moduleExports, 'warn', (original) =>\n this.wrapHandler('warn', original),\n );\n this._wrap(moduleExports, 'error', (original) =>\n this.wrapHandler('error', original),\n );\n return moduleExports;\n }\n\n private onUnpatch(moduleExports: Console) {\n this._unwrap(moduleExports, 'debug');\n this._unwrap(moduleExports, 'log');\n this._unwrap(moduleExports, 'info');\n this._unwrap(moduleExports, 'warn');\n this._unwrap(moduleExports, 'error');\n }\n\n init() {\n return [\n new InstrumentationNodeModuleDefinition(\n 'console',\n ['*'],\n (moduleExports: Console) => this.onPatch(moduleExports),\n (moduleExports: Console) => {\n this.onUnpatch(moduleExports);\n return moduleExports;\n },\n ),\n ];\n }\n}\n","import {\n InstrumentationBase,\n type InstrumentationConfig,\n} from '@opentelemetry/instrumentation';\nimport { recordException } from './recordException.ts';\n\nexport type ExceptionInstrumentationConfig = {\n captureExceptionHook?: (error: unknown) => void;\n forceFlush?: () => Promise<void>;\n unhandledRejectionMode?: 'none' | 'warn' | 'strict';\n exitEvenIfOtherHandlersAreRegistered?: boolean;\n} & InstrumentationConfig;\n\nexport class ExceptionInstrumentation extends InstrumentationBase {\n private forceFlush?: () => Promise<void>;\n private uncaughtExceptionListener?: (error: Error) => void;\n private unhandledRejectionListener?: (reason: unknown) => void;\n\n constructor(config: ExceptionInstrumentationConfig = {}) {\n super('@safaricom-mxl/instrumentation-exception', '0.0.4', config);\n this.forceFlush = config.forceFlush;\n }\n\n init() {\n return;\n }\n\n override enable() {\n const config = this.getConfig() as ExceptionInstrumentationConfig;\n const rejectionMode = config.unhandledRejectionMode ?? 'warn';\n\n this.uncaughtExceptionListener = (error: Error) => {\n config.captureExceptionHook?.(error);\n void recordException(error).finally(() => {\n void (config.forceFlush?.() ?? this.forceFlush?.());\n });\n if (config.exitEvenIfOtherHandlersAreRegistered) {\n process.exitCode = 1;\n }\n };\n\n this.unhandledRejectionListener = (reason: unknown) => {\n config.captureExceptionHook?.(reason);\n void recordException(reason).finally(() => {\n if (rejectionMode === 'warn') {\n console.warn(\n 'Unhandled promise rejection captured by MXL Node SDK. ' +\n 'Set unhandledRejectionMode=strict to terminate the process.',\n );\n }\n if (rejectionMode === 'strict') {\n void (config.forceFlush?.() ?? this.forceFlush?.()).finally(() => {\n process.exitCode = 1;\n });\n }\n });\n };\n\n process.on('uncaughtException', this.uncaughtExceptionListener);\n process.on('unhandledRejection', this.unhandledRejectionListener);\n }\n\n override disable() {\n if (this.uncaughtExceptionListener) {\n process.off('uncaughtException', this.uncaughtExceptionListener);\n }\n if (this.unhandledRejectionListener) {\n process.off('unhandledRejection', this.unhandledRejectionListener);\n }\n this.uncaughtExceptionListener = undefined;\n this.unhandledRejectionListener = undefined;\n }\n}\n","import { Span, diag } from '@opentelemetry/api';\nimport * as http from 'node:http';\nimport { PassThrough, Readable } from 'node:stream';\nimport zlib from 'node:zlib';\n\nconst SENSITIVE_DATA_SUBSTITUTE = '[Filtered]';\n\nconst DEFAULT_DENYLIST = [\n 'password',\n 'passwd',\n 'secret',\n 'api_key',\n 'apikey',\n 'auth',\n 'credentials',\n 'private_key',\n 'token',\n 'session',\n 'cookie',\n 'authorization',\n 'x_api_key',\n '_csrf',\n 'phpsessid',\n 'xsrf-token',\n];\n\nfunction captureSelectedHeaders(\n span: Span,\n prefix: 'request' | 'response',\n headers: string[],\n getter: (header: string) => unknown,\n) {\n for (const header of headers) {\n const value = getter(header);\n if (Array.isArray(value)) {\n span.setAttribute(`http.${prefix}.header.${header.toLowerCase()}`, value.join(','));\n } else if (value != null) {\n span.setAttribute(\n `http.${prefix}.header.${header.toLowerCase()}`,\n String(value),\n );\n }\n }\n}\n\nexport function splitCommaSeparatedStrings(headers?: string) {\n return headers?.split(',').map((header) => header.trim()).filter(Boolean);\n}\n\nexport function getShouldRecordBody(defaultFilter?: string) {\n return (body: string) => {\n const lowerCaseBody = body.toLowerCase();\n const keywords =\n splitCommaSeparatedStrings(defaultFilter)?.map((item) => item.toLowerCase()) ??\n DEFAULT_DENYLIST;\n return !keywords.some((keyword) => lowerCaseBody.includes(keyword));\n };\n}\n\nfunction interceptReadableStream(stream: Readable, passThrough: PassThrough) {\n const emit = stream.emit;\n stream.emit = function (\n this: Readable,\n event: string | symbol,\n ...args: unknown[]\n ) {\n if (event === 'data') passThrough.write(args[0]);\n else if (event === 'end') passThrough.end();\n return emit.call(this, event, ...args);\n } as typeof stream.emit;\n return stream;\n}\n\nfunction captureBodyAttribute({\n targetSpan,\n attributeName,\n body,\n shouldRecordBody,\n}: {\n targetSpan: Span;\n attributeName: 'http.request.body' | 'http.response.body';\n body: string;\n shouldRecordBody: (body: string) => boolean;\n}) {\n if (!targetSpan.isRecording()) return;\n targetSpan.setAttribute(\n attributeName,\n shouldRecordBody(body) ? body : SENSITIVE_DATA_SUBSTITUTE,\n );\n}\n\nfunction handleOutgoingClientRequest({\n request,\n span,\n shouldRecordBody,\n captureHeaders,\n}: {\n request: http.ClientRequest;\n span: Span;\n shouldRecordBody: (body: string) => boolean;\n captureHeaders?: string;\n}) {\n try {\n const headers = splitCommaSeparatedStrings(captureHeaders) ?? request.getRawHeaderNames();\n captureSelectedHeaders(span, 'request', headers, (header) =>\n request.getHeader(header),\n );\n } catch (error) {\n diag.debug('Failed to capture outgoing request headers', error);\n }\n\n const chunks: Buffer[] = [];\n const oldWrite = request.write.bind(request);\n request.write = ((data: unknown) => {\n chunks.push(Buffer.isBuffer(data) ? data : Buffer.from(String(data)));\n return oldWrite(data as never);\n }) as never;\n\n const oldEnd = request.end.bind(request);\n request.end = ((data: unknown) => {\n if (data != null) {\n chunks.push(Buffer.isBuffer(data) ? data : Buffer.from(String(data)));\n }\n if (chunks.length > 0) {\n captureBodyAttribute({\n targetSpan: span,\n attributeName: 'http.request.body',\n body: Buffer.concat(chunks).toString('utf8'),\n shouldRecordBody,\n });\n }\n return oldEnd(data as never);\n }) as never;\n}\n\nfunction handleIncomingServerRequest({\n request,\n span,\n shouldRecordBody,\n captureHeaders,\n headerAttributeMap,\n}: {\n request: http.IncomingMessage;\n span: Span;\n shouldRecordBody: (body: string) => boolean;\n captureHeaders?: string;\n headerAttributeMap?: Record<string, string>;\n}) {\n try {\n const headers = splitCommaSeparatedStrings(captureHeaders) ?? Object.keys(request.headers);\n captureSelectedHeaders(span, 'request', headers, (header) => request.headers[header]);\n } catch (error) {\n diag.debug('Failed to capture incoming request headers', error);\n }\n\n if (headerAttributeMap) {\n for (const [headerName, attributeName] of Object.entries(headerAttributeMap)) {\n const value = request.headers[headerName];\n if (Array.isArray(value)) {\n span.setAttribute(attributeName, value.join(','));\n } else if (value) {\n span.setAttribute(attributeName, value);\n }\n }\n }\n\n const chunks: Buffer[] = [];\n const passThrough = new PassThrough();\n passThrough.on('data', (chunk) => {\n chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk)));\n });\n passThrough.on('end', () => {\n if (chunks.length === 0) {\n return;\n }\n captureBodyAttribute({\n targetSpan: span,\n attributeName: 'http.request.body',\n body: Buffer.concat(chunks).toString('utf8'),\n shouldRecordBody,\n });\n });\n interceptReadableStream(request, passThrough);\n}\n\nfunction handleIncomingServerResponse({\n response,\n span,\n shouldRecordBody,\n captureHeaders,\n}: {\n response: http.ServerResponse;\n span: Span;\n shouldRecordBody: (body: string) => boolean;\n captureHeaders?: string;\n}) {\n const chunks: Buffer[] = [];\n const oldWrite = response.write.bind(response);\n response.write = ((data: unknown) => {\n chunks.push(Buffer.isBuffer(data) ? data : Buffer.from(String(data)));\n return oldWrite(data as never);\n }) as never;\n\n const oldEnd = response.end.bind(response);\n response.end = ((data: unknown) => {\n if (data != null) {\n chunks.push(Buffer.isBuffer(data) ? data : Buffer.from(String(data)));\n }\n if (chunks.length > 0) {\n const payload = Buffer.concat(chunks);\n const isGzip = response.getHeader('content-encoding') === 'gzip';\n const body = (isGzip ? zlib.gunzipSync(payload) : payload).toString('utf8');\n captureBodyAttribute({\n targetSpan: span,\n attributeName: 'http.response.body',\n body,\n shouldRecordBody,\n });\n }\n\n try {\n const headers = splitCommaSeparatedStrings(captureHeaders) ?? response.getHeaderNames();\n captureSelectedHeaders(span, 'response', headers, (header) =>\n response.getHeader(header),\n );\n } catch (error) {\n diag.debug('Failed to capture incoming response headers', error);\n }\n return oldEnd(data as never);\n }) as never;\n}\n\nfunction handleOutgoingClientResponse({\n response,\n span,\n shouldRecordBody,\n captureHeaders,\n}: {\n response: http.IncomingMessage;\n span: Span;\n shouldRecordBody: (body: string) => boolean;\n captureHeaders?: string;\n}) {\n try {\n const headers = splitCommaSeparatedStrings(captureHeaders) ?? Object.keys(response.headers);\n captureSelectedHeaders(span, 'response', headers, (header) => response.headers[header]);\n } catch (error) {\n diag.debug('Failed to capture outgoing response headers', error);\n }\n\n const chunks: Buffer[] = [];\n const passThrough = new PassThrough();\n passThrough.on('data', (chunk) => {\n chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk)));\n });\n passThrough.on('end', () => {\n if (chunks.length === 0) {\n return;\n }\n const payload = Buffer.concat(chunks);\n const isGzip = response.headers['content-encoding'] === 'gzip';\n const body = (isGzip ? zlib.gunzipSync(payload) : payload).toString('utf8');\n captureBodyAttribute({\n targetSpan: span,\n attributeName: 'http.response.body',\n body,\n shouldRecordBody,\n });\n });\n interceptReadableStream(response, passThrough);\n}\n\nexport function getAdvancedHttpInstrumentationConfig({\n captureBodyKeywordsFilter,\n captureHeadersClientRequest,\n captureHeadersClientResponse,\n captureHeadersServerRequest,\n captureHeadersServerResponse,\n headerAttributeMap,\n}: {\n captureBodyKeywordsFilter?: string;\n captureHeadersClientRequest?: string;\n captureHeadersClientResponse?: string;\n captureHeadersServerRequest?: string;\n captureHeadersServerResponse?: string;\n headerAttributeMap?: Record<string, string>;\n}) {\n const shouldRecordBody = getShouldRecordBody(captureBodyKeywordsFilter);\n\n return {\n requestHook(span: Span, request: http.ClientRequest | http.IncomingMessage) {\n if (request instanceof http.ClientRequest) {\n handleOutgoingClientRequest({\n request,\n span,\n shouldRecordBody,\n captureHeaders: captureHeadersClientRequest,\n });\n } else {\n handleIncomingServerRequest({\n request,\n span,\n shouldRecordBody,\n captureHeaders: captureHeadersServerRequest,\n headerAttributeMap,\n });\n }\n },\n responseHook(span: Span, response: http.ServerResponse | http.IncomingMessage) {\n if (response instanceof http.ServerResponse) {\n handleIncomingServerResponse({\n response,\n span,\n shouldRecordBody,\n captureHeaders: captureHeadersServerResponse,\n });\n } else {\n handleOutgoingClientResponse({\n response,\n span,\n shouldRecordBody,\n captureHeaders: captureHeadersClientResponse,\n });\n }\n },\n };\n}\n","import { Context, diag } from '@opentelemetry/api';\nimport type { ReadableSpan, Span, SpanProcessor } from '@opentelemetry/sdk-trace-base';\n\nexport class CompositeSpanProcessor implements SpanProcessor {\n constructor(private readonly processors: SpanProcessor[]) {}\n\n forceFlush() {\n return Promise.all(\n this.processors.map((processor) =>\n processor.forceFlush().catch((error) => {\n diag.error('@safaricom-mxl/node-sdk: forceFlush failed', error);\n }),\n ),\n ).then(() => undefined);\n }\n\n shutdown() {\n return Promise.all(\n this.processors.map((processor) =>\n processor.shutdown().catch((error) => {\n diag.error('@safaricom-mxl/node-sdk: shutdown failed', error);\n }),\n ),\n ).then(() => undefined);\n }\n\n onStart(span: Span, parentContext: Context) {\n for (const processor of this.processors) {\n processor.onStart(span, parentContext);\n }\n }\n\n onEnd(span: ReadableSpan) {\n for (const processor of this.processors) {\n processor.onEnd(span);\n }\n }\n}\n","import { Context } from '@opentelemetry/api';\nimport type { ReadableSpan, Span, SpanProcessor } from '@opentelemetry/sdk-trace-base';\n\nexport class FilterWhenDrainedSpanProcessor implements SpanProcessor {\n private drained = false;\n\n constructor(private readonly delegate: SpanProcessor) {}\n\n drain() {\n this.drained = true;\n }\n\n onStart(span: Span, parentContext: Context) {\n if (this.drained) {\n return;\n }\n this.delegate.onStart(span, parentContext);\n }\n\n onEnd(span: ReadableSpan) {\n if (this.drained) {\n return;\n }\n this.delegate.onEnd(span);\n }\n\n forceFlush() {\n return this.delegate.forceFlush();\n }\n\n shutdown() {\n this.drained = true;\n return this.delegate.shutdown();\n }\n}\n","import { Context } from '@opentelemetry/api';\nimport { BatchSpanProcessor, Span, SpanExporter } from '@opentelemetry/sdk-trace-base';\nimport { getTraceAttributes } from '../context/index.ts';\n\nexport class NodeSpanProcessor extends BatchSpanProcessor {\n constructor(exporter: SpanExporter) {\n super(exporter);\n }\n\n private applyTraceAttributes(span: Span) {\n const attributes = getTraceAttributes();\n for (const [key, value] of Object.entries(attributes)) {\n if (span.attributes[key] == null) {\n span.setAttribute(key, value as never);\n }\n }\n }\n\n onStart(span: Span, parentContext: Context) {\n this.applyTraceAttributes(span);\n super.onStart(span, parentContext);\n }\n\n onEnd(span: Span) {\n // Best effort: some instrumentations end spans with a stale context.\n // We temporarily re-open to append inherited attributes before export.\n (span as unknown as { _ended?: boolean })._ended = false;\n this.applyTraceAttributes(span);\n (span as unknown as { _ended?: boolean })._ended = true;\n super.onEnd(span);\n }\n}\n","import type { Context } from '@opentelemetry/api';\nimport { TraceFlags } from '@opentelemetry/api';\nimport type {\n ReadableSpan,\n Span,\n SpanProcessor,\n} from '@opentelemetry/sdk-trace-base';\nimport type { SpanTimeline } from './span-timeline.ts';\n\nexport class ProfilingSpanProcessor implements SpanProcessor {\n readonly #timeline: SpanTimeline;\n readonly #stack: Array<{ traceId: string; spanId: string } | undefined> = [];\n\n constructor(timeline: SpanTimeline) {\n this.#timeline = timeline;\n }\n\n onStart(span: Span, _parentContext: Context): void {\n const context = span.spanContext();\n const current =\n (context.traceFlags & TraceFlags.SAMPLED) === TraceFlags.SAMPLED\n ? { traceId: context.traceId, spanId: context.spanId }\n : undefined;\n this.#stack.push(current);\n this.#timeline.note(current);\n }\n\n onEnd(_span: ReadableSpan): void {\n this.#stack.pop();\n this.#timeline.note(this.#stack.at(-1));\n }\n\n forceFlush(): Promise<void> {\n return Promise.resolve();\n }\n\n shutdown(): Promise<void> {\n return Promise.resolve();\n }\n}\n","export interface TimelineSpan {\n readonly traceId: string;\n readonly spanId: string;\n}\n\nexport interface SpanEvents {\n readonly times: Float64Array;\n readonly spans: ReadonlyArray<TimelineSpan | undefined>;\n readonly length: number;\n readonly overflowed: boolean;\n}\n\nexport interface SpanTimeline {\n readonly note: (span: TimelineSpan | undefined) => void;\n readonly setRecording: (recording: boolean) => void;\n readonly drain: () => SpanEvents;\n}\n\nexport const SPAN_EVENT_CAPACITY = 1 << 17;\n\nexport const makeSpanTimeline = (\n options: { readonly capacity?: number; readonly now?: () => number } = {},\n): SpanTimeline => {\n const capacity = options.capacity ?? SPAN_EVENT_CAPACITY;\n const now = options.now ?? (() => performance.now());\n let times = new Float64Array(capacity);\n let spans: Array<TimelineSpan | undefined> = [];\n let length = 0;\n let overflowed = false;\n let recording = false;\n let current: TimelineSpan | undefined;\n\n const push = (span: TimelineSpan | undefined): void => {\n if (length >= capacity) {\n overflowed = true;\n return;\n }\n times[length] = now();\n spans[length] = span;\n length += 1;\n };\n\n return {\n note: (span) => {\n current = span;\n if (recording) push(span);\n },\n setRecording: (next) => {\n if (next && !recording && current !== undefined) push(current);\n recording = next;\n },\n drain: () => {\n const drained: SpanEvents = { times, spans, length, overflowed };\n times = new Float64Array(capacity);\n spans = [];\n length = 0;\n overflowed = false;\n if (recording && current !== undefined) push(current);\n return drained;\n },\n };\n};\n\nexport const spanAt = (\n events: SpanEvents,\n timeMs: number,\n): TimelineSpan | undefined => {\n if (\n events.length === 0 ||\n timeMs < (events.times[0] ?? Number.POSITIVE_INFINITY)\n ) {\n return undefined;\n }\n const last = events.length - 1;\n if (events.overflowed && timeMs > (events.times[last] ?? 0)) {\n return undefined;\n }\n let low = 0;\n let high = last;\n while (low < high) {\n const middle = (low + high + 1) >>> 1;\n if ((events.times[middle] ?? Number.POSITIVE_INFINITY) <= timeMs)\n low = middle;\n else high = middle - 1;\n }\n return events.spans[low];\n};\n","import type { SpanEvents } from './span-timeline.ts';\nimport { spanAt } from './span-timeline.ts';\n\nexport interface CpuProfile {\n readonly nodes: ReadonlyArray<{\n readonly id: number;\n readonly callFrame: {\n readonly functionName: string;\n readonly url: string;\n readonly lineNumber: number;\n };\n readonly children?: ReadonlyArray<number> | undefined;\n }>;\n readonly startTime: number;\n readonly samples?: ReadonlyArray<number> | undefined;\n readonly timeDeltas?: ReadonlyArray<number> | undefined;\n}\n\nexport interface EncodeCpuProfileOptions {\n readonly resource: unknown;\n readonly startedAtPerfMs: number;\n readonly startedAtEpochMs: number;\n readonly durationMs: number;\n readonly samplingIntervalMicros: number;\n readonly spanEvents?: SpanEvents | undefined;\n readonly profileId: string;\n}\n\nexport interface ProfilesExport {\n readonly resourceProfiles: ReadonlyArray<unknown>;\n readonly dictionary: unknown;\n}\n\nconst IDLE = '(idle)';\nconst ROOT = '(root)';\nconst FILE_SCHEME = 'file://';\n\nconst nanos = (epochMs: number): string =>\n (BigInt(Math.round(epochMs * 1000)) * 1000n).toString();\n\nclass Interner<T> {\n readonly table: Array<T>;\n readonly #index = new Map<string, number>();\n\n constructor(zero: T) {\n this.table = [zero];\n }\n\n intern(key: string, make: () => T): number {\n const existing = this.#index.get(key);\n if (existing !== undefined) return existing;\n const index = this.table.length;\n this.table.push(make());\n this.#index.set(key, index);\n return index;\n }\n}\n\ninterface Group {\n readonly nodeId: number;\n readonly linkIndex: number;\n valueNanos: number;\n firstEpochMs: number;\n}\n\nexport const encodeCpuProfile = (\n profile: CpuProfile,\n options: EncodeCpuProfileOptions,\n): ProfilesExport | undefined => {\n const samples = profile.samples ?? [];\n const deltas = profile.timeDeltas ?? [];\n const nodes = new Map(profile.nodes.map((node) => [node.id, node]));\n const parents = new Map<number, number>();\n for (const node of profile.nodes) {\n for (const child of node.children ?? []) parents.set(child, node.id);\n }\n\n const strings = new Interner<string>('');\n const string = (value: string): number =>\n value === '' ? 0 : strings.intern(value, () => value);\n const functions = new Interner<Record<string, number>>({});\n const locations = new Interner<Record<string, unknown>>({});\n const stacks = new Interner<Record<string, unknown>>({});\n const links = new Interner<Record<string, string>>({});\n\n const locationOf = (nodeId: number): number | undefined => {\n const frame = nodes.get(nodeId)?.callFrame;\n if (frame === undefined || frame.functionName === ROOT) return undefined;\n const file = frame.url.startsWith(FILE_SCHEME)\n ? frame.url.slice(FILE_SCHEME.length)\n : frame.url;\n const line = frame.lineNumber >= 0 ? frame.lineNumber + 1 : 0;\n const key = `${frame.functionName}\\u0000${file}\\u0000${line}`;\n return locations.intern(key, () => ({\n lines: [\n {\n functionIndex: functions.intern(key, () => ({\n nameStrindex: string(\n frame.functionName === '' ? '(anonymous)' : frame.functionName,\n ),\n filenameStrindex: string(file),\n startLine: line,\n })),\n line,\n },\n ],\n }));\n };\n\n const stackOf = (nodeId: number): number =>\n stacks.intern(String(nodeId), () => {\n const locationIndices: Array<number> = [];\n for (\n let current: number | undefined = nodeId;\n current !== undefined;\n current = parents.get(current)\n ) {\n const location = locationOf(current);\n if (location !== undefined) locationIndices.push(location);\n }\n return { locationIndices };\n });\n\n const maxSampleMicros = options.samplingIntervalMicros;\n const groups = new Map<string, Group>();\n let elapsedMicros = 0;\n for (let index = 0; index < samples.length; index++) {\n elapsedMicros += deltas[index] ?? 0;\n const nodeId = samples[index];\n if (\n nodeId === undefined ||\n nodes.get(nodeId)?.callFrame.functionName === IDLE\n ) {\n continue;\n }\n const valueMicros = Math.min(\n Math.max(deltas[index + 1] ?? options.samplingIntervalMicros, 0),\n maxSampleMicros,\n );\n const offsetMs = elapsedMicros / 1000;\n const span =\n options.spanEvents === undefined\n ? undefined\n : spanAt(options.spanEvents, options.startedAtPerfMs + offsetMs);\n const linkIndex =\n span === undefined\n ? 0\n : links.intern(span.spanId, () => ({\n traceId: span.traceId,\n spanId: span.spanId,\n }));\n const key = `${nodeId}|${linkIndex}`;\n const group = groups.get(key);\n if (group === undefined) {\n groups.set(key, {\n nodeId,\n linkIndex,\n valueNanos: valueMicros * 1000,\n firstEpochMs: options.startedAtEpochMs + offsetMs,\n });\n } else {\n group.valueNanos += valueMicros * 1000;\n }\n }\n if (groups.size === 0) return undefined;\n\n const cpu = {\n typeStrindex: string('cpu'),\n unitStrindex: string('nanoseconds'),\n };\n const profileSamples = [...groups.values()].map((group) => ({\n stackIndex: stackOf(group.nodeId),\n linkIndex: group.linkIndex,\n values: [String(group.valueNanos)],\n timestampsUnixNano: [nanos(group.firstEpochMs)],\n }));\n\n return {\n resourceProfiles: [\n {\n resource: options.resource,\n scopeProfiles: [\n {\n scope: { name: '@safaricom-mxl/node-sdk/profiling' },\n profiles: [\n {\n sampleType: cpu,\n samples: profileSamples,\n timeUnixNano: nanos(options.startedAtEpochMs),\n durationNano: String(\n Math.round(options.durationMs * 1_000_000),\n ),\n periodType: cpu,\n period: String(options.samplingIntervalMicros * 1000),\n profileId: options.profileId,\n },\n ],\n },\n ],\n },\n ],\n dictionary: {\n mappingTable: [{}],\n locationTable: locations.table,\n functionTable: functions.table,\n linkTable: links.table,\n stringTable: strings.table,\n attributeTable: [{}],\n stackTable: stacks.table,\n },\n };\n};\n","import { Session } from 'node:inspector';\nimport { diag } from '@opentelemetry/api';\nimport type { CpuProfile } from './cpu-profile.ts';\nimport { encodeCpuProfile } from './cpu-profile.ts';\nimport type { SpanTimeline } from './span-timeline.ts';\nimport { SPAN_EVENT_CAPACITY } from './span-timeline.ts';\n\nexport interface ProfilingOptions {\n readonly window?: number | undefined;\n readonly samplingIntervalMicros?: number | undefined;\n readonly linkSpans?: boolean | undefined;\n}\n\nexport const DEFAULT_PROFILE_WINDOW_MS = 60_000;\nconst MIN_PROFILE_WINDOW_MS = 1_000;\nconst MIN_SAMPLING_INTERVAL_MICROS = 100;\nexport const DEFAULT_SAMPLING_INTERVAL_MICROS = 10_000;\nexport const PROFILER_SETUP_TIMEOUT_MS = 5_000;\nexport const PROFILER_COMMAND_TIMEOUT_MS = 5_000;\nconst EXPORT_TIMEOUT_MS = 10_000;\nexport const PROFILES_PATH = '/v1development/profiles';\n\nexport interface CpuProfilerOptions {\n readonly baseUrl: string;\n readonly resource: unknown;\n readonly headers?: Record<string, string> | undefined;\n readonly profiling: ProfilingOptions;\n readonly timeline?: SpanTimeline | undefined;\n readonly shutdownTimeoutMs?: number | undefined;\n}\n\nexport interface CpuProfilerHandle {\n readonly stop: () => Promise<void>;\n}\n\ninterface InspectorReply {\n readonly profile?: CpuProfile;\n}\n\nconst profileWindowMs = (window: number | undefined): number =>\n Math.max(\n MIN_PROFILE_WINDOW_MS,\n window === undefined || !Number.isFinite(window) || window <= 0\n ? DEFAULT_PROFILE_WINDOW_MS\n : window,\n );\n\nconst samplingIntervalOf = (micros: number | undefined): number =>\n micros === undefined || !Number.isFinite(micros) || micros <= 0\n ? DEFAULT_SAMPLING_INTERVAL_MICROS\n : Math.max(MIN_SAMPLING_INTERVAL_MICROS, Math.round(micros));\n\nconst post = (\n session: Session,\n method: string,\n params: Record<string, unknown>,\n timeoutMs: number,\n): Promise<InspectorReply | undefined> =>\n new Promise((resolve, reject) => {\n let settled = false;\n const timer = setTimeout(() => {\n if (settled) return;\n settled = true;\n reject(new Error(`${method} got no answer within ${timeoutMs} ms`));\n }, timeoutMs);\n session.post(method, params, (error, reply) => {\n if (settled) return;\n settled = true;\n clearTimeout(timer);\n if (error) reject(error);\n else resolve(reply as InspectorReply | undefined);\n });\n });\n\nconst randomHex = (bytes: number): string =>\n Buffer.from(crypto.getRandomValues(new Uint8Array(bytes))).toString('hex');\n\nconst withTimeout = <T>(promise: Promise<T>, ms: number, message: string) => {\n const timeout = new Promise<never>((_, reject) => {\n setTimeout(() => reject(new Error(message)), ms);\n });\n return Promise.race([promise, timeout]);\n};\n\nlet profilerHolders = 0;\n\nexport const startCpuProfiler = (\n options: CpuProfilerOptions,\n): CpuProfilerHandle => {\n profilerHolders += 1;\n if (profilerHolders > 1) {\n return {\n stop: async () => {\n profilerHolders = Math.max(0, profilerHolders - 1);\n },\n };\n }\n\n let stopped = false;\n let loop: Promise<void> | undefined;\n let session: Session | undefined;\n const windowMs = profileWindowMs(options.profiling.window);\n const samplingIntervalMicros = samplingIntervalOf(\n options.profiling.samplingIntervalMicros,\n );\n const url = `${options.baseUrl.replace(/\\/$/, '')}${PROFILES_PATH}`;\n let overflowWarned = false;\n\n const send = async (body: unknown) => {\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), EXPORT_TIMEOUT_MS);\n try {\n const response = await fetch(url, {\n method: 'POST',\n headers: {\n 'content-type': 'application/json',\n 'OTLP-Profiles-Development-Version': '1',\n ...options.headers,\n },\n body: JSON.stringify(body),\n signal: controller.signal,\n });\n await response.arrayBuffer();\n } finally {\n clearTimeout(timer);\n }\n };\n\n const run = async () => {\n const inspectorSession = new Session();\n session = inspectorSession;\n inspectorSession.connect();\n const command = (method: string, params: Record<string, unknown> = {}) =>\n post(inspectorSession, method, params, PROFILER_COMMAND_TIMEOUT_MS);\n await withTimeout(\n command('Profiler.enable'),\n PROFILER_SETUP_TIMEOUT_MS,\n 'the inspector did not answer',\n );\n await withTimeout(\n command('Profiler.setSamplingInterval', {\n interval: samplingIntervalMicros,\n }),\n PROFILER_SETUP_TIMEOUT_MS,\n 'the inspector did not answer',\n );\n\n const startWindow = async () => {\n const started = {\n startedAtPerfMs: performance.now(),\n startedAtEpochMs: Date.now(),\n };\n await command('Profiler.start');\n return started;\n };\n\n options.timeline?.setRecording(true);\n let current = await startWindow();\n\n const exportWindow = async (\n started: { startedAtPerfMs: number; startedAtEpochMs: number },\n reply: InspectorReply | undefined,\n spanEvents: ReturnType<SpanTimeline['drain']> | undefined,\n ) => {\n if (spanEvents?.overflowed === true && !overflowWarned) {\n overflowWarned = true;\n diag.warn(\n `@safaricom-mxl/node-sdk: more than ${SPAN_EVENT_CAPACITY} span switches in one window; later samples in it are not linked to spans`,\n );\n }\n const profile = reply?.profile;\n if (profile === undefined) return;\n const body = encodeCpuProfile(profile, {\n resource: options.resource,\n ...started,\n durationMs: performance.now() - started.startedAtPerfMs,\n samplingIntervalMicros,\n spanEvents,\n profileId: randomHex(16),\n });\n if (body !== undefined) await send(body);\n };\n\n while (!stopped) {\n await new Promise((resolve) => setTimeout(resolve, windowMs));\n if (stopped) break;\n const ended = current;\n const reply = await command('Profiler.stop');\n const spanEvents = options.timeline?.drain();\n current = await startWindow();\n await exportWindow(ended, reply, spanEvents).catch((error: unknown) => {\n diag.warn('@safaricom-mxl/node-sdk: profile export failed', error);\n });\n }\n\n const last = await command('Profiler.stop').catch(() => undefined);\n await exportWindow(current, last, options.timeline?.drain()).catch(\n (error: unknown) => {\n diag.warn(\n '@safaricom-mxl/node-sdk: final profile export skipped',\n error,\n );\n },\n );\n };\n\n loop = run().catch((error: unknown) => {\n options.timeline?.setRecording(false);\n diag.warn(\n '@safaricom-mxl/node-sdk: profiling is off: this runtime has no CPU profiler the SDK can drive',\n error,\n );\n });\n\n return {\n stop: async () => {\n stopped = true;\n options.timeline?.setRecording(false);\n profilerHolders = Math.max(0, profilerHolders - 1);\n const timeout = options.shutdownTimeoutMs ?? 3_000;\n await Promise.race([\n loop ?? Promise.resolve(),\n new Promise((resolve) => setTimeout(resolve, timeout)),\n ]);\n try {\n session?.disconnect();\n } catch {\n // Session already closed.\n }\n },\n };\n};\n\nexport const normalizeProfiling = (\n profiling: boolean | ProfilingOptions | undefined,\n): ProfilingOptions | undefined => {\n if (profiling === true) return {};\n if (profiling === false || profiling === undefined) return undefined;\n return profiling;\n};\n","import { resourceFromAttributes, defaultServiceName } from '@opentelemetry/resources';\nimport {\n ATTR_SERVICE_NAME,\n ATTR_SERVICE_VERSION,\n ATTR_TELEMETRY_SDK_NAME,\n ATTR_TELEMETRY_SDK_VERSION,\n} from '@opentelemetry/semantic-conventions';\nimport { NODE_SDK_NAME, NODE_SDK_VERSION } from '../constants/index.ts';\nimport type { ResolvedSDKConfig } from '../sdk/types.ts';\n\nexport function createNodeSdkResource(config: ResolvedSDKConfig) {\n return resourceFromAttributes({\n [ATTR_SERVICE_NAME]: config.serviceName || defaultServiceName(),\n [ATTR_SERVICE_VERSION]: process.env.VERCEL_DEPLOYMENT_ID ?? process.env.npm_package_version,\n [ATTR_TELEMETRY_SDK_NAME]: NODE_SDK_NAME,\n [ATTR_TELEMETRY_SDK_VERSION]: NODE_SDK_VERSION,\n 'telemetry.distro.name': 'mxl-node-sdk',\n 'telemetry.distro.version': NODE_SDK_VERSION,\n ...config.additionalResourceAttributes,\n });\n}\n","import {\n DEFAULT_ADVANCED_NETWORK_CAPTURE,\n DEFAULT_BETA_MODE,\n DEFAULT_CAPTURE_BODY_KEYWORDS_FILTER,\n DEFAULT_CAPTURE_HEADERS_CLIENT_REQUEST,\n DEFAULT_CAPTURE_HEADERS_CLIENT_RESPONSE,\n DEFAULT_CAPTURE_HEADERS_SERVER_REQUEST,\n DEFAULT_CAPTURE_HEADERS_SERVER_RESPONSE,\n DEFAULT_CONSOLE_CAPTURE,\n DEFAULT_EXCEPTION_CAPTURE_ENABLED,\n DEFAULT_OTLP_PROTOCOL,\n DEFAULT_SENTRY_INTEGRATION_ENABLED,\n DEFAULT_SERVICE_NAME,\n DEFAULT_STARTUP_LOGS_ENABLED,\n DEFAULT_STOP_ON_TERMINATION_SIGNALS,\n DEFAULT_TRACE_SAMPLER,\n DEFAULT_TRACE_SAMPLER_ARG,\n} from '../constants/index.ts';\nimport {\n getBooleanFromEnv,\n getStringFromEnv,\n parseHeaderAttributeMap,\n} from '../utils/env.ts';\nimport type { ResolvedSDKConfig, SDKConfig } from './types.ts';\n\nexport function resolveSDKConfig(config: SDKConfig = {}): ResolvedSDKConfig {\n return {\n additionalInstrumentations: config.additionalInstrumentations ?? [],\n additionalResourceAttributes: config.additionalResourceAttributes ?? {},\n advancedNetworkCapture:\n config.advancedNetworkCapture ??\n getBooleanFromEnv('MXL_NODE_ADVANCED_NETWORK_CAPTURE') ??\n DEFAULT_ADVANCED_NETWORK_CAPTURE,\n apiKey: config.apiKey ?? getStringFromEnv('MXL_API_KEY'),\n betaMode:\n config.betaMode ??\n getBooleanFromEnv('MXL_NODE_BETA_MODE') ??\n DEFAULT_BETA_MODE,\n captureBodyKeywordsFilter:\n config.captureBodyKeywordsFilter ??\n getStringFromEnv(\n 'OTEL_INSTRUMENTATION_HTTP_CAPTURE_BODY_KEYWORDS_FILTER',\n ) ??\n DEFAULT_CAPTURE_BODY_KEYWORDS_FILTER,\n captureHeadersClientRequest:\n config.captureHeadersClientRequest ??\n getStringFromEnv(\n 'OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_CLIENT_REQUEST',\n ) ??\n DEFAULT_CAPTURE_HEADERS_CLIENT_REQUEST,\n captureHeadersClientResponse:\n config.captureHeadersClientResponse ??\n getStringFromEnv(\n 'OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_CLIENT_RESPONSE',\n ) ??\n DEFAULT_CAPTURE_HEADERS_CLIENT_RESPONSE,\n captureHeadersServerRequest:\n config.captureHeadersServerRequest ??\n getStringFromEnv(\n 'OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SERVER_REQUEST',\n ) ??\n DEFAULT_CAPTURE_HEADERS_SERVER_REQUEST,\n captureHeadersServerResponse:\n config.captureHeadersServerResponse ??\n getStringFromEnv(\n 'OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SERVER_RESPONSE',\n ) ??\n DEFAULT_CAPTURE_HEADERS_SERVER_RESPONSE,\n consoleCapture:\n config.consoleCapture ??\n getBooleanFromEnv('MXL_NODE_CONSOLE_CAPTURE') ??\n DEFAULT_CONSOLE_CAPTURE,\n contextManager: config.contextManager,\n detectResources: config.detectResources ?? true,\n disableLogs:\n config.disableLogs ?? getStringFromEnv('OTEL_LOGS_EXPORTER') === 'none',\n disableMetrics:\n config.disableMetrics ??\n getStringFromEnv('OTEL_METRICS_EXPORTER') === 'none',\n disableStartupLogs:\n config.disableStartupLogs ??\n !(getBooleanFromEnv('MXL_STARTUP_LOGS') ?? DEFAULT_STARTUP_LOGS_ENABLED),\n disableTracing:\n config.disableTracing ??\n getStringFromEnv('OTEL_TRACES_EXPORTER') === 'none',\n exceptionCaptureEnabled:\n config.exceptionCaptureEnabled ??\n getBooleanFromEnv('MXL_NODE_EXPERIMENTAL_EXCEPTION_CAPTURE') ??\n DEFAULT_EXCEPTION_CAPTURE_ENABLED,\n headerAttributeMap:\n config.headerAttributeMap ??\n parseHeaderAttributeMap(\n getStringFromEnv('MXL_NODE_ROOT_SPAN_HEADER_ATTRIBUTES'),\n ),\n instrumentations: config.instrumentations,\n metricReader: config.metricReader,\n otlpEndpoint:\n config.otlpEndpoint ?? getStringFromEnv('OTEL_EXPORTER_OTLP_ENDPOINT'),\n otlpHeaders:\n config.otlpHeaders ?? getStringFromEnv('OTEL_EXPORTER_OTLP_HEADERS'),\n otlpProtocol:\n config.otlpProtocol ??\n (getStringFromEnv('OTEL_EXPORTER_OTLP_PROTOCOL') as\n | ResolvedSDKConfig['otlpProtocol']\n | undefined) ??\n DEFAULT_OTLP_PROTOCOL,\n profiling: config.profiling,\n sentryIntegrationEnabled:\n config.sentryIntegrationEnabled ??\n getBooleanFromEnv('MXL_NODE_SENTRY_INTEGRATION_ENABLED') ??\n DEFAULT_SENTRY_INTEGRATION_ENABLED,\n serviceName:\n config.serviceName ??\n getStringFromEnv('OTEL_SERVICE_NAME') ??\n DEFAULT_SERVICE_NAME,\n spanLimits: config.spanLimits,\n spanProcessors: config.spanProcessors ?? [],\n stopOnTerminationSignals:\n config.stopOnTerminationSignals ??\n getBooleanFromEnv('MXL_NODE_STOP_ON_TERMINATION_SIGNALS') ??\n DEFAULT_STOP_ON_TERMINATION_SIGNALS,\n traceExporterUrl:\n config.traceExporterUrl ??\n getStringFromEnv('OTEL_EXPORTER_OTLP_TRACES_ENDPOINT'),\n traceSampler:\n config.traceSampler ??\n (getStringFromEnv(\n 'OTEL_TRACES_SAMPLER',\n ) as ResolvedSDKConfig['traceSampler']) ??\n DEFAULT_TRACE_SAMPLER,\n traceSamplerArg:\n config.traceSamplerArg ??\n getStringFromEnv('OTEL_TRACES_SAMPLER_ARG') ??\n DEFAULT_TRACE_SAMPLER_ARG,\n };\n}\n","import { diag } from '@opentelemetry/api';\nimport {\n AlwaysOffSampler,\n AlwaysOnSampler,\n ParentBasedSampler,\n TraceIdRatioBasedSampler,\n} from '@opentelemetry/sdk-trace-base';\nimport type { Sampler } from '@opentelemetry/sdk-trace-base';\nimport type { TraceSamplerName } from './types.ts';\n\nconst DEFAULT_RATIO = 1;\n\nexport function resolveTraceSampler(\n traceSampler: TraceSamplerName | Sampler,\n traceSamplerArg: string,\n): Sampler {\n if (typeof traceSampler !== 'string') {\n return traceSampler;\n }\n\n switch (traceSampler) {\n case 'always_on':\n return new AlwaysOnSampler();\n case 'always_off':\n return new AlwaysOffSampler();\n case 'parentbased_always_on':\n return new ParentBasedSampler({ root: new AlwaysOnSampler() });\n case 'parentbased_always_off':\n return new ParentBasedSampler({ root: new AlwaysOffSampler() });\n case 'traceidratio':\n return new TraceIdRatioBasedSampler(resolveSamplerRatio(traceSamplerArg));\n case 'parentbased_traceidratio':\n return new ParentBasedSampler({\n root: new TraceIdRatioBasedSampler(resolveSamplerRatio(traceSamplerArg)),\n });\n default:\n diag.error(\n `@safaricom-mxl/node-sdk: unknown sampler \"${traceSampler}\", defaulting to always_on`,\n );\n return new AlwaysOnSampler();\n }\n}\n\nfunction resolveSamplerRatio(arg: string): number {\n const parsed = Number(arg);\n if (!Number.isFinite(parsed) || parsed < 0 || parsed > 1) {\n return DEFAULT_RATIO;\n }\n return parsed;\n}\n","import type { ResolvedSDKConfig } from './types.ts';\n\nlet activeConfig: ResolvedSDKConfig | undefined;\n\nexport function setActiveSDKConfig(config: ResolvedSDKConfig | undefined) {\n activeConfig = config;\n}\n\nexport function getActiveSDKConfig() {\n return activeConfig;\n}\n","import { diag } from '@opentelemetry/api';\nimport type { InstrumentationConfigMap } from '@opentelemetry/auto-instrumentations-node';\nimport { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';\nimport { RuntimeNodeInstrumentation } from '@opentelemetry/instrumentation-runtime-node';\nimport { NodeSDK } from '@opentelemetry/sdk-node';\nimport {\n MutableAsyncLocalStorageContextManager,\n setMutableContextManager,\n setTraceAttributes,\n} from '../context/index.ts';\nimport { createMetricReader, createTraceExporter } from '../exporters/index.ts';\nimport { resolveOtlpExporterUrl } from '../exporters/urls.ts';\nimport { createSentryBridge } from '../instrumentations/exceptions/sentry.ts';\nimport {\n ConsoleInstrumentation,\n ExceptionInstrumentation,\n getAdvancedHttpInstrumentationConfig,\n} from '../instrumentations/index.ts';\nimport { OTelLogger } from '../logger/otelLogger.ts';\nimport {\n CompositeSpanProcessor,\n FilterWhenDrainedSpanProcessor,\n NodeSpanProcessor,\n} from '../processors/index.ts';\nimport { ProfilingSpanProcessor } from '../profiling/ProfilingSpanProcessor.ts';\nimport type { CpuProfilerHandle } from '../profiling/profiling.ts';\nimport {\n normalizeProfiling,\n startCpuProfiler,\n} from '../profiling/profiling.ts';\nimport { makeSpanTimeline } from '../profiling/span-timeline.ts';\nimport { createNodeSdkResource } from '../resources/index.ts';\nimport { parseOtlpHeaders } from '../utils/env.ts';\nimport { resolveSDKConfig } from './config.ts';\nimport { resolveTraceSampler } from './sampler.ts';\nimport { setActiveSDKConfig } from './state.ts';\nimport type { SDKConfig, SDKControl } from './types.ts';\n\nlet sdk: NodeSDK | undefined;\nlet logger: OTelLogger | undefined;\nlet contextManager: MutableAsyncLocalStorageContextManager | undefined;\nlet drainableSpanProcessor: FilterWhenDrainedSpanProcessor | undefined;\nlet cpuProfiler: CpuProfilerHandle | undefined;\nlet signalHandlersRegistered = false;\n\nconst terminationHandlers: Array<[NodeJS.Signals, () => void]> = [];\n\nexport function initSDK(config: SDKConfig = {}): SDKControl {\n const resolved = resolveSDKConfig(config);\n setActiveSDKConfig(resolved);\n\n if (sdk) {\n return getControl();\n }\n\n if (!resolved.disableStartupLogs) {\n diag.info('@safaricom-mxl/node-sdk: initializing');\n }\n\n contextManager =\n resolved.contextManager instanceof MutableAsyncLocalStorageContextManager\n ? resolved.contextManager\n : new MutableAsyncLocalStorageContextManager();\n setMutableContextManager(contextManager);\n\n const autoInstrumentationConfig: InstrumentationConfigMap = {\n '@opentelemetry/instrumentation-http': resolved.advancedNetworkCapture\n ? getAdvancedHttpInstrumentationConfig({\n captureBodyKeywordsFilter: resolved.captureBodyKeywordsFilter,\n captureHeadersClientRequest: resolved.captureHeadersClientRequest,\n captureHeadersClientResponse: resolved.captureHeadersClientResponse,\n captureHeadersServerRequest: resolved.captureHeadersServerRequest,\n captureHeadersServerResponse: resolved.captureHeadersServerResponse,\n headerAttributeMap: resolved.headerAttributeMap,\n })\n : { enabled: true },\n '@opentelemetry/instrumentation-fs': { enabled: false },\n ...(resolved.instrumentations ?? {}),\n };\n\n logger = new OTelLogger({ config: resolved });\n const traceExporter = createTraceExporter(resolved);\n const traceProcessor = new NodeSpanProcessor(traceExporter as never);\n const profiling = normalizeProfiling(resolved.profiling);\n const timeline =\n profiling !== undefined &&\n profiling.linkSpans !== false &&\n !resolved.disableTracing\n ? makeSpanTimeline()\n : undefined;\n const spanProcessors = resolved.disableTracing\n ? []\n : [\n (drainableSpanProcessor = new FilterWhenDrainedSpanProcessor(\n new CompositeSpanProcessor([\n traceProcessor,\n ...resolved.spanProcessors,\n ...(timeline === undefined\n ? []\n : [new ProfilingSpanProcessor(timeline)]),\n ]),\n )),\n ];\n\n const instrumentations = [\n ...getNodeAutoInstrumentations(autoInstrumentationConfig),\n new RuntimeNodeInstrumentation(),\n ...(resolved.consoleCapture\n ? [new ConsoleInstrumentation({ config: resolved })]\n : []),\n ...(resolved.exceptionCaptureEnabled\n ? [\n new ExceptionInstrumentation({\n forceFlush,\n captureExceptionHook: createSentryBridge(\n resolved.sentryIntegrationEnabled,\n )?.captureException,\n }),\n ]\n : []),\n ...resolved.additionalInstrumentations,\n ];\n\n sdk = new NodeSDK({\n resource: createNodeSdkResource(resolved),\n contextManager,\n instrumentations,\n metricReaders: resolved.disableMetrics\n ? undefined\n : [resolved.metricReader ?? createMetricReader(resolved)],\n logRecordProcessors: resolved.disableLogs ? [] : [logger.getProcessor()],\n spanProcessors,\n sampler: resolveTraceSampler(\n resolved.traceSampler,\n resolved.traceSamplerArg,\n ),\n spanLimits: resolved.spanLimits,\n } as unknown as ConstructorParameters<typeof NodeSDK>[0]);\n\n sdk.start();\n logger.setGlobalProvider();\n\n if (profiling !== undefined) {\n const tracesUrl = resolveOtlpExporterUrl({\n kind: 'trace',\n endpoint: resolved.otlpEndpoint,\n explicitUrl: resolved.traceExporterUrl,\n });\n cpuProfiler = startCpuProfiler({\n baseUrl: tracesUrl.replace(/\\/v1\\/traces\\/?$/, ''),\n resource: {\n attributes: [\n { key: 'service.name', value: { stringValue: resolved.serviceName } },\n ],\n },\n headers: parseOtlpHeaders(resolved.otlpHeaders),\n profiling,\n timeline,\n });\n }\n\n if (resolved.stopOnTerminationSignals && !signalHandlersRegistered) {\n registerTerminationHandlers();\n }\n\n if (!resolved.disableStartupLogs) {\n diag.info('@safaricom-mxl/node-sdk: initialized');\n }\n\n return getControl();\n}\n\nfunction registerTerminationHandlers() {\n const createTerminationHandler = (signal: NodeJS.Signals) => {\n return () => {\n diag.debug(`@safaricom-mxl/node-sdk: ${signal} received`);\n void shutdown().finally(() => {\n process.exit();\n });\n };\n };\n\n const sigterm = createTerminationHandler('SIGTERM');\n const sigint = createTerminationHandler('SIGINT');\n\n terminationHandlers.push(['SIGTERM', sigterm], ['SIGINT', sigint]);\n process.on('SIGTERM', sigterm);\n process.on('SIGINT', sigint);\n signalHandlersRegistered = true;\n}\n\nexport async function forceFlush() {\n await Promise.all([\n logger?.forceFlush(),\n // The tracer and meter providers are intentionally accessed through the NodeSDK internals.\n // This keeps the flush API small while still forcing all active signals to drain.\n (sdk as any)?._tracerProvider?.forceFlush?.(),\n (sdk as any)?._loggerProvider?.forceFlush?.(),\n (sdk as any)?._meterProvider?.forceFlush?.(),\n ]);\n}\n\nexport function getInitializedOTelLogger() {\n return logger;\n}\n\nexport async function shutdown() {\n if (signalHandlersRegistered) {\n for (const [signal, handler] of terminationHandlers) {\n process.off(signal, handler);\n }\n terminationHandlers.length = 0;\n signalHandlersRegistered = false;\n }\n\n drainableSpanProcessor?.drain();\n await cpuProfiler?.stop();\n cpuProfiler = undefined;\n await Promise.allSettled([logger?.shutdown(), sdk?.shutdown()]);\n sdk = undefined;\n logger = undefined;\n drainableSpanProcessor = undefined;\n setMutableContextManager(undefined);\n setActiveSDKConfig(undefined);\n}\n\nfunction getControl(): SDKControl {\n return {\n forceFlush,\n shutdown,\n setTraceAttributes,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,MAAM,uBAAuB;CAC3B;CACA;CACA;CACA;CACA;AACF;AAEA,IAAsB,mCAAtB,MAEA;CAcE,KAAQ,SAAkB,QAAc;EACtC,IAAI,kBAAkB,cACpB,OAAO,KAAK,kBAAkB,SAAS,MAAM;EAE/C,IAAI,OAAO,WAAW,YACpB,OAAO,KAAK,cAAc,SAAS,MAAM;EAE3C,OAAO;CACT;CAEQ,cAAkC,SAAkB,QAAc;EACxE,MAAM,UAAU;EAChB,MAAM,iBAAiB,SAAuB,GAAG,MAAiB;GAChE,OAAO,QAAQ,KAAK,eAAe,OAAO,MAAM,MAAM,IAAI,CAAC;EAC7D;EACA,OAAO,eAAe,gBAAgB,UAAU;GAC9C,YAAY;GACZ,cAAc;GACd,UAAU;GACV,OAAO,OAAO;EAChB,CAAC;EACD,OAAO;CACT;CAEQ,kBACN,SACA,IACG;EAEH,IADY,KAAK,aAAa,EACxB,MAAM,KAAA,GACV,OAAO;EAET,KAAK,gBAAgB,EAAE;EAEvB,qBAAqB,SAAS,eAAe;GAC3C,IAAI,GAAG,gBAAgB,KAAA,GACrB;GAEF,GAAG,cAAc,KAAK,kBAAkB,IAAI,GAAG,aAAa,OAAO;EACrE,CAAC;EACD,IAAI,OAAO,GAAG,mBAAmB,YAC/B,GAAG,iBAAiB,KAAK,qBAAqB,IAAI,GAAG,cAAc;EAErE,IAAI,OAAO,GAAG,QAAQ,YACpB,GAAG,MAAM,KAAK,qBAAqB,IAAI,GAA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AY,qBAC9B,QAAQ,IAAI,QAAQ,OAAO;EAE7B,oBAAoB,SAAS;EAC7B,2BAA2B;CAC7B;CAEA,wBAAwB,MAAM;CAC9B,MAAM,aAAa,KAAK;CACxB,cAAc,KAAA;CACd,MAAM,QAAQ,WAAW,CAAC,QAAQ,SAAS,GAAG,KAAK,SAAS,CAAC,CAAC;CAC9D,MAAM,KAAA;CACN,SAAS,KAAA;CACT,yBAAyB,KAAA;CACzB,yBAAyB,KAAA,CAAS;CAClC,mBAAmB,KAAA,CAAS;AAC9B;AAEA,SAAS,aAAyB;CAChC,OAAO;EACL;EACA;EACA;CACF;AACF"}
|
package/dist/logger/evlog.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
let _opentelemetry_api = require("@opentelemetry/api");
|
|
3
3
|
let evlog = require("evlog");
|
|
4
|
-
const require_otelLogger = require("../otelLogger-
|
|
5
|
-
const require_initSDK = require("../initSDK-
|
|
4
|
+
const require_otelLogger = require("../otelLogger-YG7L3G5Q.cjs");
|
|
5
|
+
const require_initSDK = require("../initSDK-CPCU4L5z.cjs");
|
|
6
6
|
// src/logger/evlog.ts
|
|
7
7
|
const LEVEL_SEVERITY = {
|
|
8
8
|
debug: {
|
package/dist/logger/evlog.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { context, isSpanContextValid, trace } from "@opentelemetry/api";
|
|
2
2
|
import { auditOnly } from "evlog";
|
|
3
|
-
import { t as OTelLogger } from "../otelLogger-
|
|
4
|
-
import { a as getActiveSDKConfig, n as getInitializedOTelLogger, o as resolveSDKConfig } from "../initSDK-
|
|
3
|
+
import { t as OTelLogger } from "../otelLogger-C_p4pOdm.mjs";
|
|
4
|
+
import { a as getActiveSDKConfig, n as getInitializedOTelLogger, o as resolveSDKConfig } from "../initSDK-DJtki_L0.mjs";
|
|
5
5
|
// src/logger/evlog.ts
|
|
6
6
|
const LEVEL_SEVERITY = {
|
|
7
7
|
debug: {
|
package/dist/logger/nest.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_otelLogger = require("../otelLogger-
|
|
2
|
+
const require_otelLogger = require("../otelLogger-YG7L3G5Q.cjs");
|
|
3
3
|
// src/logger/nest.ts
|
|
4
4
|
var OTelNestLogger = class {
|
|
5
5
|
logger;
|
package/dist/logger/nest.mjs
CHANGED
package/dist/logger/pino.cjs
CHANGED
|
@@ -7,7 +7,7 @@ let _opentelemetry_api = require("@opentelemetry/api");
|
|
|
7
7
|
let lodash_isstring = require("lodash.isstring");
|
|
8
8
|
let pino_abstract_transport = require("pino-abstract-transport");
|
|
9
9
|
const require_json = require("../json-CbEbCXvy.cjs");
|
|
10
|
-
const require_otelLogger = require("../otelLogger-
|
|
10
|
+
const require_otelLogger = require("../otelLogger-YG7L3G5Q.cjs");
|
|
11
11
|
lodash_isstring = require_rolldown_runtime.__toESM(lodash_isstring, 1);
|
|
12
12
|
pino_abstract_transport = require_rolldown_runtime.__toESM(pino_abstract_transport, 1);
|
|
13
13
|
// src/logger/pino.ts
|
package/dist/logger/pino.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { context, isSpanContextValid, trace } from "@opentelemetry/api";
|
|
|
2
2
|
import isString from "lodash.isstring";
|
|
3
3
|
import build from "pino-abstract-transport";
|
|
4
4
|
import { t as jsonToString } from "../json-D8GZ_Psl.mjs";
|
|
5
|
-
import { t as OTelLogger } from "../otelLogger-
|
|
5
|
+
import { t as OTelLogger } from "../otelLogger-C_p4pOdm.mjs";
|
|
6
6
|
// src/logger/pino.ts
|
|
7
7
|
const PINO_LEVELS = {
|
|
8
8
|
10: "trace",
|
package/dist/logger/winston.cjs
CHANGED
|
@@ -4,7 +4,7 @@ let lodash_isplainobject = require("lodash.isplainobject");
|
|
|
4
4
|
let lodash_isstring = require("lodash.isstring");
|
|
5
5
|
let winston_transport = require("winston-transport");
|
|
6
6
|
const require_json = require("../json-CbEbCXvy.cjs");
|
|
7
|
-
const require_otelLogger = require("../otelLogger-
|
|
7
|
+
const require_otelLogger = require("../otelLogger-YG7L3G5Q.cjs");
|
|
8
8
|
lodash_isplainobject = require_rolldown_runtime.__toESM(lodash_isplainobject, 1);
|
|
9
9
|
lodash_isstring = require_rolldown_runtime.__toESM(lodash_isstring, 1);
|
|
10
10
|
winston_transport = require_rolldown_runtime.__toESM(winston_transport, 1);
|
package/dist/logger/winston.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import isPlainObject from "lodash.isplainobject";
|
|
|
2
2
|
import isString from "lodash.isstring";
|
|
3
3
|
import Transport from "winston-transport";
|
|
4
4
|
import { t as jsonToString } from "../json-D8GZ_Psl.mjs";
|
|
5
|
-
import { t as OTelLogger } from "../otelLogger-
|
|
5
|
+
import { t as OTelLogger } from "../otelLogger-C_p4pOdm.mjs";
|
|
6
6
|
// src/logger/winston.ts
|
|
7
7
|
function parseWinstonLog(log) {
|
|
8
8
|
const { level, message, ...attributes } = log;
|
|
@@ -6,7 +6,7 @@ import { resourceFromAttributes } from "@opentelemetry/resources";
|
|
|
6
6
|
import { BatchLogRecordProcessor, LoggerProvider } from "@opentelemetry/sdk-logs";
|
|
7
7
|
import { ATTR_SERVICE_NAME } from "@opentelemetry/semantic-conventions";
|
|
8
8
|
// src/constants/index.ts
|
|
9
|
-
const NODE_SDK_VERSION = "0.0.
|
|
9
|
+
const NODE_SDK_VERSION = "0.0.21";
|
|
10
10
|
const NODE_SDK_NAME = "@safaricom-mxl/node-sdk";
|
|
11
11
|
const DEFAULT_TRACE_SAMPLER = "parentbased_always_on";
|
|
12
12
|
const DEFAULT_OTLP_PROTOCOL = "http/protobuf";
|
|
@@ -179,4 +179,4 @@ var OTelLogger = class {
|
|
|
179
179
|
};
|
|
180
180
|
export { parseHeaderAttributeMap as a, DEFAULT_METRIC_EXPORT_TIMEOUT_MS as c, DEFAULT_TRACE_TIMEOUT_MS as d, NODE_SDK_NAME as f, getStringFromEnv as i, DEFAULT_OTLP_PROTOCOL as l, resolveOtlpExporterUrl as n, parseOtlpHeaders as o, NODE_SDK_VERSION as p, getBooleanFromEnv as r, DEFAULT_METRIC_EXPORT_INTERVAL_MS as s, OTelLogger as t, DEFAULT_TRACE_SAMPLER as u };
|
|
181
181
|
|
|
182
|
-
//# sourceMappingURL=otelLogger-
|
|
182
|
+
//# sourceMappingURL=otelLogger-C_p4pOdm.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otelLogger-Bt7O4s1o.mjs","names":["apiContext","OTLPLogExporterGRPC","OTLPLogExporterHTTP"],"sources":["../src/constants/index.ts","../src/utils/env.ts","../src/exporters/urls.ts","../src/logger/otelLogger.ts"],"sourcesContent":["export const NODE_SDK_VERSION = '0.0.19';\nexport const NODE_SDK_NAME = '@safaricom-mxl/node-sdk';\nexport const NODE_SDK_SERVICE_NAME = 'mxl-node-sdk';\n\nexport const DEFAULT_SERVICE_NAME = 'app';\nexport const DEFAULT_TRACE_SAMPLER = 'parentbased_always_on';\nexport const DEFAULT_TRACE_SAMPLER_ARG = '1';\n\nexport const DEFAULT_OTLP_PROTOCOL = 'http/protobuf';\nexport const DEFAULT_TRACE_EXPORTER_PATH = '/v1/traces';\nexport const DEFAULT_LOG_EXPORTER_PATH = '/v1/logs';\nexport const DEFAULT_METRIC_EXPORTER_PATH = '/v1/metrics';\n\nexport const DEFAULT_TRACE_EXPORTER_URL = 'http://localhost:4318/v1/traces';\nexport const DEFAULT_LOG_EXPORTER_URL = 'http://localhost:4318/v1/logs';\nexport const DEFAULT_METRIC_EXPORTER_URL = 'http://localhost:4318/v1/metrics';\n\nexport const DEFAULT_TRACE_TIMEOUT_MS = 60000;\nexport const DEFAULT_LOG_TIMEOUT_MS = 30000;\nexport const DEFAULT_LOG_QUEUE_SIZE = 2048;\nexport const DEFAULT_LOG_EXPORT_BATCH_SIZE = 512;\nexport const DEFAULT_LOG_SCHEDULE_DELAY_MS = 2000;\nexport const DEFAULT_METRIC_EXPORT_INTERVAL_MS = 60000;\nexport const DEFAULT_METRIC_EXPORT_TIMEOUT_MS = 30000;\n\nexport const DEFAULT_CONSOLE_CAPTURE = true;\nexport const DEFAULT_ADVANCED_NETWORK_CAPTURE = false;\nexport const DEFAULT_BETA_MODE = false;\nexport const DEFAULT_STOP_ON_TERMINATION_SIGNALS = true;\nexport const DEFAULT_SENTRY_INTEGRATION_ENABLED = false;\nexport const DEFAULT_EXCEPTION_CAPTURE_ENABLED = true;\nexport const DEFAULT_STARTUP_LOGS_ENABLED = true;\n\nexport const DEFAULT_CAPTURE_HEADERS_CLIENT_REQUEST = '';\nexport const DEFAULT_CAPTURE_HEADERS_CLIENT_RESPONSE = '';\nexport const DEFAULT_CAPTURE_HEADERS_SERVER_REQUEST = '';\nexport const DEFAULT_CAPTURE_HEADERS_SERVER_RESPONSE = '';\nexport const DEFAULT_CAPTURE_BODY_KEYWORDS_FILTER = '';\n","export function getStringFromEnv(key: string): string | undefined {\n const raw = process.env[key];\n if (!raw || raw.trim() === '') {\n return undefined;\n }\n return raw;\n}\n\nexport function getStringListFromEnv(key: string): string[] | undefined {\n return getStringFromEnv(key)\n ?.split(',')\n .map((item) => item.trim())\n .filter(Boolean);\n}\n\nexport function getBooleanFromEnv(key: string): boolean | undefined {\n const value = getStringFromEnv(key)?.toLowerCase();\n switch (value) {\n case '1':\n case 'true':\n case 'yes':\n return true;\n case '0':\n case 'false':\n case 'no':\n return false;\n default:\n return undefined;\n }\n}\n\nexport function getNumberFromEnv(key: string): number | undefined {\n const value = getStringFromEnv(key);\n if (!value) {\n return undefined;\n }\n const parsed = Number(value);\n return Number.isFinite(parsed) ? parsed : undefined;\n}\n\nexport function parseOtlpHeaders(headersString?: string): Record<string, string> {\n if (!headersString) {\n return {};\n }\n const result: Record<string, string> = {};\n for (const pair of headersString.split(',')) {\n const trimmedPair = pair.trim();\n if (!trimmedPair) {\n continue;\n }\n const equalIndex = trimmedPair.indexOf('=');\n if (equalIndex === -1) {\n continue;\n }\n const key = trimmedPair.slice(0, equalIndex).trim();\n const value = trimmedPair.slice(equalIndex + 1).trim();\n if (key) {\n result[key] = value;\n }\n }\n return result;\n}\n\nexport function parseHeaderAttributeMap(\n mapString?: string,\n): Record<string, string> {\n if (!mapString) {\n return {};\n }\n const result: Record<string, string> = {};\n for (const pair of mapString.split(',')) {\n const trimmed = pair.trim();\n if (!trimmed) {\n continue;\n }\n const separator = trimmed.indexOf('=');\n if (separator === -1) {\n continue;\n }\n const header = trimmed.slice(0, separator).trim().toLowerCase();\n const attribute = trimmed.slice(separator + 1).trim();\n if (header && attribute) {\n result[header] = attribute;\n }\n }\n return result;\n}\n","import {\n DEFAULT_LOG_EXPORTER_PATH,\n DEFAULT_LOG_EXPORTER_URL,\n DEFAULT_METRIC_EXPORTER_PATH,\n DEFAULT_METRIC_EXPORTER_URL,\n DEFAULT_TRACE_EXPORTER_PATH,\n DEFAULT_TRACE_EXPORTER_URL,\n} from '../constants/index.ts';\n\ntype ExporterKind = 'trace' | 'log' | 'metric';\n\nexport function resolveOtlpExporterUrl({\n kind,\n endpoint,\n explicitUrl,\n}: {\n kind: ExporterKind;\n endpoint?: string;\n explicitUrl?: string;\n}) {\n if (explicitUrl) {\n return explicitUrl;\n }\n\n if (endpoint) {\n const normalized = endpoint.replace(/\\/$/, '');\n if (kind === 'trace') {\n return `${normalized}${DEFAULT_TRACE_EXPORTER_PATH}`;\n }\n if (kind === 'log') {\n return `${normalized}${DEFAULT_LOG_EXPORTER_PATH}`;\n }\n return `${normalized}${DEFAULT_METRIC_EXPORTER_PATH}`;\n }\n\n if (kind === 'trace') {\n return DEFAULT_TRACE_EXPORTER_URL;\n }\n if (kind === 'log') {\n return DEFAULT_LOG_EXPORTER_URL;\n }\n return DEFAULT_METRIC_EXPORTER_URL;\n}\n","import { Attributes, context as apiContext, trace } from '@opentelemetry/api';\nimport { Logger as OTelLoggerAPI, LogRecord, logs } from '@opentelemetry/api-logs';\nimport { OTLPLogExporter as OTLPLogExporterGRPC } from '@opentelemetry/exporter-logs-otlp-grpc';\nimport { OTLPLogExporter as OTLPLogExporterHTTP } from '@opentelemetry/exporter-logs-otlp-http';\nimport { resourceFromAttributes } from '@opentelemetry/resources';\nimport {\n LoggerProvider,\n BatchLogRecordProcessor,\n type LogRecordProcessor,\n} from '@opentelemetry/sdk-logs';\nimport { ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions';\nimport {\n DEFAULT_LOG_EXPORT_BATCH_SIZE,\n DEFAULT_LOG_QUEUE_SIZE,\n DEFAULT_LOG_SCHEDULE_DELAY_MS,\n DEFAULT_LOG_TIMEOUT_MS,\n NODE_SDK_VERSION,\n} from '../constants/index.ts';\nimport type { ResolvedSDKConfig } from '../sdk/types.ts';\nimport { parseOtlpHeaders } from '../utils/env.ts';\nimport { resolveOtlpExporterUrl } from '../exporters/urls.ts';\n\nfunction loadContext(logRecord: LogRecord): LogRecord {\n let recordContext = apiContext.active();\n let attributes = logRecord.attributes;\n\n if (attributes) {\n const { trace_id, span_id, trace_flags, ...other } = attributes as Attributes & {\n trace_id?: string;\n span_id?: string;\n trace_flags?: number;\n };\n\n if (trace_id && span_id) {\n recordContext = trace.setSpanContext(recordContext, {\n traceId: trace_id,\n spanId: span_id,\n traceFlags: trace_flags ?? 1,\n isRemote: true,\n });\n }\n attributes = other;\n }\n\n return { ...logRecord, attributes, context: recordContext };\n}\n\nexport type LoggerOptions = {\n config: ResolvedSDKConfig;\n resourceAttributes?: Attributes;\n};\n\nexport type OTelLogEmitOptions = {\n scope?: string;\n severityNumber?: number;\n severityText?: string;\n};\n\nexport class OTelLogger {\n private readonly url: string;\n private readonly logger: OTelLoggerAPI;\n private readonly processor: BatchLogRecordProcessor | LogRecordProcessor;\n private readonly provider: LoggerProvider;\n\n constructor({ config, resourceAttributes }: LoggerOptions) {\n this.url = resolveOtlpExporterUrl({\n kind: 'log',\n endpoint: config.otlpEndpoint,\n });\n\n const exporterHeaders = parseOtlpHeaders(config.otlpHeaders);\n if (config.apiKey) {\n exporterHeaders.Authorization = config.apiKey;\n }\n\n const exporter =\n config.otlpProtocol === 'grpc'\n ? new OTLPLogExporterGRPC({\n url: this.url,\n headers: exporterHeaders,\n } as ConstructorParameters<typeof OTLPLogExporterGRPC>[0])\n : new OTLPLogExporterHTTP({ url: this.url, headers: exporterHeaders });\n\n const noopLogRecordProcessor: LogRecordProcessor = {\n forceFlush() {\n return Promise.resolve();\n },\n onEmit() {},\n shutdown() {\n return Promise.resolve();\n },\n };\n\n this.processor = config.disableLogs\n ? noopLogRecordProcessor\n : new BatchLogRecordProcessor({\n exporter,\n maxExportBatchSize: DEFAULT_LOG_EXPORT_BATCH_SIZE,\n maxQueueSize: DEFAULT_LOG_QUEUE_SIZE,\n scheduledDelayMillis: DEFAULT_LOG_SCHEDULE_DELAY_MS,\n exportTimeoutMillis: DEFAULT_LOG_TIMEOUT_MS,\n });\n\n this.provider = new LoggerProvider({\n resource: resourceFromAttributes({\n [ATTR_SERVICE_NAME]: config.serviceName,\n 'telemetry.distro.name': 'mxl-node-sdk',\n 'telemetry.distro.version': NODE_SDK_VERSION,\n ...resourceAttributes,\n }),\n processors: [this.processor],\n });\n\n this.logger = this.provider.getLogger('node-sdk');\n }\n\n setGlobalProvider() {\n logs.setGlobalLoggerProvider(this.provider);\n }\n\n getProcessor() {\n return this.processor;\n }\n\n getProvider() {\n return this.provider;\n }\n\n getLoggerByName(name: string): OTelLoggerAPI {\n return this.provider.getLogger(name);\n }\n\n getExporterUrl() {\n return this.url;\n }\n\n shutdown() {\n return this.processor.shutdown();\n }\n\n forceFlush() {\n return this.processor.forceFlush();\n }\n\n postMessage(\n level: string,\n message: string,\n attributes: Attributes = {},\n opts?: OTelLogEmitOptions,\n ) {\n const targetLogger = opts?.scope ? this.getLoggerByName(opts.scope) : this.logger;\n targetLogger.emit(\n loadContext({\n severityNumber: opts?.severityNumber ?? 0,\n severityText: opts?.severityText ?? level,\n body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{"version":3,"file":"otelLogger-C_p4pOdm.mjs","names":["apiContext","OTLPLogExporterGRPC","OTLPLogExporterHTTP"],"sources":["../src/constants/index.ts","../src/utils/env.ts","../src/exporters/urls.ts","../src/logger/otelLogger.ts"],"sourcesContent":["export const NODE_SDK_VERSION = '0.0.21';\nexport const NODE_SDK_NAME = '@safaricom-mxl/node-sdk';\nexport const NODE_SDK_SERVICE_NAME = 'mxl-node-sdk';\n\nexport const DEFAULT_SERVICE_NAME = 'app';\nexport const DEFAULT_TRACE_SAMPLER = 'parentbased_always_on';\nexport const DEFAULT_TRACE_SAMPLER_ARG = '1';\n\nexport const DEFAULT_OTLP_PROTOCOL = 'http/protobuf';\nexport const DEFAULT_TRACE_EXPORTER_PATH = '/v1/traces';\nexport const DEFAULT_LOG_EXPORTER_PATH = '/v1/logs';\nexport const DEFAULT_METRIC_EXPORTER_PATH = '/v1/metrics';\n\nexport const DEFAULT_TRACE_EXPORTER_URL = 'http://localhost:4318/v1/traces';\nexport const DEFAULT_LOG_EXPORTER_URL = 'http://localhost:4318/v1/logs';\nexport const DEFAULT_METRIC_EXPORTER_URL = 'http://localhost:4318/v1/metrics';\n\nexport const DEFAULT_TRACE_TIMEOUT_MS = 60000;\nexport const DEFAULT_LOG_TIMEOUT_MS = 30000;\nexport const DEFAULT_LOG_QUEUE_SIZE = 2048;\nexport const DEFAULT_LOG_EXPORT_BATCH_SIZE = 512;\nexport const DEFAULT_LOG_SCHEDULE_DELAY_MS = 2000;\nexport const DEFAULT_METRIC_EXPORT_INTERVAL_MS = 60000;\nexport const DEFAULT_METRIC_EXPORT_TIMEOUT_MS = 30000;\n\nexport const DEFAULT_CONSOLE_CAPTURE = true;\nexport const DEFAULT_ADVANCED_NETWORK_CAPTURE = false;\nexport const DEFAULT_BETA_MODE = false;\nexport const DEFAULT_STOP_ON_TERMINATION_SIGNALS = true;\nexport const DEFAULT_SENTRY_INTEGRATION_ENABLED = false;\nexport const DEFAULT_EXCEPTION_CAPTURE_ENABLED = true;\nexport const DEFAULT_STARTUP_LOGS_ENABLED = true;\n\nexport const DEFAULT_CAPTURE_HEADERS_CLIENT_REQUEST = '';\nexport const DEFAULT_CAPTURE_HEADERS_CLIENT_RESPONSE = '';\nexport const DEFAULT_CAPTURE_HEADERS_SERVER_REQUEST = '';\nexport const DEFAULT_CAPTURE_HEADERS_SERVER_RESPONSE = '';\nexport const DEFAULT_CAPTURE_BODY_KEYWORDS_FILTER = '';\n","export function getStringFromEnv(key: string): string | undefined {\n const raw = process.env[key];\n if (!raw || raw.trim() === '') {\n return undefined;\n }\n return raw;\n}\n\nexport function getStringListFromEnv(key: string): string[] | undefined {\n return getStringFromEnv(key)\n ?.split(',')\n .map((item) => item.trim())\n .filter(Boolean);\n}\n\nexport function getBooleanFromEnv(key: string): boolean | undefined {\n const value = getStringFromEnv(key)?.toLowerCase();\n switch (value) {\n case '1':\n case 'true':\n case 'yes':\n return true;\n case '0':\n case 'false':\n case 'no':\n return false;\n default:\n return undefined;\n }\n}\n\nexport function getNumberFromEnv(key: string): number | undefined {\n const value = getStringFromEnv(key);\n if (!value) {\n return undefined;\n }\n const parsed = Number(value);\n return Number.isFinite(parsed) ? parsed : undefined;\n}\n\nexport function parseOtlpHeaders(headersString?: string): Record<string, string> {\n if (!headersString) {\n return {};\n }\n const result: Record<string, string> = {};\n for (const pair of headersString.split(',')) {\n const trimmedPair = pair.trim();\n if (!trimmedPair) {\n continue;\n }\n const equalIndex = trimmedPair.indexOf('=');\n if (equalIndex === -1) {\n continue;\n }\n const key = trimmedPair.slice(0, equalIndex).trim();\n const value = trimmedPair.slice(equalIndex + 1).trim();\n if (key) {\n result[key] = value;\n }\n }\n return result;\n}\n\nexport function parseHeaderAttributeMap(\n mapString?: string,\n): Record<string, string> {\n if (!mapString) {\n return {};\n }\n const result: Record<string, string> = {};\n for (const pair of mapString.split(',')) {\n const trimmed = pair.trim();\n if (!trimmed) {\n continue;\n }\n const separator = trimmed.indexOf('=');\n if (separator === -1) {\n continue;\n }\n const header = trimmed.slice(0, separator).trim().toLowerCase();\n const attribute = trimmed.slice(separator + 1).trim();\n if (header && attribute) {\n result[header] = attribute;\n }\n }\n return result;\n}\n","import {\n DEFAULT_LOG_EXPORTER_PATH,\n DEFAULT_LOG_EXPORTER_URL,\n DEFAULT_METRIC_EXPORTER_PATH,\n DEFAULT_METRIC_EXPORTER_URL,\n DEFAULT_TRACE_EXPORTER_PATH,\n DEFAULT_TRACE_EXPORTER_URL,\n} from '../constants/index.ts';\n\ntype ExporterKind = 'trace' | 'log' | 'metric';\n\nexport function resolveOtlpExporterUrl({\n kind,\n endpoint,\n explicitUrl,\n}: {\n kind: ExporterKind;\n endpoint?: string;\n explicitUrl?: string;\n}) {\n if (explicitUrl) {\n return explicitUrl;\n }\n\n if (endpoint) {\n const normalized = endpoint.replace(/\\/$/, '');\n if (kind === 'trace') {\n return `${normalized}${DEFAULT_TRACE_EXPORTER_PATH}`;\n }\n if (kind === 'log') {\n return `${normalized}${DEFAULT_LOG_EXPORTER_PATH}`;\n }\n return `${normalized}${DEFAULT_METRIC_EXPORTER_PATH}`;\n }\n\n if (kind === 'trace') {\n return DEFAULT_TRACE_EXPORTER_URL;\n }\n if (kind === 'log') {\n return DEFAULT_LOG_EXPORTER_URL;\n }\n return DEFAULT_METRIC_EXPORTER_URL;\n}\n","import { Attributes, context as apiContext, trace } from '@opentelemetry/api';\nimport { Logger as OTelLoggerAPI, LogRecord, logs } from '@opentelemetry/api-logs';\nimport { OTLPLogExporter as OTLPLogExporterGRPC } from '@opentelemetry/exporter-logs-otlp-grpc';\nimport { OTLPLogExporter as OTLPLogExporterHTTP } from '@opentelemetry/exporter-logs-otlp-http';\nimport { resourceFromAttributes } from '@opentelemetry/resources';\nimport {\n LoggerProvider,\n BatchLogRecordProcessor,\n type LogRecordProcessor,\n} from '@opentelemetry/sdk-logs';\nimport { ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions';\nimport {\n DEFAULT_LOG_EXPORT_BATCH_SIZE,\n DEFAULT_LOG_QUEUE_SIZE,\n DEFAULT_LOG_SCHEDULE_DELAY_MS,\n DEFAULT_LOG_TIMEOUT_MS,\n NODE_SDK_VERSION,\n} from '../constants/index.ts';\nimport type { ResolvedSDKConfig } from '../sdk/types.ts';\nimport { parseOtlpHeaders } from '../utils/env.ts';\nimport { resolveOtlpExporterUrl } from '../exporters/urls.ts';\n\nfunction loadContext(logRecord: LogRecord): LogRecord {\n let recordContext = apiContext.active();\n let attributes = logRecord.attributes;\n\n if (attributes) {\n const { trace_id, span_id, trace_flags, ...other } = attributes as Attributes & {\n trace_id?: string;\n span_id?: string;\n trace_flags?: number;\n };\n\n if (trace_id && span_id) {\n recordContext = trace.setSpanContext(recordContext, {\n traceId: trace_id,\n spanId: span_id,\n traceFlags: trace_flags ?? 1,\n isRemote: true,\n });\n }\n attributes = other;\n }\n\n return { ...logRecord, attributes, context: recordContext };\n}\n\nexport type LoggerOptions = {\n config: ResolvedSDKConfig;\n resourceAttributes?: Attributes;\n};\n\nexport type OTelLogEmitOptions = {\n scope?: string;\n severityNumber?: number;\n severityText?: string;\n};\n\nexport class OTelLogger {\n private readonly url: string;\n private readonly logger: OTelLoggerAPI;\n private readonly processor: BatchLogRecordProcessor | LogRecordProcessor;\n private readonly provider: LoggerProvider;\n\n constructor({ config, resourceAttributes }: LoggerOptions) {\n this.url = resolveOtlpExporterUrl({\n kind: 'log',\n endpoint: config.otlpEndpoint,\n });\n\n const exporterHeaders = parseOtlpHeaders(config.otlpHeaders);\n if (config.apiKey) {\n exporterHeaders.Authorization = config.apiKey;\n }\n\n const exporter =\n config.otlpProtocol === 'grpc'\n ? new OTLPLogExporterGRPC({\n url: this.url,\n headers: exporterHeaders,\n } as ConstructorParameters<typeof OTLPLogExporterGRPC>[0])\n : new OTLPLogExporterHTTP({ url: this.url, headers: exporterHeaders });\n\n const noopLogRecordProcessor: LogRecordProcessor = {\n forceFlush() {\n return Promise.resolve();\n },\n onEmit() {},\n shutdown() {\n return Promise.resolve();\n },\n };\n\n this.processor = config.disableLogs\n ? noopLogRecordProcessor\n : new BatchLogRecordProcessor({\n exporter,\n maxExportBatchSize: DEFAULT_LOG_EXPORT_BATCH_SIZE,\n maxQueueSize: DEFAULT_LOG_QUEUE_SIZE,\n scheduledDelayMillis: DEFAULT_LOG_SCHEDULE_DELAY_MS,\n exportTimeoutMillis: DEFAULT_LOG_TIMEOUT_MS,\n });\n\n this.provider = new LoggerProvider({\n resource: resourceFromAttributes({\n [ATTR_SERVICE_NAME]: config.serviceName,\n 'telemetry.distro.name': 'mxl-node-sdk',\n 'telemetry.distro.version': NODE_SDK_VERSION,\n ...resourceAttributes,\n }),\n processors: [this.processor],\n });\n\n this.logger = this.provider.getLogger('node-sdk');\n }\n\n setGlobalProvider() {\n logs.setGlobalLoggerProvider(this.provider);\n }\n\n getProcessor() {\n return this.processor;\n }\n\n getProvider() {\n return this.provider;\n }\n\n getLoggerByName(name: string): OTelLoggerAPI {\n return this.provider.getLogger(name);\n }\n\n getExporterUrl() {\n return this.url;\n }\n\n shutdown() {\n return this.processor.shutdown();\n }\n\n forceFlush() {\n return this.processor.forceFlush();\n }\n\n postMessage(\n level: string,\n message: string,\n attributes: Attributes = {},\n opts?: OTelLogEmitOptions,\n ) {\n const targetLogger = opts?.scope ? this.getLoggerByName(opts.scope) : this.logger;\n targetLogger.emit(\n loadContext({\n severityNumber: opts?.severityNumber ?? 0,\n severityText: opts?.severityText ?? level,\n body: message,\n attributes,\n timestamp: new Date(),\n }),\n );\n }\n}\n"],"mappings":";;;;;;;;AAAA,MAAa,mBAAmB;AAChC,MAAa,gBAAgB;AAI7B,MAAa,wBAAwB;AAGrC,MAAa,wBAAwB;AACrC,MAAa,8BAA8B;AAC3C,MAAa,4BAA4B;AACzC,MAAa,+BAA+B;AAE5C,MAAa,6BAA6B;AAC1C,MAAa,2BAA2B;AACxC,MAAa,8BAA8B;AAE3C,MAAa,2BAA2B;AACxC,MAAa,yBAAyB;AACtC,MAAa,yBAAyB;AAEtC,M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,IAAI,wBAAwB;GAC1B;GACA,oBAAA;GACA,cAAc;GACd,sBAAsB;GACtB,qBAAqB;EACvB,CAAC;EAEL,KAAK,WAAW,IAAI,eAAe;GACjC,UAAU,uBAAuB;KAC5B,oBAAoB,OAAO;IAC5B,yBAAyB;IACzB,4BAA4B;IAC5B,GAAG;GACP,CAAC;GACD,YAAY,CAAC,KAAK,SAAS;EAC7B,CAAC;EAED,KAAK,SAAS,KAAK,SAAS,UAAU,UAAU;CAClD;CAEA,oBAAoB;EAClB,KAAK,wBAAwB,KAAK,QAAQ;CAC5C;CAEA,eAAe;EACb,OAAO,KAAK;CACd;CAEA,cAAc;EACZ,OAAO,KAAK;CACd;CAEA,gBAAgB,MAA6B;EAC3C,OAAO,KAAK,SAAS,UAAU,IAAI;CACrC;CAEA,iBAAiB;EACf,OAAO,KAAK;CACd;CAEA,WAAW;EACT,OAAO,KAAK,UAAU,SAAS;CACjC;CAEA,aAAa;EACX,OAAO,KAAK,UAAU,WAAW;CACnC;CAEA,YACE,OACA,SACA,aAAyB,CAAC,GAC1B,MACA;EAEA,CADqB,MAAM,QAAQ,KAAK,gBAAgB,KAAK,KAAK,IAAI,KAAK,OAAA,CAC9D,KACX,YAAY;GACV,gBAAgB,MAAM,kBAAkB;GACxC,cAAc,MAAM,gBAAgB;GACpC,MAAM;GACN;GACA,2BAAW,IAAI,KAAK;EACtB,CAAC,CACH;CACF;AACF"}
|
|
@@ -6,7 +6,7 @@ let _opentelemetry_resources = require("@opentelemetry/resources");
|
|
|
6
6
|
let _opentelemetry_sdk_logs = require("@opentelemetry/sdk-logs");
|
|
7
7
|
let _opentelemetry_semantic_conventions = require("@opentelemetry/semantic-conventions");
|
|
8
8
|
// src/constants/index.ts
|
|
9
|
-
const NODE_SDK_VERSION = "0.0.
|
|
9
|
+
const NODE_SDK_VERSION = "0.0.21";
|
|
10
10
|
const NODE_SDK_NAME = "@safaricom-mxl/node-sdk";
|
|
11
11
|
const DEFAULT_TRACE_SAMPLER = "parentbased_always_on";
|
|
12
12
|
const DEFAULT_OTLP_PROTOCOL = "http/protobuf";
|
package/dist/tracing.cjs
CHANGED
|
@@ -2,7 +2,7 @@ Object.defineProperties(exports, {
|
|
|
2
2
|
__esModule: { value: true },
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
|
-
const require_initSDK = require("./initSDK-
|
|
5
|
+
const require_initSDK = require("./initSDK-CPCU4L5z.cjs");
|
|
6
6
|
// src/tracing.ts
|
|
7
7
|
const sdkControl = require_initSDK.initSDK({});
|
|
8
8
|
exports.default = sdkControl;
|
package/dist/tracing.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as shutdown, n as getInitializedOTelLogger, r as initSDK, t as forceFlush } from "./initSDK-
|
|
1
|
+
import { i as shutdown, n as getInitializedOTelLogger, r as initSDK, t as forceFlush } from "./initSDK-DJtki_L0.mjs";
|
|
2
2
|
// src/tracing.ts
|
|
3
3
|
const sdkControl = initSDK({});
|
|
4
4
|
export { sdkControl as default, forceFlush, getInitializedOTelLogger, initSDK, shutdown };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@safaricom-mxl/node-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.21",
|
|
4
4
|
"description": "MXL Node.js OpenTelemetry SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -13,15 +13,6 @@
|
|
|
13
13
|
"access": "public"
|
|
14
14
|
},
|
|
15
15
|
"sideEffects": false,
|
|
16
|
-
"scripts": {
|
|
17
|
-
"clean": "rimraf dist",
|
|
18
|
-
"build": "tsdown",
|
|
19
|
-
"dev": "tsdown --watch --no-clean",
|
|
20
|
-
"check": "tsc",
|
|
21
|
-
"test": "tsx --test src/**/*.test.ts",
|
|
22
|
-
"bench:profiling": "tsdown && node --experimental-strip-types bench/profiling.ts",
|
|
23
|
-
"validate": "tsx scripts/validate.ts"
|
|
24
|
-
},
|
|
25
16
|
"files": [
|
|
26
17
|
"dist",
|
|
27
18
|
"*.md"
|
|
@@ -127,24 +118,24 @@
|
|
|
127
118
|
"telemetry"
|
|
128
119
|
],
|
|
129
120
|
"dependencies": {
|
|
130
|
-
"@opentelemetry/api": "
|
|
131
|
-
"@opentelemetry/api-logs": "
|
|
132
|
-
"@opentelemetry/auto-instrumentations-node": "
|
|
133
|
-
"@opentelemetry/exporter-logs-otlp-grpc": "
|
|
134
|
-
"@opentelemetry/exporter-logs-otlp-http": "
|
|
135
|
-
"@opentelemetry/exporter-metrics-otlp-grpc": "
|
|
136
|
-
"@opentelemetry/exporter-metrics-otlp-proto": "
|
|
137
|
-
"@opentelemetry/exporter-trace-otlp-grpc": "
|
|
138
|
-
"@opentelemetry/exporter-trace-otlp-proto": "
|
|
139
|
-
"@opentelemetry/instrumentation": "
|
|
140
|
-
"@opentelemetry/instrumentation-http": "
|
|
141
|
-
"@opentelemetry/instrumentation-runtime-node": "
|
|
142
|
-
"@opentelemetry/resources": "
|
|
143
|
-
"@opentelemetry/sdk-logs": "
|
|
144
|
-
"@opentelemetry/sdk-metrics": "
|
|
145
|
-
"@opentelemetry/sdk-node": "
|
|
146
|
-
"@opentelemetry/sdk-trace-base": "
|
|
147
|
-
"@opentelemetry/semantic-conventions": "
|
|
121
|
+
"@opentelemetry/api": "^1.9.1",
|
|
122
|
+
"@opentelemetry/api-logs": "^0.223.2",
|
|
123
|
+
"@opentelemetry/auto-instrumentations-node": "^0.81.2",
|
|
124
|
+
"@opentelemetry/exporter-logs-otlp-grpc": "^0.223.2",
|
|
125
|
+
"@opentelemetry/exporter-logs-otlp-http": "^0.223.2",
|
|
126
|
+
"@opentelemetry/exporter-metrics-otlp-grpc": "^0.223.2",
|
|
127
|
+
"@opentelemetry/exporter-metrics-otlp-proto": "^0.223.2",
|
|
128
|
+
"@opentelemetry/exporter-trace-otlp-grpc": "^0.223.2",
|
|
129
|
+
"@opentelemetry/exporter-trace-otlp-proto": "^0.223.2",
|
|
130
|
+
"@opentelemetry/instrumentation": "^0.223.2",
|
|
131
|
+
"@opentelemetry/instrumentation-http": "^0.223.2",
|
|
132
|
+
"@opentelemetry/instrumentation-runtime-node": "^0.36.1",
|
|
133
|
+
"@opentelemetry/resources": "^2.12.1",
|
|
134
|
+
"@opentelemetry/sdk-logs": "^0.223.2",
|
|
135
|
+
"@opentelemetry/sdk-metrics": "^2.12.1",
|
|
136
|
+
"@opentelemetry/sdk-node": "^0.223.2",
|
|
137
|
+
"@opentelemetry/sdk-trace-base": "^2.12.0",
|
|
138
|
+
"@opentelemetry/semantic-conventions": "^1.45.0",
|
|
148
139
|
"json-stringify-safe": "^5.0.1",
|
|
149
140
|
"lodash.isobject": "^3.0.2",
|
|
150
141
|
"lodash.isplainobject": "^4.0.6",
|
|
@@ -180,8 +171,17 @@
|
|
|
180
171
|
"node": "^20.19.0 || >=22.12.0"
|
|
181
172
|
},
|
|
182
173
|
"devDependencies": {
|
|
183
|
-
"@opentelemetry/context-async-hooks": "
|
|
174
|
+
"@opentelemetry/context-async-hooks": "^2.12.1",
|
|
184
175
|
"evlog": "^2.37.1",
|
|
185
176
|
"fastify": "^5.12.8"
|
|
177
|
+
},
|
|
178
|
+
"scripts": {
|
|
179
|
+
"clean": "rimraf dist",
|
|
180
|
+
"build": "tsdown",
|
|
181
|
+
"dev": "tsdown --watch --no-clean",
|
|
182
|
+
"check": "tsc",
|
|
183
|
+
"test": "tsx --test src/**/*.test.ts",
|
|
184
|
+
"bench:profiling": "tsdown && node --experimental-strip-types bench/profiling.ts",
|
|
185
|
+
"validate": "tsx scripts/validate.ts"
|
|
186
186
|
}
|
|
187
|
-
}
|
|
187
|
+
}
|