@nxtedition/lib 19.14.2 → 20.0.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/app.js CHANGED
@@ -250,7 +250,7 @@ export function makeApp(appConfig, onTerminate) {
250
250
  const histogram = monitorEventLoopDelay({ resolution })
251
251
  histogram.enable()
252
252
 
253
- const lagMap = new LRUCache({ ttl: 10e3 })
253
+ const lagMap = new LRUCache({ ttl: 10e3, max: 1024 })
254
254
 
255
255
  const bc = new BroadcastChannel('nxt:lag')
256
256
 
package/couch.js CHANGED
@@ -333,7 +333,7 @@ export function makeCouch(opts) {
333
333
  for (const line of lines) {
334
334
  if (line === '') {
335
335
  // hearbeat
336
- yield batched ? [] : null
336
+ yield batched ? [] : { seq: params.since }
337
337
  } else if (line === ',') {
338
338
  // Do nothing. Couch sometimes insert new line between
339
339
  // json body and comma.
@@ -390,6 +390,7 @@ export function makeCouch(opts) {
390
390
  resume = resolve
391
391
  })
392
392
  } else {
393
+ yield { seq: params.since }
393
394
  return
394
395
  }
395
396
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "19.14.2",
3
+ "version": "20.0.0",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "type": "module",
package/trace.js CHANGED
@@ -1,6 +1,13 @@
1
1
  import { Pool } from 'undici'
2
2
  import fp from 'lodash/fp.js'
3
3
 
4
+ const maxInt = 2147483647
5
+ let nextTraceId = Math.floor(Math.random() * maxInt)
6
+ function genTraceId() {
7
+ nextTraceId = (nextTraceId + 1) & maxInt
8
+ return nextTraceId
9
+ }
10
+
4
11
  export function makeTrace({
5
12
  url,
6
13
  stringify = JSON.stringify,
@@ -85,10 +92,9 @@ export function makeTrace({
85
92
  if (pending > limit) {
86
93
  warnDrop()
87
94
  } else {
88
- const now = performance.timeOrigin + performance.now()
89
95
  const doc = (typeof obj === 'string' ? obj : stringify(obj)).slice(1, -1)
90
96
  traceData +=
91
- prefix + `${op}", "@timestamp_unix_nano": ${now}, "@timestamp": ${Date.now()}, ${doc} }\n`
97
+ prefix + `${op}", "traceId": ${genTraceId()}, "@timestamp": ${Date.now()}, ${doc} }\n`
92
98
  if (traceData.length > batch) {
93
99
  flushTraces()
94
100
  }