@elto/telemetry 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,176 @@
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 Support. 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
package/README.md ADDED
@@ -0,0 +1,284 @@
1
+ # @elto/telemetry
2
+
3
+ OpenTelemetry integration for Effect with Node.js and browser support.
4
+
5
+ ## Features
6
+
7
+ - **Node.js Support**: Full OpenTelemetry integration with traces, metrics, and logs
8
+ - **Browser Support**: Web-optimized telemetry with traces and logs
9
+ - **Dual Mode**: Browser apps can send telemetry directly to collector or proxy through server
10
+ - **Effect Integration**: Built on top of `@effect/opentelemetry` for seamless Effect usage
11
+ - **TypeScript**: Full type safety and excellent IDE support
12
+ - **Simple API**: Clean, declarative configuration
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ pnpm add @elto/telemetry effect
18
+ ```
19
+
20
+ ## Quick Start
21
+
22
+ ### Node.js
23
+
24
+ ```typescript
25
+ import { createNodeOtelLayer, createEndpoints } from "@elto/telemetry/node";
26
+
27
+ const OtelLive = createNodeOtelLayer({
28
+ resource: {
29
+ serviceName: "api-server",
30
+ serviceVersion: "1.0.0",
31
+ },
32
+ endpoints: createEndpoints("http://localhost:4318"),
33
+ });
34
+
35
+ // Use with your Effect program
36
+ const program = Effect.gen(function* () {
37
+ // Your telemetry-enabled code here
38
+ }).pipe(Effect.provide(OtelLive));
39
+ ```
40
+
41
+ ### Browser
42
+
43
+ ```typescript
44
+ import { createWebOtelLayer, createModeBasedEndpoints } from "@elto/telemetry/web";
45
+
46
+ const OtelLive = createWebOtelLayer({
47
+ resource: {
48
+ serviceName: "web-client",
49
+ serviceVersion: "1.0.0",
50
+ },
51
+ endpoints: { traces: "", logs: "" }, // fallback
52
+ getEndpoints: createModeBasedEndpoints(
53
+ "http://localhost:4318",
54
+ { serverUrl: "https://api.example.com" }
55
+ ),
56
+ });
57
+
58
+ // Use with your Effect program or RPC client
59
+ import { withOtel } from "@elto/telemetry/web";
60
+
61
+ const ClientLive = withOtel(OtelLive, RpcClientLayer);
62
+ ```
63
+
64
+ ## Span Processing
65
+
66
+ `@elto/telemetry` applies a built-in custom span processor by default. Both
67
+ `createNodeOtelLayer` and `createWebOtelLayer` wrap the batch span processor
68
+ with an opinionated sanitizer before export.
69
+
70
+ Behavior:
71
+
72
+ - Redacts `user.email`, `note.id`, and `profile.id` and adds `<key>_hash`
73
+ - Redacts `db.connection_string` and adds `db.connection_string_redacted`
74
+ - Shortens `db.statement` when it exceeds the internal length threshold
75
+ - Strips query strings from `http.url`
76
+ - Adds `http.status_category` when `http.status_code` is present
77
+ - Adds `telemetry.redactions` and `telemetry.transformations` counters
78
+ - Drops spans when `telemetry.drop` is `true` or `"true"`
79
+
80
+ Not redacted or hashed: `user.id`, `cache.key`, `request.id`, `request.client_id`.
81
+
82
+ To explicitly drop a span, annotate it:
83
+
84
+ ```typescript
85
+ Effect.annotateCurrentSpan({
86
+ "telemetry.drop": true,
87
+ "telemetry.drop_reason": "debug-only",
88
+ });
89
+ ```
90
+
91
+ If you need full control, build your own OpenTelemetry layer using
92
+ `@effect/opentelemetry` or wrap a processor with `createCustomSpanProcessor`
93
+ from `@elto/telemetry`.
94
+
95
+ ### Browser Logger (Non-Effect)
96
+
97
+ For browser contexts where Effect is not available:
98
+
99
+ ```typescript
100
+ import { createBrowserLogger, getOtelMode } from "@elto/telemetry/web";
101
+
102
+ const getEndpoint = () =>
103
+ getOtelMode() === "proxy"
104
+ ? "https://api.example.com/api/signals"
105
+ : "http://localhost:4318/v1/logs";
106
+
107
+ const logger = createBrowserLogger({
108
+ resource: {
109
+ serviceName: "web-client",
110
+ serviceVersion: "1.0.0",
111
+ },
112
+ logsEndpoint: getEndpoint,
113
+ });
114
+
115
+ logger.info("User logged in", { userId: "123" });
116
+ logger.error("Operation failed", { operation: "checkout", error: "timeout" });
117
+ await logger.flush(); // Flush before page unload
118
+ ```
119
+
120
+ ## API Reference
121
+
122
+ ### Common (`@elto/telemetry`)
123
+
124
+ #### `createCustomSpanProcessor(delegate: SpanProcessor)`
125
+
126
+ Wraps a delegate span processor (for example, `BatchSpanProcessor`) with the
127
+ sanitization rules described above.
128
+
129
+ ### Node.js (`@elto/telemetry/node`)
130
+
131
+ #### `createNodeOtelLayer(config: NodeSdkConfig)`
132
+
133
+ Creates an Effect Layer with OpenTelemetry configured for Node.js.
134
+
135
+ **Config:**
136
+
137
+ - `resource.serviceName` - Service name for telemetry
138
+ - `resource.serviceVersion` - Service version
139
+ - `endpoints` - Endpoint URLs (use `createEndpoints()` helper)
140
+ - `metricExportIntervalMs` - Optional, default 10000ms
141
+
142
+ **Returns:** Effect Layer for OpenTelemetry
143
+
144
+ #### `createEndpoints(baseUrl: string)`
145
+
146
+ Generates OTLP endpoint URLs for traces, logs, and metrics.
147
+
148
+ **Example:**
149
+
150
+ ```typescript
151
+ createEndpoints("http://localhost:4318")
152
+ // Returns:
153
+ // {
154
+ // traces: "http://localhost:4318/v1/traces",
155
+ // logs: "http://localhost:4318/v1/logs",
156
+ // metrics: "http://localhost:4318/v1/metrics"
157
+ // }
158
+ ```
159
+
160
+ #### `DEFAULT_OTEL_ENDPOINT`
161
+
162
+ Default OpenTelemetry collector endpoint: `"http://localhost:4318"`
163
+
164
+ ### Browser (`@elto/telemetry/web`)
165
+
166
+ #### `createWebOtelLayer(config: WebSdkConfig)`
167
+
168
+ Creates an Effect Layer with OpenTelemetry configured for browsers.
169
+
170
+ **Config:**
171
+
172
+ - `resource.serviceName` - Service name for telemetry
173
+ - `resource.serviceVersion` - Service version
174
+ - `endpoints` - Fallback endpoint URLs
175
+ - `getEndpoints` - Optional function to dynamically get endpoints (for mode switching)
176
+
177
+ **Returns:** Effect Layer for OpenTelemetry
178
+
179
+ #### `createDirectEndpoints(baseUrl: string)`
180
+
181
+ Creates endpoints for direct connection to OpenTelemetry collector.
182
+
183
+ #### `createProxyEndpoints(config: ProxyConfig)`
184
+
185
+ Creates endpoints for proxy mode (telemetry sent through server).
186
+
187
+ **Config:**
188
+
189
+ - `serverUrl` - Your server URL
190
+ - `tracesPath` - Optional, defaults to "/api/events"
191
+ - `logsPath` - Optional, defaults to "/api/signals"
192
+
193
+ #### `createModeBasedEndpoints(directUrl: string, proxyConfig: ProxyConfig)`
194
+
195
+ Creates a function that returns endpoints based on the current mode.
196
+
197
+ **Example:**
198
+
199
+ ```typescript
200
+ const getEndpoints = createModeBasedEndpoints(
201
+ "http://localhost:4318",
202
+ { serverUrl: "https://api.example.com" }
203
+ );
204
+ ```
205
+
206
+ #### `getOtelMode(): OtelMode`
207
+
208
+ Returns the current telemetry mode from localStorage ("direct" or "proxy").
209
+
210
+ #### `setOtelMode(mode: OtelMode): void`
211
+
212
+ Sets the telemetry mode in localStorage.
213
+
214
+ #### `withOtel(otelLayer, layer)`
215
+
216
+ Helper to merge OpenTelemetry layer with another layer.
217
+
218
+ #### `createBrowserLogger(config: BrowserLoggerConfig)`
219
+
220
+ Creates a standalone logger for non-Effect browser contexts.
221
+
222
+ **Config:**
223
+
224
+ - `resource.serviceName` - Service name
225
+ - `resource.serviceVersion` - Service version
226
+ - `logsEndpoint` - Endpoint URL or function that returns URL
227
+
228
+ **Returns:** Logger instance with methods: `debug`, `info`, `warning`, `error`, `flush`
229
+
230
+ ## Proxy Mode
231
+
232
+ Browser apps can send telemetry through your server instead of directly to the collector. This:
233
+
234
+ - Hides OpenTelemetry infrastructure from the browser
235
+ - Works around CORS restrictions
236
+ - Provides obscured endpoint names (`/api/events`, `/api/signals`)
237
+
238
+ ### Implementation
239
+
240
+ 1. **Browser**: Use `createModeBasedEndpoints()` to support both modes
241
+ 2. **Server**: Add proxy endpoints that forward to your collector
242
+ 3. **User Control**: Use `setOtelMode("proxy")` to switch modes
243
+
244
+ Example server proxy (Express):
245
+
246
+ ```typescript
247
+ app.post("/api/events", async (req, res) => {
248
+ // Forward to OTLP collector traces endpoint
249
+ await fetch("http://localhost:4318/v1/traces", {
250
+ method: "POST",
251
+ headers: req.headers,
252
+ body: req.body,
253
+ });
254
+ res.sendStatus(200);
255
+ });
256
+
257
+ app.post("/api/signals", async (req, res) => {
258
+ // Forward to OTLP collector logs endpoint
259
+ await fetch("http://localhost:4318/v1/logs", {
260
+ method: "POST",
261
+ headers: req.headers,
262
+ body: req.body,
263
+ });
264
+ res.sendStatus(200);
265
+ });
266
+ ```
267
+
268
+ ## TypeScript
269
+
270
+ All types are exported from the main package and subpath exports:
271
+
272
+ ```typescript
273
+ import type { ResourceConfig, EndpointConfig } from "@elto/telemetry";
274
+ import type { NodeSdkConfig } from "@elto/telemetry/node";
275
+ import type { WebSdkConfig, OtelMode, BrowserLogger } from "@elto/telemetry/web";
276
+ ```
277
+
278
+ ## Contributing
279
+
280
+ Contributions are welcome! Please feel free to submit a Pull Request.
281
+
282
+ ## License
283
+
284
+ Apache-2.0
package/dist/index.cjs ADDED
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // src/index.ts
17
+ var src_exports = {};
18
+ module.exports = __toCommonJS(src_exports);
19
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @elto/telemetry\n *\n * OpenTelemetry integration for Effect with Node.js and browser support.\n *\n * For Node.js usage: import from \"@elto/telemetry/node\"\n * For browser usage: import from \"@elto/telemetry/web\"\n *\n * @packageDocumentation\n */\nexport type {\n ResourceConfig,\n EndpointConfig,\n NodeSdkConfig,\n WebSdkConfig,\n ProxyConfig,\n OtelMode,\n BrowserLoggerConfig,\n LogLevel,\n LogOptions,\n BrowserLogger,\n} from \"./common/index.js\";\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -0,0 +1,91 @@
1
+ interface PIIConfig {
2
+ /**
3
+ * Set of span attribute keys whose values will be redacted.
4
+ */
5
+ piiAttributeKeys?: Set<string>;
6
+ /**
7
+ * Redacted value placeholder.
8
+ *
9
+ * @default "[redacted]"
10
+ */
11
+ redactedValue?: string;
12
+ }
13
+ /**
14
+ * Resource configuration for OpenTelemetry
15
+ */
16
+ interface ResourceConfig {
17
+ serviceName: string;
18
+ serviceVersion: string;
19
+ }
20
+ /**
21
+ * Endpoint configuration for OpenTelemetry exporters
22
+ */
23
+ interface EndpointConfig {
24
+ traces: string;
25
+ logs: string;
26
+ metrics?: string;
27
+ }
28
+ /**
29
+ * Configuration for Node.js OpenTelemetry SDK
30
+ */
31
+ interface NodeSdkConfig {
32
+ resource: ResourceConfig;
33
+ endpoints: EndpointConfig;
34
+ metricExportIntervalMs?: number;
35
+ piiConfig?: PIIConfig;
36
+ }
37
+ /**
38
+ * Configuration for Web OpenTelemetry SDK
39
+ */
40
+ interface WebSdkConfig {
41
+ resource: ResourceConfig;
42
+ endpoints: EndpointConfig;
43
+ getEndpoints?: () => EndpointConfig;
44
+ piiConfig?: PIIConfig;
45
+ }
46
+ /**
47
+ * Proxy mode configuration for browser telemetry
48
+ */
49
+ interface ProxyConfig {
50
+ serverUrl: string;
51
+ tracesPath?: string;
52
+ logsPath?: string;
53
+ }
54
+ /**
55
+ * OTel mode for browser telemetry,
56
+ *
57
+ * - "direct": Send telemetry directly to the OpenTelemetry collector
58
+ * - "proxy": Send telemetry through your server
59
+ */
60
+ type OtelMode = "direct" | "proxy";
61
+ /**
62
+ * Configuration for browser logger
63
+ */
64
+ interface BrowserLoggerConfig {
65
+ resource: ResourceConfig;
66
+ logsEndpoint: string | (() => string);
67
+ }
68
+ /**
69
+ * Log level for browser logger
70
+ */
71
+ type LogLevel = "debug" | "info" | "warning" | "error";
72
+ /**
73
+ * Options for logging
74
+ */
75
+ interface LogOptions {
76
+ level: LogLevel;
77
+ message: string;
78
+ annotations?: Record<string, string | number | boolean>;
79
+ }
80
+ /**
81
+ * Browser logger interface
82
+ */
83
+ interface BrowserLogger {
84
+ debug: (message: string, annotations?: Record<string, string | number | boolean>) => void;
85
+ info: (message: string, annotations?: Record<string, string | number | boolean>) => void;
86
+ warning: (message: string, annotations?: Record<string, string | number | boolean>) => void;
87
+ error: (message: string, annotations?: Record<string, string | number | boolean>) => void;
88
+ flush: () => Promise<void>;
89
+ }
90
+
91
+ export type { BrowserLogger, BrowserLoggerConfig, EndpointConfig, LogLevel, LogOptions, NodeSdkConfig, OtelMode, ProxyConfig, ResourceConfig, WebSdkConfig };
@@ -0,0 +1,91 @@
1
+ interface PIIConfig {
2
+ /**
3
+ * Set of span attribute keys whose values will be redacted.
4
+ */
5
+ piiAttributeKeys?: Set<string>;
6
+ /**
7
+ * Redacted value placeholder.
8
+ *
9
+ * @default "[redacted]"
10
+ */
11
+ redactedValue?: string;
12
+ }
13
+ /**
14
+ * Resource configuration for OpenTelemetry
15
+ */
16
+ interface ResourceConfig {
17
+ serviceName: string;
18
+ serviceVersion: string;
19
+ }
20
+ /**
21
+ * Endpoint configuration for OpenTelemetry exporters
22
+ */
23
+ interface EndpointConfig {
24
+ traces: string;
25
+ logs: string;
26
+ metrics?: string;
27
+ }
28
+ /**
29
+ * Configuration for Node.js OpenTelemetry SDK
30
+ */
31
+ interface NodeSdkConfig {
32
+ resource: ResourceConfig;
33
+ endpoints: EndpointConfig;
34
+ metricExportIntervalMs?: number;
35
+ piiConfig?: PIIConfig;
36
+ }
37
+ /**
38
+ * Configuration for Web OpenTelemetry SDK
39
+ */
40
+ interface WebSdkConfig {
41
+ resource: ResourceConfig;
42
+ endpoints: EndpointConfig;
43
+ getEndpoints?: () => EndpointConfig;
44
+ piiConfig?: PIIConfig;
45
+ }
46
+ /**
47
+ * Proxy mode configuration for browser telemetry
48
+ */
49
+ interface ProxyConfig {
50
+ serverUrl: string;
51
+ tracesPath?: string;
52
+ logsPath?: string;
53
+ }
54
+ /**
55
+ * OTel mode for browser telemetry,
56
+ *
57
+ * - "direct": Send telemetry directly to the OpenTelemetry collector
58
+ * - "proxy": Send telemetry through your server
59
+ */
60
+ type OtelMode = "direct" | "proxy";
61
+ /**
62
+ * Configuration for browser logger
63
+ */
64
+ interface BrowserLoggerConfig {
65
+ resource: ResourceConfig;
66
+ logsEndpoint: string | (() => string);
67
+ }
68
+ /**
69
+ * Log level for browser logger
70
+ */
71
+ type LogLevel = "debug" | "info" | "warning" | "error";
72
+ /**
73
+ * Options for logging
74
+ */
75
+ interface LogOptions {
76
+ level: LogLevel;
77
+ message: string;
78
+ annotations?: Record<string, string | number | boolean>;
79
+ }
80
+ /**
81
+ * Browser logger interface
82
+ */
83
+ interface BrowserLogger {
84
+ debug: (message: string, annotations?: Record<string, string | number | boolean>) => void;
85
+ info: (message: string, annotations?: Record<string, string | number | boolean>) => void;
86
+ warning: (message: string, annotations?: Record<string, string | number | boolean>) => void;
87
+ error: (message: string, annotations?: Record<string, string | number | boolean>) => void;
88
+ flush: () => Promise<void>;
89
+ }
90
+
91
+ export type { BrowserLogger, BrowserLoggerConfig, EndpointConfig, LogLevel, LogOptions, NodeSdkConfig, OtelMode, ProxyConfig, ResourceConfig, WebSdkConfig };
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}