@contrail/telemetry 2.0.9 → 2.0.10-alpha.2

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/CHANGELOG.md CHANGED
@@ -7,6 +7,12 @@ Versioning follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [2.0.10] - 2026-04-21
11
+
12
+ ### Added
13
+
14
+ - **Browser-safe entry point** — Added `index.browser.ts` and the `"browser"` field in `package.json`. Webpack 5 and Angular builds now resolve a lightweight stub that delegates logging to `console` instead of pulling in Node built-ins (`stream`, `async_hooks`) and `pino`. Semantic conventions, logger-config constants, and `parseOtelResourceAttributes` are re-exported as-is.
15
+
10
16
  ## [2.0.5] - 2026-04-17
11
17
 
12
18
  ### Added
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Browser-safe entry point for @contrail/telemetry.
3
+ *
4
+ * Webpack 5 / Angular resolve this file via the "browser" field in package.json,
5
+ * avoiding Node built-in imports (stream, async_hooks). Pino's own browser build
6
+ * is pure JS and logs to console, so we use it directly instead of a custom stub.
7
+ */
8
+ import pino from 'pino';
9
+ import type { Logger } from 'pino';
10
+ export * from './semantic-conventions';
11
+ export { ATTR_LOG_MESSAGE, ATTR_LOG_BODY, ATTR_LOG_PAYLOAD } from './logger/semantic-conventions';
12
+ export { PINO_LEVEL_TO_OTEL_SEVERITY, PINO_LEVEL_TO_NAME } from './logger/logger-config';
13
+ export { parseOtelResourceAttributes } from './logger/parse-otel-resource-attributes';
14
+ export declare const baseLogger: pino.Logger<never, boolean>;
15
+ export declare const logger: pino.Logger<never, boolean>;
16
+ export declare const loggerStorage: {
17
+ getStore: () => any;
18
+ run: <T>(_store: unknown, callback: () => T) => T;
19
+ };
20
+ export declare function withLogAttributes<T>(_fields: Record<string, unknown>, fn: () => T): T;
21
+ /** @deprecated Use `withLogAttributes` instead. */
22
+ export declare const withLogContext: typeof withLogAttributes;
23
+ export declare function createContextAwareLogger(_baseLogger: Logger): Logger;
24
+ export declare function addStream(_streamEntry: unknown): void;
25
+ export declare function flushLogs(_options?: {
26
+ timeoutMs?: number;
27
+ }): Promise<void>;
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ /**
3
+ * Browser-safe entry point for @contrail/telemetry.
4
+ *
5
+ * Webpack 5 / Angular resolve this file via the "browser" field in package.json,
6
+ * avoiding Node built-in imports (stream, async_hooks). Pino's own browser build
7
+ * is pure JS and logs to console, so we use it directly instead of a custom stub.
8
+ */
9
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
16
+ }) : (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ o[k2] = m[k];
19
+ }));
20
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
21
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
22
+ };
23
+ var __importDefault = (this && this.__importDefault) || function (mod) {
24
+ return (mod && mod.__esModule) ? mod : { "default": mod };
25
+ };
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.withLogContext = exports.loggerStorage = exports.logger = exports.baseLogger = exports.parseOtelResourceAttributes = exports.PINO_LEVEL_TO_NAME = exports.PINO_LEVEL_TO_OTEL_SEVERITY = exports.ATTR_LOG_PAYLOAD = exports.ATTR_LOG_BODY = exports.ATTR_LOG_MESSAGE = void 0;
28
+ exports.withLogAttributes = withLogAttributes;
29
+ exports.createContextAwareLogger = createContextAwareLogger;
30
+ exports.addStream = addStream;
31
+ exports.flushLogs = flushLogs;
32
+ const pino_1 = __importDefault(require("pino"));
33
+ // --- Re-export browser-safe modules as-is ---
34
+ __exportStar(require("./semantic-conventions"), exports);
35
+ var semantic_conventions_1 = require("./logger/semantic-conventions");
36
+ Object.defineProperty(exports, "ATTR_LOG_MESSAGE", { enumerable: true, get: function () { return semantic_conventions_1.ATTR_LOG_MESSAGE; } });
37
+ Object.defineProperty(exports, "ATTR_LOG_BODY", { enumerable: true, get: function () { return semantic_conventions_1.ATTR_LOG_BODY; } });
38
+ Object.defineProperty(exports, "ATTR_LOG_PAYLOAD", { enumerable: true, get: function () { return semantic_conventions_1.ATTR_LOG_PAYLOAD; } });
39
+ var logger_config_1 = require("./logger/logger-config");
40
+ Object.defineProperty(exports, "PINO_LEVEL_TO_OTEL_SEVERITY", { enumerable: true, get: function () { return logger_config_1.PINO_LEVEL_TO_OTEL_SEVERITY; } });
41
+ Object.defineProperty(exports, "PINO_LEVEL_TO_NAME", { enumerable: true, get: function () { return logger_config_1.PINO_LEVEL_TO_NAME; } });
42
+ var parse_otel_resource_attributes_1 = require("./logger/parse-otel-resource-attributes");
43
+ Object.defineProperty(exports, "parseOtelResourceAttributes", { enumerable: true, get: function () { return parse_otel_resource_attributes_1.parseOtelResourceAttributes; } });
44
+ // --- Browser logger (pino's built-in browser build) ---
45
+ exports.baseLogger = (0, pino_1.default)({ level: 'debug' });
46
+ exports.logger = exports.baseLogger;
47
+ // --- No-op stubs for Node-only features ---
48
+ exports.loggerStorage = {
49
+ getStore: () => undefined,
50
+ run: (_store, callback) => callback(),
51
+ };
52
+ function withLogAttributes(_fields, fn) {
53
+ return fn();
54
+ }
55
+ /** @deprecated Use `withLogAttributes` instead. */
56
+ exports.withLogContext = withLogAttributes;
57
+ function createContextAwareLogger(_baseLogger) {
58
+ return _baseLogger;
59
+ }
60
+ function addStream(_streamEntry) { }
61
+ async function flushLogs(_options) { }
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@contrail/telemetry",
3
- "version": "2.0.9",
3
+ "version": "2.0.10-alpha.2",
4
4
  "description": "Telemetry and monitoring utilities for contrail services",
5
5
  "main": "lib/index.js",
6
+ "browser": "lib/index.browser.js",
6
7
  "types": "lib/index.d.ts",
7
8
  "scripts": {
8
9
  "build": "tsc",