@contrail/util 1.2.1-alpha-otel-logs-13 → 1.2.1-alpha-plat927-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,10 +7,6 @@ Versioning follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
- ### Changed
11
-
12
- - Replaced `console.log/warn/error` calls with structured logger from `@contrail/telemetry`. No API changes. On the backend, logs are now captured by the OTel pipeline. In the browser, behavior is unchanged (Pino delegates to native console).
13
-
14
10
  ## [1.2.0] - 2026-03-09
15
11
 
16
12
  ### Added
@@ -3,11 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.compressIntoString = compressIntoString;
4
4
  exports.decompressFromString = decompressFromString;
5
5
  const fflate_1 = require("fflate");
6
- const telemetry_1 = require("@contrail/telemetry");
7
6
  function compressIntoString(obj) {
8
7
  const jsonStr = JSON.stringify(obj === undefined ? null : obj);
9
8
  if (typeof Buffer === 'undefined') {
10
- telemetry_1.logger.warn('Buffer is not available. Compression will be skipped.');
9
+ console.warn('Buffer is not available. Compression will be skipped.');
11
10
  return jsonStr;
12
11
  }
13
12
  const buffer = new TextEncoder().encode(jsonStr);
@@ -16,7 +15,7 @@ function compressIntoString(obj) {
16
15
  }
17
16
  function decompressFromString(str) {
18
17
  if (typeof Buffer === 'undefined') {
19
- telemetry_1.logger.warn('Buffer is not available. Decompression will be skipped. Returning original string.');
18
+ console.warn('Buffer is not available. Decompression will be skipped. Returning original string.');
20
19
  return str;
21
20
  }
22
21
  const compressed = Buffer.from(str, 'base64');
@@ -2,7 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getIsoDatePart = getIsoDatePart;
4
4
  function getIsoDatePart(date) {
5
+ console.log('date 1: ', date.toISOString(), '\n\n\n\n\n\n\n\n');
5
6
  let d = new Date(date);
7
+ console.log('date 2: ', d.toISOString(), '\n\n\n\n\n\n\n\n');
6
8
  let month = '' + (d.getMonth() + 1), day = '' + d.getDate(), year = d.getFullYear();
7
9
  if (month.length < 2) {
8
10
  month = '0' + month;
@@ -10,18 +10,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  const performance_util_1 = require("./performance-util");
13
- const telemetry_1 = require("@contrail/telemetry");
14
13
  function demonstrateStartEndSpan() {
15
- telemetry_1.logger.debug('--- Demonstrating startSpan/endSpan functionality ---\n');
14
+ console.log('--- Demonstrating startSpan/endSpan functionality ---\n');
16
15
  (0, performance_util_1.clearDefaultTimingProfile)();
17
- telemetry_1.logger.debug('Example 1: Simple span');
16
+ console.log('Example 1: Simple span');
18
17
  (0, performance_util_1.startSpan)('Data Processing');
19
18
  const start1 = performance.now();
20
19
  while (performance.now() < start1 + 100) {
21
20
  }
22
21
  (0, performance_util_1.endSpan)('Data Processing');
23
22
  (0, performance_util_1.displayTimingTree)();
24
- telemetry_1.logger.debug('\nExample 2: Nested spans');
23
+ console.log('\nExample 2: Nested spans');
25
24
  (0, performance_util_1.clearDefaultTimingProfile)();
26
25
  (0, performance_util_1.startSpan)('Complete Task');
27
26
  (0, performance_util_1.startSpan)('Initialization');
@@ -48,7 +47,7 @@ function demonstrateStartEndSpan() {
48
47
  (0, performance_util_1.endSpan)('Cleanup');
49
48
  (0, performance_util_1.endSpan)('Complete Task');
50
49
  (0, performance_util_1.displayTimingTree)();
51
- telemetry_1.logger.debug('\nExample 3: Multiple sequential spans');
50
+ console.log('\nExample 3: Multiple sequential spans');
52
51
  (0, performance_util_1.clearDefaultTimingProfile)();
53
52
  (0, performance_util_1.startSpan)('Phase 1');
54
53
  const start6 = performance.now();
@@ -68,49 +67,49 @@ function demonstrateStartEndSpan() {
68
67
  (0, performance_util_1.displayTimingTree)();
69
68
  }
70
69
  function demonstrateWarningBehavior() {
71
- telemetry_1.logger.debug('\n--- Demonstrating Warning Behavior ---\n');
70
+ console.log('\n--- Demonstrating Warning Behavior ---\n');
72
71
  (0, performance_util_1.clearDefaultTimingProfile)();
73
- telemetry_1.logger.debug('Example 4: Warning behavior');
72
+ console.log('Example 4: Warning behavior');
74
73
  (0, performance_util_1.startSpan)('Test Span');
75
- telemetry_1.logger.debug('Started "Test Span"');
74
+ console.log('Started "Test Span"');
76
75
  (0, performance_util_1.startSpan)('Test Span');
77
- telemetry_1.logger.debug('Attempted to start "Test Span" again (should see warning above)');
76
+ console.log('Attempted to start "Test Span" again (should see warning above)');
78
77
  (0, performance_util_1.endSpan)('Test Span');
79
- telemetry_1.logger.debug('Ended "Test Span"');
78
+ console.log('Ended "Test Span"');
80
79
  (0, performance_util_1.endSpan)('Non-existent Span');
81
- telemetry_1.logger.debug('Attempted to end "Non-existent Span" (should see warning above)');
80
+ console.log('Attempted to end "Non-existent Span" (should see warning above)');
82
81
  (0, performance_util_1.displayTimingTree)();
83
82
  }
84
83
  function demonstrateParentNodeId() {
85
84
  return __awaiter(this, void 0, void 0, function* () {
86
- telemetry_1.logger.debug('\n--- Demonstrating parentNodeId Functionality ---\n');
85
+ console.log('\n--- Demonstrating parentNodeId Functionality ---\n');
87
86
  (0, performance_util_1.clearDefaultTimingProfile)();
88
- telemetry_1.logger.debug('Example 5: Concurrent async operations with explicit parent');
87
+ console.log('Example 5: Concurrent async operations with explicit parent');
89
88
  yield (0, performance_util_1.withTimingAsync)('Main Operation', () => __awaiter(this, void 0, void 0, function* () {
90
89
  const mainOpId = (0, performance_util_1.getCurrentParentNodeId)();
91
- telemetry_1.logger.debug(`Main Operation ID: ${String(mainOpId)}`);
92
- telemetry_1.logger.debug('Starting concurrent operations...');
90
+ console.log(`Main Operation ID: ${String(mainOpId)}`);
91
+ console.log('Starting concurrent operations...');
93
92
  const results = yield Promise.all([
94
93
  (0, performance_util_1.withTimingAsync)('Fetch User Data', () => __awaiter(this, void 0, void 0, function* () {
95
94
  yield new Promise((resolve) => setTimeout(resolve, 80));
96
- telemetry_1.logger.debug(' ✓ User data fetched');
95
+ console.log(' ✓ User data fetched');
97
96
  return 'user-data';
98
97
  }), { parentNodeId: mainOpId }),
99
98
  (0, performance_util_1.withTimingAsync)('Fetch Permissions', () => __awaiter(this, void 0, void 0, function* () {
100
99
  yield new Promise((resolve) => setTimeout(resolve, 60));
101
- telemetry_1.logger.debug(' ✓ Permissions fetched');
100
+ console.log(' ✓ Permissions fetched');
102
101
  return 'permissions-data';
103
102
  }), { parentNodeId: mainOpId }),
104
103
  (0, performance_util_1.withTimingAsync)('Fetch Preferences', () => __awaiter(this, void 0, void 0, function* () {
105
104
  yield new Promise((resolve) => setTimeout(resolve, 100));
106
- telemetry_1.logger.debug(' ✓ Preferences fetched');
105
+ console.log(' ✓ Preferences fetched');
107
106
  return 'preferences-data';
108
107
  }), { parentNodeId: mainOpId }),
109
108
  ]);
110
- telemetry_1.logger.debug(`All concurrent operations completed: ${JSON.stringify(results)}`);
109
+ console.log('All concurrent operations completed:', results);
111
110
  yield (0, performance_util_1.withTimingAsync)('Process Results', () => __awaiter(this, void 0, void 0, function* () {
112
111
  yield new Promise((resolve) => setTimeout(resolve, 30));
113
- telemetry_1.logger.debug(' ✓ Results processed');
112
+ console.log(' ✓ Results processed');
114
113
  }));
115
114
  }));
116
115
  (0, performance_util_1.displayTimingTree)();
@@ -118,140 +117,140 @@ function demonstrateParentNodeId() {
118
117
  }
119
118
  function demonstrateMixedNesting() {
120
119
  return __awaiter(this, void 0, void 0, function* () {
121
- telemetry_1.logger.debug('\n--- Demonstrating Mixed Natural and Explicit Nesting ---\n');
120
+ console.log('\n--- Demonstrating Mixed Natural and Explicit Nesting ---\n');
122
121
  (0, performance_util_1.clearDefaultTimingProfile)();
123
- telemetry_1.logger.debug('Example 6: Mixed natural and explicit nesting');
122
+ console.log('Example 6: Mixed natural and explicit nesting');
124
123
  yield (0, performance_util_1.withTimingAsync)('Application Startup', () => __awaiter(this, void 0, void 0, function* () {
125
124
  yield (0, performance_util_1.withTimingAsync)('Load Configuration', () => __awaiter(this, void 0, void 0, function* () {
126
125
  yield new Promise((resolve) => setTimeout(resolve, 50));
127
- telemetry_1.logger.debug(' ✓ Configuration loaded');
126
+ console.log(' ✓ Configuration loaded');
128
127
  yield (0, performance_util_1.withTimingAsync)('Validate Config', () => __awaiter(this, void 0, void 0, function* () {
129
128
  yield new Promise((resolve) => setTimeout(resolve, 20));
130
- telemetry_1.logger.debug(' ✓ Configuration validated');
129
+ console.log(' ✓ Configuration validated');
131
130
  }));
132
131
  }));
133
- telemetry_1.logger.debug('Starting parallel initialization...');
132
+ console.log('Starting parallel initialization...');
134
133
  (0, performance_util_1.startSpan)('Initialization');
135
134
  const ininitializeId = (0, performance_util_1.getCurrentParentNodeId)();
136
135
  (0, performance_util_1.withTimingSync)('Do something before initialization', () => {
137
136
  const start = performance.now();
138
137
  while (performance.now() < start + 20) {
139
138
  }
140
- telemetry_1.logger.debug(' ✓ Pre-initialization task completed');
139
+ console.log(' ✓ Pre-initialization task completed');
141
140
  });
142
141
  yield Promise.all([
143
142
  (0, performance_util_1.withTimingAsync)('Initialize Database', () => __awaiter(this, void 0, void 0, function* () {
144
143
  yield new Promise((resolve) => setTimeout(resolve, 120));
145
- telemetry_1.logger.debug(' ✓ Database initialized');
144
+ console.log(' ✓ Database initialized');
146
145
  }), { parentNodeId: ininitializeId }),
147
146
  (0, performance_util_1.withTimingAsync)('Initialize Cache', () => __awaiter(this, void 0, void 0, function* () {
148
147
  yield new Promise((resolve) => setTimeout(resolve, 90));
149
- telemetry_1.logger.debug(' ✓ Cache initialized');
148
+ console.log(' ✓ Cache initialized');
150
149
  }), { parentNodeId: ininitializeId }),
151
150
  (0, performance_util_1.withTimingAsync)('Initialize Logging', () => __awaiter(this, void 0, void 0, function* () {
152
151
  yield new Promise((resolve) => setTimeout(resolve, 40));
153
- telemetry_1.logger.debug(' ✓ Logging initialized');
152
+ console.log(' ✓ Logging initialized');
154
153
  }), { parentNodeId: ininitializeId }),
155
154
  ]);
156
155
  (0, performance_util_1.withTimingSync)('Do something after initialization', () => {
157
156
  const start = performance.now();
158
157
  while (performance.now() < start + 20) {
159
158
  }
160
- telemetry_1.logger.debug(' ✓ Post-initialization task completed');
159
+ console.log(' ✓ Post-initialization task completed');
161
160
  });
162
161
  (0, performance_util_1.endSpan)('Initialization');
163
162
  yield (0, performance_util_1.withTimingAsync)('Final Setup', () => __awaiter(this, void 0, void 0, function* () {
164
163
  yield new Promise((resolve) => setTimeout(resolve, 30));
165
- telemetry_1.logger.debug(' ✓ Final setup completed');
164
+ console.log(' ✓ Final setup completed');
166
165
  }));
167
166
  }));
168
167
  (0, performance_util_1.displayTimingTree)();
169
168
  });
170
169
  }
171
170
  function demonstrateSyncWithParentId() {
172
- telemetry_1.logger.debug('\n--- Demonstrating Sync Functions with parentNodeId ---\n');
171
+ console.log('\n--- Demonstrating Sync Functions with parentNodeId ---\n');
173
172
  (0, performance_util_1.clearDefaultTimingProfile)();
174
- telemetry_1.logger.debug('Example 7: Sync functions with explicit parent');
173
+ console.log('Example 7: Sync functions with explicit parent');
175
174
  (0, performance_util_1.withTimingSync)('Data Processing Pipeline', () => {
176
175
  const pipelineId = (0, performance_util_1.getCurrentParentNodeId)();
177
- telemetry_1.logger.debug(`Pipeline ID: ${String(pipelineId)}`);
176
+ console.log(`Pipeline ID: ${String(pipelineId)}`);
178
177
  (0, performance_util_1.withTimingSync)('Load Input Data', () => {
179
178
  const start = performance.now();
180
179
  while (performance.now() < start + 50) {
181
180
  }
182
- telemetry_1.logger.debug(' ✓ Input data loaded');
181
+ console.log(' ✓ Input data loaded');
183
182
  });
184
183
  (0, performance_util_1.withTimingSync)('Process Batch 1', () => {
185
184
  const start = performance.now();
186
185
  while (performance.now() < start + 80) {
187
186
  }
188
- telemetry_1.logger.debug(' ✓ Batch 1 processed');
187
+ console.log(' ✓ Batch 1 processed');
189
188
  }, { parentNodeId: pipelineId });
190
189
  (0, performance_util_1.withTimingSync)('Process Batch 2', () => {
191
190
  const start = performance.now();
192
191
  while (performance.now() < start + 70) {
193
192
  }
194
- telemetry_1.logger.debug(' ✓ Batch 2 processed');
193
+ console.log(' ✓ Batch 2 processed');
195
194
  }, { parentNodeId: pipelineId });
196
195
  (0, performance_util_1.withTimingSync)('Process Batch 3', () => {
197
196
  const start = performance.now();
198
197
  while (performance.now() < start + 90) {
199
198
  }
200
- telemetry_1.logger.debug(' ✓ Batch 3 processed');
199
+ console.log(' ✓ Batch 3 processed');
201
200
  }, { parentNodeId: pipelineId });
202
201
  (0, performance_util_1.withTimingSync)('Save Results', () => {
203
202
  const start = performance.now();
204
203
  while (performance.now() < start + 40) {
205
204
  }
206
- telemetry_1.logger.debug(' ✓ Results saved');
205
+ console.log(' ✓ Results saved');
207
206
  });
208
207
  });
209
208
  (0, performance_util_1.displayTimingTree)();
210
209
  }
211
210
  function demonstrateManualSpansWithParentId() {
212
- telemetry_1.logger.debug('\n--- Demonstrating Manual Spans with parentNodeId ---\n');
211
+ console.log('\n--- Demonstrating Manual Spans with parentNodeId ---\n');
213
212
  (0, performance_util_1.clearDefaultTimingProfile)();
214
- telemetry_1.logger.debug('Example 8: Manual spans with explicit parent');
213
+ console.log('Example 8: Manual spans with explicit parent');
215
214
  (0, performance_util_1.startSpan)('Service Request');
216
215
  const serviceId = (0, performance_util_1.getCurrentParentNodeId)();
217
- telemetry_1.logger.debug(`Service Request ID: ${String(serviceId)}`);
216
+ console.log(`Service Request ID: ${String(serviceId)}`);
218
217
  (0, performance_util_1.startSpan)('Authenticate User');
219
218
  const start1 = performance.now();
220
219
  while (performance.now() < start1 + 30) {
221
220
  }
222
221
  (0, performance_util_1.endSpan)('Authenticate User');
223
- telemetry_1.logger.debug(' ✓ User authenticated');
222
+ console.log(' ✓ User authenticated');
224
223
  (0, performance_util_1.startSpan)('Validate Input', { parentNodeId: serviceId });
225
224
  const start2 = performance.now();
226
225
  while (performance.now() < start2 + 20) {
227
226
  }
228
227
  (0, performance_util_1.endSpan)('Validate Input');
229
- telemetry_1.logger.debug(' ✓ Input validated');
228
+ console.log(' ✓ Input validated');
230
229
  (0, performance_util_1.startSpan)('Check Rate Limits', { parentNodeId: serviceId });
231
230
  const start3 = performance.now();
232
231
  while (performance.now() < start3 + 15) {
233
232
  }
234
233
  (0, performance_util_1.endSpan)('Check Rate Limits');
235
- telemetry_1.logger.debug(' ✓ Rate limits checked');
234
+ console.log(' ✓ Rate limits checked');
236
235
  (0, performance_util_1.startSpan)('Log Request', { parentNodeId: serviceId });
237
236
  const start4 = performance.now();
238
237
  while (performance.now() < start4 + 10) {
239
238
  }
240
239
  (0, performance_util_1.endSpan)('Log Request');
241
- telemetry_1.logger.debug(' ✓ Request logged');
240
+ console.log(' ✓ Request logged');
242
241
  (0, performance_util_1.startSpan)('Process Request');
243
242
  const start5 = performance.now();
244
243
  while (performance.now() < start5 + 60) {
245
244
  }
246
245
  (0, performance_util_1.endSpan)('Process Request');
247
- telemetry_1.logger.debug(' ✓ Request processed');
246
+ console.log(' ✓ Request processed');
248
247
  (0, performance_util_1.endSpan)('Service Request');
249
248
  (0, performance_util_1.displayTimingTree)();
250
249
  }
251
250
  function demonstrateNestingComparison() {
252
251
  return __awaiter(this, void 0, void 0, function* () {
253
- telemetry_1.logger.debug('\n--- Demonstrating Natural vs Explicit Nesting ---\n');
254
- telemetry_1.logger.debug('Natural Nesting (call stack based):');
252
+ console.log('\n--- Demonstrating Natural vs Explicit Nesting ---\n');
253
+ console.log('Natural Nesting (call stack based):');
255
254
  (0, performance_util_1.clearDefaultTimingProfile)();
256
255
  yield (0, performance_util_1.withTimingAsync)('Sequential Operations', () => __awaiter(this, void 0, void 0, function* () {
257
256
  yield (0, performance_util_1.withTimingAsync)('Operation 1', () => __awaiter(this, void 0, void 0, function* () {
@@ -265,7 +264,7 @@ function demonstrateNestingComparison() {
265
264
  }));
266
265
  }));
267
266
  (0, performance_util_1.displayTimingTree)();
268
- telemetry_1.logger.debug('\nExplicit Parent Assignment (logical grouping):');
267
+ console.log('\nExplicit Parent Assignment (logical grouping):');
269
268
  (0, performance_util_1.clearDefaultTimingProfile)();
270
269
  yield (0, performance_util_1.withTimingAsync)('Parallel Operations', () => __awaiter(this, void 0, void 0, function* () {
271
270
  const parentId = (0, performance_util_1.getCurrentParentNodeId)();
@@ -293,7 +292,7 @@ function runAllExamples() {
293
292
  demonstrateSyncWithParentId();
294
293
  demonstrateManualSpansWithParentId();
295
294
  yield demonstrateNestingComparison();
296
- telemetry_1.logger.debug('\nAll examples completed. ');
295
+ console.log('\nAll examples completed. ');
297
296
  });
298
297
  }
299
- runAllExamples().catch((err) => telemetry_1.logger.error({ err }, 'Example run failed'));
298
+ runAllExamples().catch(console.error);
@@ -17,7 +17,6 @@ exports.withTimingSync = withTimingSync;
17
17
  exports.displayTimingTree = displayTimingTree;
18
18
  exports.startSpan = startSpan;
19
19
  exports.endSpan = endSpan;
20
- const telemetry_1 = require("@contrail/telemetry");
21
20
  const DEFAULT_TIMING_PROFILE = {
22
21
  activeSpans: new Map(),
23
22
  spansById: new Map(),
@@ -188,15 +187,15 @@ function displayTimingTree(nodes = DEFAULT_TIMING_PROFILE.timingSpans, depth = 0
188
187
  });
189
188
  const result = lines.join('\n');
190
189
  if (depth === 0) {
191
- telemetry_1.logger.debug('\n--- Performance Timing Tree ---\n');
192
- telemetry_1.logger.debug(result);
193
- telemetry_1.logger.debug('\n--- End Timing ---\n');
190
+ console.log('\n--- Performance Timing Tree ---\n');
191
+ console.log(result);
192
+ console.log('\n--- End Timing ---\n');
194
193
  }
195
194
  return result;
196
195
  }
197
196
  function startSpan(spanName, options) {
198
197
  if (DEFAULT_TIMING_PROFILE.activeSpans.has(spanName)) {
199
- telemetry_1.logger.warn(`Span "${spanName}" is already active. Please end it before starting a new one with the same name.`);
198
+ console.warn(`Span "${spanName}" is already active. Please end it before starting a new one with the same name.`);
200
199
  return;
201
200
  }
202
201
  const startTime = performance.now();
@@ -230,7 +229,7 @@ function startSpan(spanName, options) {
230
229
  function endSpan(spanName) {
231
230
  const activeSpan = DEFAULT_TIMING_PROFILE.activeSpans.get(spanName);
232
231
  if (!activeSpan) {
233
- telemetry_1.logger.warn(`No active span found with name "${spanName}". Make sure to call startSpan() first.`);
232
+ console.warn(`No active span found with name "${spanName}". Make sure to call startSpan() first.`);
234
233
  return;
235
234
  }
236
235
  const endTime = performance.now();
@@ -4,7 +4,7 @@ exports.StringUtil = void 0;
4
4
  const telemetry_1 = require("@contrail/telemetry");
5
5
  class StringUtil {
6
6
  static logSomething() {
7
- console.log('hi from cosnole 🚨');
7
+ console.log('hi from console 🚨');
8
8
  telemetry_1.logger.info('hi from logger 💥');
9
9
  }
10
10
  static convertToHyphenCase(entityName, transformToLowerCase = true) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/util",
3
- "version": "1.2.1-alpha-otel-logs-13",
3
+ "version": "1.2.1-alpha-plat927-2",
4
4
  "description": "General JavaScript utilities",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -39,8 +39,8 @@
39
39
  "testEnvironment": "node"
40
40
  },
41
41
  "dependencies": {
42
- "@contrail/telemetry": "^1.1.0-alpha-frontend-logging-1",
43
- "@contrail/types": "^3.1.6-alpha-logger-3",
42
+ "@contrail/telemetry": "^1.0.2-alpha-plat927-2",
43
+ "@contrail/types": "^3.1.3",
44
44
  "fflate": "^0.8.2",
45
45
  "lodash": "^4.17.21"
46
46
  }