rian 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,7 +19,7 @@ const convert_value_to_anyvalue = (value) => {
19
19
  any_value.arrayValue = {
20
20
  values: value.map((i) => convert_value_to_anyvalue(i)),
21
21
  };
22
- else
22
+ else if (value)
23
23
  any_value.kvlistValue = { values: convert_object_to_kv(value) };
24
24
  return any_value;
25
25
  };
@@ -17,7 +17,7 @@ const convert_value_to_anyvalue = (value) => {
17
17
  any_value.arrayValue = {
18
18
  values: value.map((i) => convert_value_to_anyvalue(i)),
19
19
  };
20
- else
20
+ else if (value)
21
21
  any_value.kvlistValue = { values: convert_object_to_kv(value) };
22
22
  return any_value;
23
23
  };
package/index.d.ts CHANGED
@@ -170,7 +170,7 @@ interface Options {
170
170
  /**
171
171
  * @borrows {@link Sampler}
172
172
  */
173
- sampler?: Sampler;
173
+ sampler?: Sampler | boolean;
174
174
  context?: Context;
175
175
  /**
176
176
  * A root, or extracted w3c traceparent stringed header.
package/index.js CHANGED
@@ -72,8 +72,11 @@ const create = (name, options) => {
72
72
  const spans = new Set();
73
73
  const promises = [];
74
74
  const sampler = options.sampler || defaultSampler;
75
+ const sampler_callable = typeof sampler !== 'boolean';
75
76
  const span = (name, parent) => {
76
- const should_sample = sampler(name, parent, options.context);
77
+ const should_sample = sampler_callable
78
+ ? sampler(name, parent, options.context)
79
+ : sampler;
77
80
  const id = parent
78
81
  ? parent.child(should_sample)
79
82
  : tctx__namespace.make(should_sample);
@@ -116,7 +119,8 @@ const create = (name, options) => {
116
119
  const endRoot = root.end.bind(root);
117
120
  root.end = async () => {
118
121
  endRoot();
119
- await Promise.all(promises);
122
+ if (promises.length)
123
+ await Promise.all(promises);
120
124
  return options.exporter(spans, {
121
125
  ...(options.context || {}),
122
126
  ...sdk_object,
package/index.mjs CHANGED
@@ -50,8 +50,11 @@ const create = (name, options) => {
50
50
  const spans = new Set();
51
51
  const promises = [];
52
52
  const sampler = options.sampler || defaultSampler;
53
+ const sampler_callable = typeof sampler !== 'boolean';
53
54
  const span = (name, parent) => {
54
- const should_sample = sampler(name, parent, options.context);
55
+ const should_sample = sampler_callable
56
+ ? sampler(name, parent, options.context)
57
+ : sampler;
55
58
  const id = parent
56
59
  ? parent.child(should_sample)
57
60
  : tctx.make(should_sample);
@@ -94,7 +97,8 @@ const create = (name, options) => {
94
97
  const endRoot = root.end.bind(root);
95
98
  root.end = async () => {
96
99
  endRoot();
97
- await Promise.all(promises);
100
+ if (promises.length)
101
+ await Promise.all(promises);
98
102
  return options.exporter(spans, {
99
103
  ...(options.context || {}),
100
104
  ...sdk_object,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rian",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "Effective tracing for the edge and origins",
5
5
  "keywords": [
6
6
  "opentelemetry",