@nxtedition/lib 19.14.3 → 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.
Files changed (3) hide show
  1. package/couch.js +2 -1
  2. package/package.json +1 -1
  3. package/trace.js +8 -2
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.3",
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
  }