rian 0.0.2-alpha.5 → 0.0.2-alpha.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. package/index.js +5 -4
  2. package/index.mjs +5 -4
  3. package/package.json +2 -2
package/index.js CHANGED
@@ -9,8 +9,8 @@ const measure = (cb, scope, promises) => {
9
9
  });
10
10
  };
11
11
  try {
12
- const r = cb();
13
- if (r instanceof Promise)
12
+ var r = cb(), is_promise = r instanceof Promise;
13
+ if (is_promise)
14
14
  promises.push(r.catch(set_error).finally(() => scope.end()));
15
15
  return r;
16
16
  }
@@ -19,14 +19,15 @@ const measure = (cb, scope, promises) => {
19
19
  throw e;
20
20
  }
21
21
  finally {
22
- scope.end();
22
+ if (is_promise !== true)
23
+ scope.end();
23
24
  }
24
25
  };
25
26
  const create = (name, options) => {
26
27
  const spans = new Set();
27
28
  const promises = [];
28
29
  const scope = (name, parent) => {
29
- const me = parent ? parent.child() : tracecontext.make_traceparent();
30
+ const me = parent ? parent.child() : tracecontext.make_traceparent(true);
30
31
  const attributes = {};
31
32
  const start = Date.now();
32
33
  let ended = false;
package/index.mjs CHANGED
@@ -7,8 +7,8 @@ const measure = (cb, scope, promises) => {
7
7
  });
8
8
  };
9
9
  try {
10
- const r = cb();
11
- if (r instanceof Promise)
10
+ var r = cb(), is_promise = r instanceof Promise;
11
+ if (is_promise)
12
12
  promises.push(r.catch(set_error).finally(() => scope.end()));
13
13
  return r;
14
14
  }
@@ -17,14 +17,15 @@ const measure = (cb, scope, promises) => {
17
17
  throw e;
18
18
  }
19
19
  finally {
20
- scope.end();
20
+ if (is_promise !== true)
21
+ scope.end();
21
22
  }
22
23
  };
23
24
  const create = (name, options) => {
24
25
  const spans = new Set();
25
26
  const promises = [];
26
27
  const scope = (name, parent) => {
27
- const me = parent ? parent.child() : make_traceparent();
28
+ const me = parent ? parent.child() : make_traceparent(true);
28
29
  const attributes = {};
29
30
  const start = Date.now();
30
31
  let ended = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rian",
3
- "version": "0.0.2-alpha.5",
3
+ "version": "0.0.2-alpha.9",
4
4
  "description": "A tracer for the edge",
5
5
  "keywords": [
6
6
  "TODO"
@@ -34,6 +34,6 @@
34
34
  "*.d.ts"
35
35
  ],
36
36
  "dependencies": {
37
- "tctx": "^0.0.7"
37
+ "tctx": "^0.0.9"
38
38
  }
39
39
  }