spanport 0.0.0-stage → 0.1.0

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 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/README.md CHANGED
@@ -1,3 +1,57 @@
1
- # Temporary Holding Version
1
+ # spanport (Node.js SDK)
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Send your Node.js app's logs to Spanport. Keep logging the way you already do.
4
+
5
+ ```bash
6
+ npm install spanport
7
+ ```
8
+
9
+ ```js
10
+ import * as spanport from "spanport";
11
+
12
+ spanport.init({
13
+ // From: python -m spanport_server.cli create-data-key
14
+ dataKey: "sp_ingest_...",
15
+ service: "orders-api",
16
+ // Defaults: http://localhost:4318 and http://localhost:8000
17
+ collectorUrl: "https://spanport-collector.example.com",
18
+ serverUrl: "https://spanport.example.com",
19
+ });
20
+
21
+ console.error("Payment failed for order 1042"); // sent automatically
22
+ ```
23
+
24
+ **pino and winston** write JSON lines to `spanport.logStream()`:
25
+
26
+ ```js
27
+ import pino from "pino";
28
+ const logger = pino(pino.multistream([{ stream: process.stdout }, { stream: spanport.logStream() }]));
29
+
30
+ import winston from "winston";
31
+ const logger = winston.createLogger({
32
+ format: winston.format.combine(winston.format.timestamp(), winston.format.json()),
33
+ transports: [
34
+ new winston.transports.Console(),
35
+ new winston.transports.Stream({ stream: spanport.logStream() }),
36
+ ],
37
+ });
38
+ ```
39
+
40
+ - **`console.debug/log/info/warn/error` are sent automatically**; what your app prints doesn't change. Turn this off with `captureConsole: false`.
41
+ - **Logs are sent in the background**, in batches. A normal exit sends what is left; on `SIGTERM`, call `await spanport.shutdown()` first.
42
+ - **Logs inside an OpenTelemetry span** carry its `trace_id` and `span_id`; so do pino lines that include them.
43
+ - **Wrong key?** At start-up the SDK asks the server once whether the key is valid and prints a clear error on stderr if not. Pass `checkKey: false` if the app cannot reach the server.
44
+ - **Use `https://` for anything beyond your own machine or Docker network.** The data key is sent with every batch.
45
+ - **It never breaks your app.** `init()` never throws; problems are printed on stderr as `spanport: ...` and the app carries on.
46
+
47
+ Node.js 22.15 or newer. ES module; CommonJS apps can `require("spanport")`.
48
+
49
+ ## Development
50
+
51
+ ```bash
52
+ npm install
53
+ npm test
54
+ npm run lint
55
+ npm run typecheck
56
+ npm run build
57
+ ```
@@ -0,0 +1,14 @@
1
+ /** Copies console.debug/log/info/warn/error calls to Spanport. The app's console output is unchanged. */
2
+ import { type ConsoleMethod } from "./severity.js";
3
+ /**
4
+ * Wrap the console methods so each call is also passed to `onLog`.
5
+ *
6
+ * The original method always runs first. A failure in `onLog` is ignored on purpose: the app's
7
+ * console must keep working whatever happens to Spanport. A call made while `onLog` is running
8
+ * (e.g. by an exporter that logs) is not passed on again, so it can't loop.
9
+ *
10
+ * @param onLog - Receives the method and the formatted message, as console would print it.
11
+ * @returns A function that puts the original console methods back.
12
+ */
13
+ export declare function captureConsole(onLog: (method: ConsoleMethod, message: string) => void): () => void;
14
+ //# sourceMappingURL=consoleCapture.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consoleCapture.d.ts","sourceRoot":"","sources":["../src/consoleCapture.ts"],"names":[],"mappings":"AAAA,yGAAyG;AAKzG,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAInD;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,CAAC,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,GAAG,MAAM,IAAI,CAwBlG"}
@@ -0,0 +1,44 @@
1
+ /** Copies console.debug/log/info/warn/error calls to Spanport. The app's console output is unchanged. */
2
+ import { format } from "node:util";
3
+ import { CAPTURED_CONSOLE_METHODS } from "./constants.js";
4
+ import {} from "./severity.js";
5
+ /**
6
+ * Wrap the console methods so each call is also passed to `onLog`.
7
+ *
8
+ * The original method always runs first. A failure in `onLog` is ignored on purpose: the app's
9
+ * console must keep working whatever happens to Spanport. A call made while `onLog` is running
10
+ * (e.g. by an exporter that logs) is not passed on again, so it can't loop.
11
+ *
12
+ * @param onLog - Receives the method and the formatted message, as console would print it.
13
+ * @returns A function that puts the original console methods back.
14
+ */
15
+ export function captureConsole(onLog) {
16
+ const originals = new Map();
17
+ let passingOn = false;
18
+ for (const method of CAPTURED_CONSOLE_METHODS) {
19
+ // Kept as-is so restore puts back the exact original; always called with console as `this`.
20
+ // eslint-disable-next-line @typescript-eslint/unbound-method
21
+ const original = console[method];
22
+ originals.set(method, original);
23
+ console[method] = (...args) => {
24
+ original.apply(console, args);
25
+ if (passingOn)
26
+ return;
27
+ passingOn = true;
28
+ try {
29
+ onLog(method, format(...args));
30
+ }
31
+ catch {
32
+ // Never let Spanport break the app's console.
33
+ }
34
+ finally {
35
+ passingOn = false;
36
+ }
37
+ };
38
+ }
39
+ return () => {
40
+ for (const [method, original] of originals)
41
+ console[method] = original;
42
+ };
43
+ }
44
+ //# sourceMappingURL=consoleCapture.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consoleCapture.js","sourceRoot":"","sources":["../src/consoleCapture.ts"],"names":[],"mappings":"AAAA,yGAAyG;AAEzG,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAsB,MAAM,eAAe,CAAC;AAInD;;;;;;;;;GASG;AACH,MAAM,UAAU,cAAc,CAAC,KAAuD;IACpF,MAAM,SAAS,GAAG,IAAI,GAAG,EAAkC,CAAC;IAC5D,IAAI,SAAS,GAAG,KAAK,CAAC;IACtB,KAAK,MAAM,MAAM,IAAI,wBAAwB,EAAE,CAAC;QAC9C,4FAA4F;QAC5F,6DAA6D;QAC7D,MAAM,QAAQ,GAAoB,OAAO,CAAC,MAAM,CAAC,CAAC;QAClD,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QAChC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,IAAe,EAAQ,EAAE;YAC7C,QAAQ,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;YAC9B,IAAI,SAAS;gBAAE,OAAO;YACtB,SAAS,GAAG,IAAI,CAAC;YACjB,IAAI,CAAC;gBACH,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;YACjC,CAAC;YAAC,MAAM,CAAC;gBACP,8CAA8C;YAChD,CAAC;oBAAS,CAAC;gBACT,SAAS,GAAG,KAAK,CAAC;YACpB,CAAC;QACH,CAAC,CAAC;IACJ,CAAC;IACD,OAAO,GAAG,EAAE;QACV,KAAK,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,SAAS;YAAE,OAAO,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC;IACzE,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,38 @@
1
+ /** SDK constants. Code refers to these by name, never by inline value. */
2
+ export declare const DATA_KEY_PREFIX = "sp_ingest_";
3
+ export declare const DEFAULT_COLLECTOR_URL = "http://localhost:4318";
4
+ export declare const DEFAULT_SERVER_URL = "http://localhost:8000";
5
+ export declare const OTLP_LOGS_PATH = "/v1/logs";
6
+ export declare const CURRENT_API_KEY_PATH = "/api/v1/api-keys/current";
7
+ export declare const AUTHORIZATION_HEADER = "Authorization";
8
+ export declare const BEARER_PREFIX = "Bearer ";
9
+ export declare const ALLOWED_URL_PROTOCOLS: readonly string[];
10
+ export declare const KEY_CHECK_TIMEOUT_MS = 5000;
11
+ export declare const VISIBLE_KEY_SUFFIX_LENGTH = 4;
12
+ export declare const HTTP_UNAUTHORIZED = 401;
13
+ /** console methods the SDK copies to Spanport; the original output is unchanged. */
14
+ export declare const CAPTURED_CONSOLE_METHODS: readonly ["debug", "log", "info", "warn", "error"];
15
+ /** pino's numeric levels (pino's own defaults). */
16
+ export declare const PINO_TRACE = 10;
17
+ export declare const PINO_DEBUG = 20;
18
+ export declare const PINO_INFO = 30;
19
+ export declare const PINO_WARN = 40;
20
+ export declare const PINO_ERROR = 50;
21
+ export declare const PINO_FATAL = 60;
22
+ export declare const SERVICE_NAME_ATTRIBUTE = "service.name";
23
+ /** Instrumentation scope name on every log record the SDK emits. */
24
+ export declare const SDK_SCOPE_NAME = "spanport";
25
+ /** Prefix on the SDK's own stderr messages, which are never exported. */
26
+ export declare const SDK_MESSAGE_PREFIX = "spanport:";
27
+ /** Where a log came from, recorded as the `log.source` attribute. */
28
+ export declare const LOG_SOURCE_ATTRIBUTE = "log.source";
29
+ export declare const CONSOLE_SOURCE = "console";
30
+ export declare const LOG_STREAM_SOURCE = "stream";
31
+ /** Fields of a pino or winston JSON line that become part of the record rather than attributes. */
32
+ export declare const MESSAGE_FIELDS: readonly string[];
33
+ export declare const LEVEL_FIELD = "level";
34
+ export declare const TIME_FIELDS: readonly string[];
35
+ export declare const TRACE_ID_FIELD = "trace_id";
36
+ export declare const SPAN_ID_FIELD = "span_id";
37
+ export declare const LINE_SEPARATOR = "\n";
38
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAE1E,eAAO,MAAM,eAAe,eAAe,CAAC;AAC5C,eAAO,MAAM,qBAAqB,0BAA0B,CAAC;AAC7D,eAAO,MAAM,kBAAkB,0BAA0B,CAAC;AAC1D,eAAO,MAAM,cAAc,aAAa,CAAC;AACzC,eAAO,MAAM,oBAAoB,6BAA6B,CAAC;AAC/D,eAAO,MAAM,oBAAoB,kBAAkB,CAAC;AACpD,eAAO,MAAM,aAAa,YAAY,CAAC;AACvC,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EAAwB,CAAC;AAC5E,eAAO,MAAM,oBAAoB,OAAO,CAAC;AACzC,eAAO,MAAM,yBAAyB,IAAI,CAAC;AAC3C,eAAO,MAAM,iBAAiB,MAAM,CAAC;AAErC,oFAAoF;AACpF,eAAO,MAAM,wBAAwB,oDAAqD,CAAC;AAE3F,mDAAmD;AACnD,eAAO,MAAM,UAAU,KAAK,CAAC;AAC7B,eAAO,MAAM,UAAU,KAAK,CAAC;AAC7B,eAAO,MAAM,SAAS,KAAK,CAAC;AAC5B,eAAO,MAAM,SAAS,KAAK,CAAC;AAC5B,eAAO,MAAM,UAAU,KAAK,CAAC;AAC7B,eAAO,MAAM,UAAU,KAAK,CAAC;AAE7B,eAAO,MAAM,sBAAsB,iBAAiB,CAAC;AACrD,oEAAoE;AACpE,eAAO,MAAM,cAAc,aAAa,CAAC;AACzC,yEAAyE;AACzE,eAAO,MAAM,kBAAkB,cAAc,CAAC;AAE9C,qEAAqE;AACrE,eAAO,MAAM,oBAAoB,eAAe,CAAC;AACjD,eAAO,MAAM,cAAc,YAAY,CAAC;AACxC,eAAO,MAAM,iBAAiB,WAAW,CAAC;AAE1C,mGAAmG;AACnG,eAAO,MAAM,cAAc,EAAE,SAAS,MAAM,EAAuB,CAAC;AACpE,eAAO,MAAM,WAAW,UAAU,CAAC;AACnC,eAAO,MAAM,WAAW,EAAE,SAAS,MAAM,EAA0B,CAAC;AACpE,eAAO,MAAM,cAAc,aAAa,CAAC;AACzC,eAAO,MAAM,aAAa,YAAY,CAAC;AACvC,eAAO,MAAM,cAAc,OAAO,CAAC"}
@@ -0,0 +1,38 @@
1
+ /** SDK constants. Code refers to these by name, never by inline value. */
2
+ export const DATA_KEY_PREFIX = "sp_ingest_";
3
+ export const DEFAULT_COLLECTOR_URL = "http://localhost:4318";
4
+ export const DEFAULT_SERVER_URL = "http://localhost:8000";
5
+ export const OTLP_LOGS_PATH = "/v1/logs";
6
+ export const CURRENT_API_KEY_PATH = "/api/v1/api-keys/current";
7
+ export const AUTHORIZATION_HEADER = "Authorization";
8
+ export const BEARER_PREFIX = "Bearer ";
9
+ export const ALLOWED_URL_PROTOCOLS = ["http:", "https:"];
10
+ export const KEY_CHECK_TIMEOUT_MS = 5000;
11
+ export const VISIBLE_KEY_SUFFIX_LENGTH = 4;
12
+ export const HTTP_UNAUTHORIZED = 401;
13
+ /** console methods the SDK copies to Spanport; the original output is unchanged. */
14
+ export const CAPTURED_CONSOLE_METHODS = ["debug", "log", "info", "warn", "error"];
15
+ /** pino's numeric levels (pino's own defaults). */
16
+ export const PINO_TRACE = 10;
17
+ export const PINO_DEBUG = 20;
18
+ export const PINO_INFO = 30;
19
+ export const PINO_WARN = 40;
20
+ export const PINO_ERROR = 50;
21
+ export const PINO_FATAL = 60;
22
+ export const SERVICE_NAME_ATTRIBUTE = "service.name";
23
+ /** Instrumentation scope name on every log record the SDK emits. */
24
+ export const SDK_SCOPE_NAME = "spanport";
25
+ /** Prefix on the SDK's own stderr messages, which are never exported. */
26
+ export const SDK_MESSAGE_PREFIX = "spanport:";
27
+ /** Where a log came from, recorded as the `log.source` attribute. */
28
+ export const LOG_SOURCE_ATTRIBUTE = "log.source";
29
+ export const CONSOLE_SOURCE = "console";
30
+ export const LOG_STREAM_SOURCE = "stream";
31
+ /** Fields of a pino or winston JSON line that become part of the record rather than attributes. */
32
+ export const MESSAGE_FIELDS = ["msg", "message"];
33
+ export const LEVEL_FIELD = "level";
34
+ export const TIME_FIELDS = ["time", "timestamp"];
35
+ export const TRACE_ID_FIELD = "trace_id";
36
+ export const SPAN_ID_FIELD = "span_id";
37
+ export const LINE_SEPARATOR = "\n";
38
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAE1E,MAAM,CAAC,MAAM,eAAe,GAAG,YAAY,CAAC;AAC5C,MAAM,CAAC,MAAM,qBAAqB,GAAG,uBAAuB,CAAC;AAC7D,MAAM,CAAC,MAAM,kBAAkB,GAAG,uBAAuB,CAAC;AAC1D,MAAM,CAAC,M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,cAAc,GAAsB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;AACpE,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC;AACnC,MAAM,CAAC,MAAM,WAAW,GAAsB,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AACpE,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAC;AACzC,MAAM,CAAC,MAAM,aAAa,GAAG,SAAS,CAAC;AACvC,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,CAAC"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Spanport SDK: send your Node.js app's logs to Spanport.
3
+ *
4
+ * import * as spanport from "spanport";
5
+ * spanport.init({ dataKey: "sp_ingest_...", service: "orders-api" });
6
+ *
7
+ * It never breaks the host app: init() never throws, logs are sent in the background, and if
8
+ * anything is wrong it says so on stderr and the app carries on.
9
+ */
10
+ import { type Writable } from "node:stream";
11
+ export interface SpanportOptions {
12
+ /** The project's data key (sp_ingest_...). */
13
+ dataKey: string;
14
+ /** Name of this app as shown in Spanport, e.g. "orders-api". */
15
+ service: string;
16
+ /** The Spanport OTel Collector (OTLP/HTTP). Default http://localhost:4318. */
17
+ collectorUrl?: string;
18
+ /** The Spanport server, asked once whether the data key is valid. Default http://localhost:8000. */
19
+ serverUrl?: string;
20
+ /** Set false to skip the start-up key check (e.g. no route to the server). Default true. */
21
+ checkKey?: boolean;
22
+ /** Set false to stop copying console.* calls to Spanport. Default true. */
23
+ captureConsole?: boolean;
24
+ }
25
+ /**
26
+ * Start sending this app's logs to Spanport. Call once at start-up. Never throws.
27
+ *
28
+ * @param options - Data key, service name and where Spanport runs.
29
+ */
30
+ export declare function init(options: SpanportOptions): void;
31
+ /**
32
+ * Send any logs still queued, stop capturing console and stop. Safe to call more than once.
33
+ * Call it on SIGTERM; a normal exit calls it for you. Never rejects.
34
+ */
35
+ export declare function shutdown(): Promise<void>;
36
+ /**
37
+ * A stream for pino or winston (JSON lines). Lines written before init() or after shutdown()
38
+ * are dropped.
39
+ *
40
+ * pino(spanport.logStream())
41
+ * new winston.transports.Stream({ stream: spanport.logStream() })
42
+ *
43
+ * @returns A new writable stream.
44
+ */
45
+ export declare function logStream(): Writable;
46
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAqB5C,MAAM,WAAW,eAAe;IAC9B,8CAA8C;IAC9C,OAAO,EAAE,MAAM,CAAC;IAChB,gEAAgE;IAChE,OAAO,EAAE,MAAM,CAAC;IAChB,8EAA8E;IAC9E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oGAAoG;IACpG,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4FAA4F;IAC5F,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,2EAA2E;IAC3E,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAWD;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI,CAMnD;AAED;;;GAGG;AACH,wBAAsB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAU9C;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,IAAI,QAAQ,CAIpC"}
package/dist/index.js ADDED
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Spanport SDK: send your Node.js app's logs to Spanport.
3
+ *
4
+ * import * as spanport from "spanport";
5
+ * spanport.init({ dataKey: "sp_ingest_...", service: "orders-api" });
6
+ *
7
+ * It never breaks the host app: init() never throws, logs are sent in the background, and if
8
+ * anything is wrong it says so on stderr and the app carries on.
9
+ */
10
+ import {} from "node:stream";
11
+ import {} from "@opentelemetry/api";
12
+ import {} from "@opentelemetry/sdk-logs";
13
+ import { captureConsole } from "./consoleCapture.js";
14
+ import { CONSOLE_SOURCE, DATA_KEY_PREFIX, DEFAULT_COLLECTOR_URL, DEFAULT_SERVER_URL, LOG_STREAM_SOURCE, SDK_SCOPE_NAME, } from "./constants.js";
15
+ import { checkDataKey } from "./keyCheck.js";
16
+ import { createLogStream } from "./logStream.js";
17
+ import { buildLoggerProvider, buildOtlpExporter, toLogRecord } from "./pipeline.js";
18
+ import { sdkError, sdkInfo, sdkWarning } from "./sdkMessages.js";
19
+ import { consoleSeverity } from "./severity.js";
20
+ import { isHttpUrl } from "./urls.js";
21
+ let active;
22
+ let exitFlushInstalled = false;
23
+ /**
24
+ * Start sending this app's logs to Spanport. Call once at start-up. Never throws.
25
+ *
26
+ * @param options - Data key, service name and where Spanport runs.
27
+ */
28
+ export function init(options) {
29
+ try {
30
+ start(options);
31
+ }
32
+ catch (error) {
33
+ sdkError(`setup failed; the app keeps running but logs are not sent: ${describe(error)}`);
34
+ }
35
+ }
36
+ /**
37
+ * Send any logs still queued, stop capturing console and stop. Safe to call more than once.
38
+ * Call it on SIGTERM; a normal exit calls it for you. Never rejects.
39
+ */
40
+ export async function shutdown() {
41
+ const pipeline = active;
42
+ active = undefined;
43
+ if (!pipeline)
44
+ return;
45
+ pipeline.restoreConsole?.();
46
+ try {
47
+ await pipeline.provider.shutdown();
48
+ }
49
+ catch (error) {
50
+ sdkWarning(`shutdown failed; some queued logs may not have been sent: ${describe(error)}`);
51
+ }
52
+ }
53
+ /**
54
+ * A stream for pino or winston (JSON lines). Lines written before init() or after shutdown()
55
+ * are dropped.
56
+ *
57
+ * pino(spanport.logStream())
58
+ * new winston.transports.Stream({ stream: spanport.logStream() })
59
+ *
60
+ * @returns A new writable stream.
61
+ */
62
+ export function logStream() {
63
+ return createLogStream((entry) => {
64
+ active?.logger.emit(toLogRecord(entry, LOG_STREAM_SOURCE));
65
+ });
66
+ }
67
+ function start(options) {
68
+ if (active) {
69
+ sdkWarning("init() was already called; ignoring the second call");
70
+ return;
71
+ }
72
+ const collectorUrl = options.collectorUrl ?? DEFAULT_COLLECTOR_URL;
73
+ const problem = findProblem(options, collectorUrl);
74
+ if (problem) {
75
+ sdkError(`${problem}; logs are not sent`);
76
+ return;
77
+ }
78
+ const provider = buildLoggerProvider(options.service, buildOtlpExporter(collectorUrl, options.dataKey));
79
+ const logger = provider.getLogger(SDK_SCOPE_NAME);
80
+ const restoreConsole = options.captureConsole === false
81
+ ? undefined
82
+ : captureConsole((method, message) => {
83
+ logger.emit(toLogRecord({ body: message, severity: consoleSeverity(method), attributes: {} }, CONSOLE_SOURCE));
84
+ });
85
+ active = { provider, logger, restoreConsole };
86
+ installExitFlush();
87
+ sdkInfo(`sending logs for service ${options.service} to ${collectorUrl}`);
88
+ if (options.checkKey !== false) {
89
+ void checkDataKey(options.serverUrl ?? DEFAULT_SERVER_URL, options.dataKey);
90
+ }
91
+ }
92
+ /** Send what is queued when the app exits normally. Installed once, however often init runs. */
93
+ function installExitFlush() {
94
+ if (exitFlushInstalled)
95
+ return;
96
+ exitFlushInstalled = true;
97
+ process.on("beforeExit", () => void shutdown());
98
+ }
99
+ function findProblem(options, collectorUrl) {
100
+ if (!options.dataKey.startsWith(DATA_KEY_PREFIX)) {
101
+ return `dataKey must be a data key (${DATA_KEY_PREFIX}...)`;
102
+ }
103
+ if (!options.service)
104
+ return "service must name this app, e.g. service: 'orders-api'";
105
+ if (!isHttpUrl(collectorUrl))
106
+ return "collectorUrl must start with http:// or https://";
107
+ return undefined;
108
+ }
109
+ function describe(error) {
110
+ return error instanceof Error ? error.message : String(error);
111
+ }
112
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAiB,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAe,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAuB,MAAM,yBAAyB,CAAC;AAE9D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EACL,cAAc,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AK,EAAE,CAAC;QAC/B,KAAK,YAAY,CAAC,OAAO,CAAC,SAAS,IAAI,kBAAkB,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAC9E,CAAC;AACH,CAAC;AAED,gGAAgG;AAChG,SAAS,gBAAgB;IACvB,IAAI,kBAAkB;QAAE,OAAO;IAC/B,kBAAkB,GAAG,IAAI,CAAC;IAC1B,OAAO,CAAC,EAAE,CAAC,YAAY,EAAE,GAAG,EAAE,CAAC,KAAK,QAAQ,EAAE,CAAC,CAAC;AAClD,CAAC;AAED,SAAS,WAAW,CAAC,OAAwB,EAAE,YAAoB;IACjE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE,CAAC;QACjD,OAAO,+BAA+B,eAAe,MAAM,CAAC;IAC9D,CAAC;IACD,IAAI,CAAC,OAAO,CAAC,OAAO;QAAE,OAAO,wDAAwD,CAAC;IACtF,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC;QAAE,OAAO,kDAAkD,CAAC;IACxF,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Checks the data key once against the Spanport server and says clearly if it is wrong.
3
+ *
4
+ * The collector accepts logs without checking keys, so without this an app with a wrong key would
5
+ * lose its logs silently.
6
+ */
7
+ /**
8
+ * Ask the server whether the data key is valid and report the answer on stderr. Never throws.
9
+ *
10
+ * Redirects are refused: following one would send the key to whatever host it names.
11
+ *
12
+ * @param serverUrl - Base URL of the Spanport server.
13
+ * @param dataKey - The raw data key; only its last characters are ever printed.
14
+ * @returns True if the server accepted the key; false if it rejected it or could not be asked.
15
+ */
16
+ export declare function checkDataKey(serverUrl: string, dataKey: string): Promise<boolean>;
17
+ //# sourceMappingURL=keyCheck.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keyCheck.d.ts","sourceRoot":"","sources":["../src/keyCheck.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAaH;;;;;;;;GAQG;AACH,wBAAsB,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAqBvF"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Checks the data key once against the Spanport server and says clearly if it is wrong.
3
+ *
4
+ * The collector accepts logs without checking keys, so without this an app with a wrong key would
5
+ * lose its logs silently.
6
+ */
7
+ import { AUTHORIZATION_HEADER, BEARER_PREFIX, CURRENT_API_KEY_PATH, HTTP_UNAUTHORIZED, KEY_CHECK_TIMEOUT_MS, VISIBLE_KEY_SUFFIX_LENGTH, } from "./constants.js";
8
+ import { sdkError, sdkInfo, sdkWarning } from "./sdkMessages.js";
9
+ import { isHttpUrl, joinUrl } from "./urls.js";
10
+ /**
11
+ * Ask the server whether the data key is valid and report the answer on stderr. Never throws.
12
+ *
13
+ * Redirects are refused: following one would send the key to whatever host it names.
14
+ *
15
+ * @param serverUrl - Base URL of the Spanport server.
16
+ * @param dataKey - The raw data key; only its last characters are ever printed.
17
+ * @returns True if the server accepted the key; false if it rejected it or could not be asked.
18
+ */
19
+ export async function checkDataKey(serverUrl, dataKey) {
20
+ const keySuffix = dataKey.slice(-VISIBLE_KEY_SUFFIX_LENGTH);
21
+ if (!isHttpUrl(serverUrl)) {
22
+ sdkWarning("serverUrl must start with http:// or https://; key not checked");
23
+ return false;
24
+ }
25
+ try {
26
+ const response = await fetch(joinUrl(serverUrl, CURRENT_API_KEY_PATH), {
27
+ headers: { [AUTHORIZATION_HEADER]: BEARER_PREFIX + dataKey },
28
+ redirect: "manual",
29
+ signal: AbortSignal.timeout(KEY_CHECK_TIMEOUT_MS),
30
+ });
31
+ // The body isn't needed; release the connection.
32
+ await response.body?.cancel();
33
+ return reportAnswer(response.status, response.ok, serverUrl, keySuffix);
34
+ }
35
+ catch (error) {
36
+ sdkWarning(`could not reach ${serverUrl} to check data key ...${keySuffix}: ${describe(error)}`);
37
+ return false;
38
+ }
39
+ }
40
+ function reportAnswer(status, ok, serverUrl, keySuffix) {
41
+ if (ok) {
42
+ sdkInfo(`data key ...${keySuffix} accepted`);
43
+ return true;
44
+ }
45
+ if (status === HTTP_UNAUTHORIZED) {
46
+ sdkError(`data key ...${keySuffix} was rejected by ${serverUrl}; logs will NOT be stored. ` +
47
+ "Check the key, or create one with create-data-key.");
48
+ return false;
49
+ }
50
+ sdkWarning(`could not check data key ...${keySuffix}: HTTP ${String(status)}`);
51
+ return false;
52
+ }
53
+ function describe(error) {
54
+ return error instanceof Error ? error.message : String(error);
55
+ }
56
+ //# sourceMappingURL=keyCheck.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keyCheck.js","sourceRoot":"","sources":["../src/keyCheck.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,oBAAoB,EACpB,aAAa,EACb,oBAAoB,EACpB,iBAAiB,EACjB,oBAAoB,EACpB,yBAAyB,GAC1B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE/C;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,SAAiB,EAAE,OAAe;IACnE,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,yBAAyB,CAAC,CAAC;IAC5D,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC;QAC1B,UAAU,CAAC,gEAAgE,CAAC,CAAC;QAC7E,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CA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ream for loggers that write JSON lines: pino (as its destination) and winston (with
3
+ * the Stream transport and JSON format). The SDK depends on neither.
4
+ */
5
+ import { Writable } from "node:stream";
6
+ import { type LogEntry } from "./pipeline.js";
7
+ /**
8
+ * Create a stream that turns each line written to it into a log entry.
9
+ *
10
+ * Lines split across writes are joined before parsing.
11
+ *
12
+ * @param onEntry - Receives each parsed entry.
13
+ * @returns The stream to give to pino or winston.
14
+ */
15
+ export declare function createLogStream(onEntry: (entry: LogEntry) => void): Writable;
16
+ /**
17
+ * Parse one pino or winston JSON line. A line that isn't JSON becomes an INFO entry with the line
18
+ * as its message.
19
+ *
20
+ * @param line - One line, without the newline.
21
+ * @returns The log entry.
22
+ */
23
+ export declare function parseLogLine(line: string): LogEntry;
24
+ //# sourceMappingURL=logStream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logStream.d.ts","sourceRoot":"","sources":["../src/logStream.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAmBvC,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AAc9C;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,GAAG,QAAQ,CAY5E;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAanD"}
@@ -0,0 +1,127 @@
1
+ /**
2
+ * A writable stream for loggers that write JSON lines: pino (as its destination) and winston (with
3
+ * the Stream transport and JSON format). The SDK depends on neither.
4
+ */
5
+ import { Writable } from "node:stream";
6
+ import { ROOT_CONTEXT, TraceFlags, isSpanContextValid, trace, } from "@opentelemetry/api";
7
+ import { LEVEL_FIELD, LINE_SEPARATOR, MESSAGE_FIELDS, SPAN_ID_FIELD, TIME_FIELDS, TRACE_ID_FIELD, } from "./constants.js";
8
+ import {} from "./pipeline.js";
9
+ import { INFO, pinoSeverity, winstonSeverity } from "./severity.js";
10
+ /** Fields that become part of the record itself, not attributes. */
11
+ const RECORD_FIELDS = new Set([
12
+ ...MESSAGE_FIELDS,
13
+ LEVEL_FIELD,
14
+ ...TIME_FIELDS,
15
+ TRACE_ID_FIELD,
16
+ SPAN_ID_FIELD,
17
+ ]);
18
+ /**
19
+ * Create a stream that turns each line written to it into a log entry.
20
+ *
21
+ * Lines split across writes are joined before parsing.
22
+ *
23
+ * @param onEntry - Receives each parsed entry.
24
+ * @returns The stream to give to pino or winston.
25
+ */
26
+ export function createLogStream(onEntry) {
27
+ let partialLine = "";
28
+ return new Writable({
29
+ write(chunk, _encoding, done) {
30
+ const lines = (partialLine + chunk.toString()).split(LINE_SEPARATOR);
31
+ partialLine = lines.pop() ?? "";
32
+ for (const line of lines) {
33
+ if (line.trim())
34
+ onEntry(parseLogLine(line));
35
+ }
36
+ done();
37
+ },
38
+ });
39
+ }
40
+ /**
41
+ * Parse one pino or winston JSON line. A line that isn't JSON becomes an INFO entry with the line
42
+ * as its message.
43
+ *
44
+ * @param line - One line, without the newline.
45
+ * @returns The log entry.
46
+ */
47
+ export function parseLogLine(line) {
48
+ const fields = parseJsonObject(line);
49
+ if (!fields)
50
+ return { body: line, severity: INFO, attributes: {} };
51
+ const entry = {
52
+ body: messageOf(fields) ?? line,
53
+ severity: severityOf(fields[LEVEL_FIELD]),
54
+ attributes: attributesOf(fields),
55
+ };
56
+ const context = traceContextOf(fields);
57
+ if (context)
58
+ entry.context = context;
59
+ const timestamp = timestampOf(fields);
60
+ if (timestamp)
61
+ entry.timestamp = timestamp;
62
+ return entry;
63
+ }
64
+ function parseJsonObject(line) {
65
+ try {
66
+ const parsed = JSON.parse(line);
67
+ return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)
68
+ ? parsed
69
+ : undefined;
70
+ }
71
+ catch {
72
+ return undefined;
73
+ }
74
+ }
75
+ function messageOf(fields) {
76
+ for (const name of MESSAGE_FIELDS) {
77
+ const value = fields[name];
78
+ if (typeof value === "string")
79
+ return value;
80
+ }
81
+ return undefined;
82
+ }
83
+ function severityOf(level) {
84
+ if (typeof level === "number")
85
+ return pinoSeverity(level);
86
+ if (typeof level === "string")
87
+ return winstonSeverity(level);
88
+ return INFO;
89
+ }
90
+ function attributesOf(fields) {
91
+ const attributes = {};
92
+ for (const [name, value] of Object.entries(fields)) {
93
+ if (!RECORD_FIELDS.has(name))
94
+ attributes[name] = toAttributeValue(value);
95
+ }
96
+ return attributes;
97
+ }
98
+ function toAttributeValue(value) {
99
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
100
+ return value;
101
+ }
102
+ return JSON.stringify(value);
103
+ }
104
+ /** Use the line's trace_id/span_id (as written by pino's OpenTelemetry integration) if valid. */
105
+ function traceContextOf(fields) {
106
+ const traceId = fields[TRACE_ID_FIELD];
107
+ const spanId = fields[SPAN_ID_FIELD];
108
+ if (typeof traceId !== "string" || typeof spanId !== "string")
109
+ return undefined;
110
+ const spanContext = { traceId, spanId, traceFlags: TraceFlags.SAMPLED, isRemote: true };
111
+ return isSpanContextValid(spanContext)
112
+ ? trace.setSpanContext(ROOT_CONTEXT, spanContext)
113
+ : undefined;
114
+ }
115
+ /** pino writes epoch milliseconds in `time`; winston's timestamp format writes an ISO string. */
116
+ function timestampOf(fields) {
117
+ for (const name of TIME_FIELDS) {
118
+ const value = fields[name];
119
+ if (typeof value !== "number" && typeof value !== "string")
120
+ continue;
121
+ const date = new Date(value);
122
+ if (!Number.isNaN(date.getTime()))
123
+ return date;
124
+ }
125
+ return undefined;
126
+ }
127
+ //# sourceMappingURL=logStream.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logStream.js","sourceRoot":"","sources":["../src/logStream.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAGL,YAAY,EACZ,UAAU,EACV,kBAAkB,EAClB,KAAK,GACN,MAAM,oBAAoB,CA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,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ;YAAE,SAAS;QACrE,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;QAC7B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YAAE,OAAO,IAAI,CAAC;IACjD,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -0,0 +1,39 @@
1
+ /** Builds the OpenTelemetry pipeline: log records → batch → OTLP/HTTP → collector. */
2
+ import { type Attributes, type Context, type LogRecord } from "@opentelemetry/api";
3
+ import { OTLPLogExporter } from "@opentelemetry/exporter-logs-otlp-http";
4
+ import { LoggerProvider, type LogRecordExporter } from "@opentelemetry/sdk-logs";
5
+ import { type Severity } from "./severity.js";
6
+ /** One log line, whatever logger it came from, before it becomes an OpenTelemetry record. */
7
+ export interface LogEntry {
8
+ body: string;
9
+ severity: Severity;
10
+ attributes: Attributes;
11
+ /** Carries the trace and span the log belongs to; the active span is used when absent. */
12
+ context?: Context;
13
+ timestamp?: Date;
14
+ }
15
+ /**
16
+ * Exporter that sends batches to the collector with the data key as a bearer token.
17
+ *
18
+ * @param collectorUrl - Base URL of the OTel Collector, e.g. "http://localhost:4318".
19
+ * @param dataKey - The raw data key.
20
+ * @returns The OTLP/HTTP log exporter.
21
+ */
22
+ export declare function buildOtlpExporter(collectorUrl: string, dataKey: string): OTLPLogExporter;
23
+ /**
24
+ * Provider that batches records in the background and hands them to `exporter`.
25
+ *
26
+ * @param service - Service name shown in Spanport, e.g. "orders-api".
27
+ * @param exporter - Where batches go; OTLP in real use, in-memory in tests.
28
+ * @returns The provider; shut it down to send what is still queued.
29
+ */
30
+ export declare function buildLoggerProvider(service: string, exporter: LogRecordExporter): LoggerProvider;
31
+ /**
32
+ * Turn a log entry into an OpenTelemetry log record.
33
+ *
34
+ * @param entry - The parsed log line.
35
+ * @param source - Where it came from ("console" or "stream"), kept as the log.source attribute.
36
+ * @returns The record to emit.
37
+ */
38
+ export declare function toLogRecord(entry: LogEntry, source: string): LogRecord;
39
+ //# sourceMappingURL=pipeline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../src/pipeline.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACnF,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AAEzE,OAAO,EAEL,cAAc,EACd,KAAK,iBAAiB,EACvB,MAAM,yBAAyB,CAAC;AASjC,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AAG9C,6FAA6F;AAC7F,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,QAAQ,CAAC;IACnB,UAAU,EAAE,UAAU,CAAC;IACvB,0FAA0F;IAC1F,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,IAAI,CAAC;CAClB;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,eAAe,CAKxF;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,iBAAiB,GAAG,cAAc,CAKhG;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,CAUtE"}
@@ -0,0 +1,55 @@
1
+ /** Builds the OpenTelemetry pipeline: log records → batch → OTLP/HTTP → collector. */
2
+ import {} from "@opentelemetry/api";
3
+ import { OTLPLogExporter } from "@opentelemetry/exporter-logs-otlp-http";
4
+ import { resourceFromAttributes } from "@opentelemetry/resources";
5
+ import { BatchLogRecordProcessor, LoggerProvider, } from "@opentelemetry/sdk-logs";
6
+ import { AUTHORIZATION_HEADER, BEARER_PREFIX, LOG_SOURCE_ATTRIBUTE, OTLP_LOGS_PATH, SERVICE_NAME_ATTRIBUTE, } from "./constants.js";
7
+ import {} from "./severity.js";
8
+ import { joinUrl } from "./urls.js";
9
+ /**
10
+ * Exporter that sends batches to the collector with the data key as a bearer token.
11
+ *
12
+ * @param collectorUrl - Base URL of the OTel Collector, e.g. "http://localhost:4318".
13
+ * @param dataKey - The raw data key.
14
+ * @returns The OTLP/HTTP log exporter.
15
+ */
16
+ export function buildOtlpExporter(collectorUrl, dataKey) {
17
+ return new OTLPLogExporter({
18
+ url: joinUrl(collectorUrl, OTLP_LOGS_PATH),
19
+ headers: { [AUTHORIZATION_HEADER]: BEARER_PREFIX + dataKey },
20
+ });
21
+ }
22
+ /**
23
+ * Provider that batches records in the background and hands them to `exporter`.
24
+ *
25
+ * @param service - Service name shown in Spanport, e.g. "orders-api".
26
+ * @param exporter - Where batches go; OTLP in real use, in-memory in tests.
27
+ * @returns The provider; shut it down to send what is still queued.
28
+ */
29
+ export function buildLoggerProvider(service, exporter) {
30
+ return new LoggerProvider({
31
+ resource: resourceFromAttributes({ [SERVICE_NAME_ATTRIBUTE]: service }),
32
+ processors: [new BatchLogRecordProcessor({ exporter })],
33
+ });
34
+ }
35
+ /**
36
+ * Turn a log entry into an OpenTelemetry log record.
37
+ *
38
+ * @param entry - The parsed log line.
39
+ * @param source - Where it came from ("console" or "stream"), kept as the log.source attribute.
40
+ * @returns The record to emit.
41
+ */
42
+ export function toLogRecord(entry, source) {
43
+ const record = {
44
+ body: entry.body,
45
+ severityNumber: entry.severity.number,
46
+ severityText: entry.severity.text,
47
+ attributes: { ...entry.attributes, [LOG_SOURCE_ATTRIBUTE]: source },
48
+ };
49
+ if (entry.context)
50
+ record.context = entry.context;
51
+ if (entry.timestamp)
52
+ record.timestamp = entry.timestamp;
53
+ return record;
54
+ }
55
+ //# sourceMappingURL=pipeline.js.map
@@ -0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AAK,CAAC,QAAQ,CAAC,IAAI;QACjC,UAAU,EAAE,EAAE,GAAG,KAAK,CAAC,UAAU,EAAE,CAAC,oBAAoB,CAAC,EAAE,MAAM,EAAE;KACpE,CAAC;IACF,IAAI,KAAK,CAAC,OAAO;QAAE,MAAM,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;IAClD,IAAI,KAAK,CAAC,SAAS;QAAE,MAAM,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;IACxD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * The SDK's own messages. They go straight to stderr: never through console (which the SDK may be
3
+ * capturing, so they would loop) and never exported.
4
+ */
5
+ /** Report normal progress, e.g. the key was accepted. */
6
+ export declare function sdkInfo(message: string): void;
7
+ /** Report something that may stop logs from arriving, e.g. the server could not be reached. */
8
+ export declare function sdkWarning(message: string): void;
9
+ /** Report something that stops logs from being stored, e.g. a rejected key. */
10
+ export declare function sdkError(message: string): void;
11
+ //# sourceMappingURL=sdkMessages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdkMessages.d.ts","sourceRoot":"","sources":["../src/sdkMessages.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,yDAAyD;AACzD,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE7C;AAED,+FAA+F;AAC/F,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAEhD;AAED,+EAA+E;AAC/E,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE9C"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * The SDK's own messages. They go straight to stderr: never through console (which the SDK may be
3
+ * capturing, so they would loop) and never exported.
4
+ */
5
+ import { SDK_MESSAGE_PREFIX } from "./constants.js";
6
+ function write(level, message) {
7
+ process.stderr.write(`${level} ${SDK_MESSAGE_PREFIX} ${message}\n`);
8
+ }
9
+ /** Report normal progress, e.g. the key was accepted. */
10
+ export function sdkInfo(message) {
11
+ write("INFO", message);
12
+ }
13
+ /** Report something that may stop logs from arriving, e.g. the server could not be reached. */
14
+ export function sdkWarning(message) {
15
+ write("WARNING", message);
16
+ }
17
+ /** Report something that stops logs from being stored, e.g. a rejected key. */
18
+ export function sdkError(message) {
19
+ write("ERROR", message);
20
+ }
21
+ //# sourceMappingURL=sdkMessages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdkMessages.js","sourceRoot":"","sources":["../src/sdkMessages.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAIpD,SAAS,KAAK,CAAC,KAAmB,EAAE,OAAe;IACjD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,IAAI,kBAAkB,IAAI,OAAO,IAAI,CAAC,CAAC;AACtE,CAAC;AAED,yDAAyD;AACzD,MAAM,UAAU,OAAO,CAAC,OAAe;IACrC,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACzB,CAAC;AAED,+FAA+F;AAC/F,MAAM,UAAU,UAAU,CAAC,OAAe;IACxC,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AAC5B,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,QAAQ,CAAC,OAAe;IACtC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,31 @@
1
+ /** Maps console, pino and winston levels to OpenTelemetry severities. */
2
+ import { SeverityNumber } from "@opentelemetry/api";
3
+ import { type CAPTURED_CONSOLE_METHODS } from "./constants.js";
4
+ export type ConsoleMethod = (typeof CAPTURED_CONSOLE_METHODS)[number];
5
+ export interface Severity {
6
+ number: SeverityNumber;
7
+ text: string;
8
+ }
9
+ export declare const INFO: Severity;
10
+ /**
11
+ * Severity of a console call.
12
+ *
13
+ * @param method - The console method that was called.
14
+ * @returns console.debug is DEBUG, log and info are INFO, warn is WARN, error is ERROR.
15
+ */
16
+ export declare function consoleSeverity(method: ConsoleMethod): Severity;
17
+ /**
18
+ * Severity of a pino level number (10 trace ... 60 fatal; custom levels fall into the band below).
19
+ *
20
+ * @param level - pino's numeric level.
21
+ * @returns The matching severity.
22
+ */
23
+ export declare function pinoSeverity(level: number): Severity;
24
+ /**
25
+ * Severity of a winston (npm-style) level name. Unknown names count as INFO.
26
+ *
27
+ * @param level - e.g. "error", "warn", "info", "http", "verbose", "debug", "silly".
28
+ * @returns The matching severity.
29
+ */
30
+ export declare function winstonSeverity(level: string): Severity;
31
+ //# sourceMappingURL=severity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"severity.d.ts","sourceRoot":"","sources":["../src/severity.ts"],"names":[],"mappings":"AAAA,yEAAyE;AAEzE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EACL,KAAK,wBAAwB,EAM9B,MAAM,gBAAgB,CAAC;AAExB,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEtE,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,cAAc,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;CACd;AAID,eAAO,MAAM,IAAI,EAAE,QAAwD,CAAC;AAK5E;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,aAAa,GAAG,QAAQ,CAY/D;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,CAOpD;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,CAqBvD"}
@@ -0,0 +1,76 @@
1
+ /** Maps console, pino and winston levels to OpenTelemetry severities. */
2
+ import { SeverityNumber } from "@opentelemetry/api";
3
+ import { PINO_DEBUG, PINO_ERROR, PINO_FATAL, PINO_INFO, PINO_WARN, } from "./constants.js";
4
+ const TRACE = { number: SeverityNumber.TRACE, text: "TRACE" };
5
+ const DEBUG = { number: SeverityNumber.DEBUG, text: "DEBUG" };
6
+ export const INFO = { number: SeverityNumber.INFO, text: "INFO" };
7
+ const WARN = { number: SeverityNumber.WARN, text: "WARN" };
8
+ const ERROR = { number: SeverityNumber.ERROR, text: "ERROR" };
9
+ const FATAL = { number: SeverityNumber.FATAL, text: "FATAL" };
10
+ /**
11
+ * Severity of a console call.
12
+ *
13
+ * @param method - The console method that was called.
14
+ * @returns console.debug is DEBUG, log and info are INFO, warn is WARN, error is ERROR.
15
+ */
16
+ export function consoleSeverity(method) {
17
+ switch (method) {
18
+ case "debug":
19
+ return DEBUG;
20
+ case "log":
21
+ case "info":
22
+ return INFO;
23
+ case "warn":
24
+ return WARN;
25
+ case "error":
26
+ return ERROR;
27
+ }
28
+ }
29
+ /**
30
+ * Severity of a pino level number (10 trace ... 60 fatal; custom levels fall into the band below).
31
+ *
32
+ * @param level - pino's numeric level.
33
+ * @returns The matching severity.
34
+ */
35
+ export function pinoSeverity(level) {
36
+ if (level >= PINO_FATAL)
37
+ return FATAL;
38
+ if (level >= PINO_ERROR)
39
+ return ERROR;
40
+ if (level >= PINO_WARN)
41
+ return WARN;
42
+ if (level >= PINO_INFO)
43
+ return INFO;
44
+ if (level >= PINO_DEBUG)
45
+ return DEBUG;
46
+ return TRACE;
47
+ }
48
+ /**
49
+ * Severity of a winston (npm-style) level name. Unknown names count as INFO.
50
+ *
51
+ * @param level - e.g. "error", "warn", "info", "http", "verbose", "debug", "silly".
52
+ * @returns The matching severity.
53
+ */
54
+ export function winstonSeverity(level) {
55
+ switch (level.toLowerCase()) {
56
+ case "fatal":
57
+ case "emerg":
58
+ case "alert":
59
+ case "crit":
60
+ return FATAL;
61
+ case "error":
62
+ return ERROR;
63
+ case "warn":
64
+ case "warning":
65
+ return WARN;
66
+ case "debug":
67
+ case "verbose":
68
+ return DEBUG;
69
+ case "silly":
70
+ case "trace":
71
+ return TRACE;
72
+ default:
73
+ return INFO;
74
+ }
75
+ }
76
+ //# sourceMappingURL=severity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"severity.js","sourceRoot":"","sources":["../src/severity.ts"],"names":[],"mappings":"AAAA,yEAAyE;AAEzE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EAEL,UAAU,EACV,UAAU,EACV,UAAU,EACV,SAAS,EACT,SAAS,GACV,MAAM,gBAAgB,CAAC;AASxB,MAAM,KAAK,GAAa,EAAE,MAAM,EAAE,cAAc,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AACxE,MAAM,KAAK,GAAa,EAAE,MAAM,EAAE,cAAc,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AACxE,MAAM,CAAC,MAAM,IAAI,GAAa,EAAE,MAAM,EAAE,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAC5E,MAAM,IAAI,GAAa,EAAE,MAAM,EAAE,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AACrE,MAAM,KAAK,GAAa,EAAE,MAAM,EAAE,cAAc,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AACxE,MAAM,KAAK,GAAa,EAAE,MAAM,EAAE,cAAc,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAExE;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,MAAqB;IACnD,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,OAAO;YACV,OAAO,KAAK,CAAC;QACf,KAAK,KAAK,CAAC;QACX,KAAK,MAAM;YACT,OAAO,IAAI,CAAC;QACd,KAAK,MAAM;YACT,OAAO,IAAI,CAAC;QACd,KAAK,OAAO;YACV,OAAO,KAAK,CAAC;IACjB,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,IAAI,KAAK,IAAI,UAAU;QAAE,OAAO,KAAK,CAAC;IACtC,IAAI,KAAK,IAAI,UAAU;QAAE,OAAO,KAAK,CAAC;IACtC,IAAI,KAAK,IAAI,SAAS;QAAE,OAAO,IAAI,CAAC;IACpC,IAAI,KAAK,IAAI,SAAS;QAAE,OAAO,IAAI,CAAC;IACpC,IAAI,KAAK,IAAI,UAAU;QAAE,OAAO,KAAK,CAAC;IACtC,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,KAAa;IAC3C,QAAQ,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;QAC5B,KAAK,OAAO,CAAC;QACb,KAAK,OAAO,CAAC;QACb,KAAK,OAAO,CAAC;QACb,KAAK,MAAM;YACT,OAAO,KAAK,CAAC;QACf,KAAK,OAAO;YACV,OAAO,KAAK,CAAC;QACf,KAAK,MAAM,CAAC;QACZ,KAAK,SAAS;YACZ,OAAO,IAAI,CAAC;QACd,KAAK,OAAO,CAAC;QACb,KAAK,SAAS;YACZ,OAAO,KAAK,CAAC;QACf,KAAK,OAAO,CAAC;QACb,KAAK,OAAO;YACV,OAAO,KAAK,CAAC;QACf;YACE,OAAO,IAAI,CAAC;IAChB,CAAC;AACH,CAAC"}
package/dist/urls.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ /** URL helpers shared by the exporter and the key check. */
2
+ /**
3
+ * Append a path to a base URL, keeping any path the base already has (e.g. behind a proxy).
4
+ *
5
+ * @param baseUrl - e.g. "https://example.com/spanport" or "https://example.com/spanport/".
6
+ * @param path - Starting with "/", e.g. "/v1/logs".
7
+ * @returns The joined URL text.
8
+ */
9
+ export declare function joinUrl(baseUrl: string, path: string): string;
10
+ /**
11
+ * Whether the text is an absolute http:// or https:// URL.
12
+ *
13
+ * @param url - The URL text to check.
14
+ * @returns True only for parseable http(s) URLs.
15
+ */
16
+ export declare function isHttpUrl(url: string): boolean;
17
+ //# sourceMappingURL=urls.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"urls.d.ts","sourceRoot":"","sources":["../src/urls.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAI5D;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAE9C"}
package/dist/urls.js ADDED
@@ -0,0 +1,22 @@
1
+ /** URL helpers shared by the exporter and the key check. */
2
+ import { ALLOWED_URL_PROTOCOLS } from "./constants.js";
3
+ /**
4
+ * Append a path to a base URL, keeping any path the base already has (e.g. behind a proxy).
5
+ *
6
+ * @param baseUrl - e.g. "https://example.com/spanport" or "https://example.com/spanport/".
7
+ * @param path - Starting with "/", e.g. "/v1/logs".
8
+ * @returns The joined URL text.
9
+ */
10
+ export function joinUrl(baseUrl, path) {
11
+ return (baseUrl.endsWith("/") ? baseUrl.slice(0, -1) : baseUrl) + path;
12
+ }
13
+ /**
14
+ * Whether the text is an absolute http:// or https:// URL.
15
+ *
16
+ * @param url - The URL text to check.
17
+ * @returns True only for parseable http(s) URLs.
18
+ */
19
+ export function isHttpUrl(url) {
20
+ return URL.canParse(url) && ALLOWED_URL_PROTOCOLS.includes(new URL(url).protocol);
21
+ }
22
+ //# sourceMappingURL=urls.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"urls.js","sourceRoot":"","sources":["../src/urls.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAE5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAEvD;;;;;;GAMG;AACH,MAAM,UAAU,OAAO,CAAC,OAAe,EAAE,IAAY;IACnD,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;AACzE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,GAAW;IACnC,OAAO,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,qBAAqB,CAAC,QAAQ,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC;AACpF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,51 @@
1
1
  {
2
2
  "name": "spanport",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Send your Node.js app's logs to Spanport. Keep logging the way you already do.",
5
+ "keywords": ["logging", "observability", "opentelemetry", "otlp", "spanport"],
6
+ "license": "Apache-2.0",
7
+ "author": "Nitish Bharadwaj <nitishbharadwaj2002@gmail.com>",
8
+ "homepage": "https://github.com/span-port/spanport",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/span-port/spanport.git",
12
+ "directory": "sdk/node"
13
+ },
14
+ "bugs": "https://github.com/span-port/spanport/issues",
15
+ "type": "module",
16
+ "engines": {
17
+ "node": ">=22.15"
18
+ },
19
+ "exports": {
20
+ ".": {
21
+ "types": "./dist/index.d.ts",
22
+ "default": "./dist/index.js"
23
+ }
24
+ },
25
+ "files": ["dist", "LICENSE", "README.md"],
26
+ "scripts": {
27
+ "build": "tsc -p tsconfig.build.json",
28
+ "typecheck": "tsc --noEmit -p tsconfig.json",
29
+ "lint": "eslint .",
30
+ "test": "tsc -p tsconfig.json && node --test --test-reporter=dot \"build/test/**/*.test.js\"",
31
+ "prepublishOnly": "npm run lint && npm test && npm run build"
32
+ },
33
+ "dependencies": {
34
+ "@opentelemetry/api": ">=1.10.0 <1.11.0",
35
+ "@opentelemetry/exporter-logs-otlp-http": ">=0.300.0 <0.301.0",
36
+ "@opentelemetry/resources": ">=3.0.0 <4.0.0",
37
+ "@opentelemetry/sdk-logs": ">=3.0.0 <4.0.0"
38
+ },
39
+ "devDependencies": {
40
+ "@eslint/js": "10.0.1",
41
+ "@opentelemetry/context-async-hooks": "3.0.0",
42
+ "@opentelemetry/sdk-trace": "3.0.0",
43
+ "@types/node": "22.20.5",
44
+ "eslint": "10.13.0",
45
+ "typescript": "6.0.3",
46
+ "typescript-eslint": "8.72.1"
47
+ },
48
+ "overrides": {
49
+ "@types/estree": "1.0.9"
50
+ }
51
+ }