rian 0.3.8 → 0.4.0-beta.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/async.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // src/async.ts
2
2
  const async_hooks = require('node:async_hooks');
3
3
  const { measure } = require('rian/utils');
4
- const tctx = require('tctx');
4
+ const traceparent = require('tctx/traceparent');
5
5
 
6
6
  // src/_internal/index.ts
7
7
  var resource = {};
@@ -10,7 +10,7 @@ function configure(name, attributes = {}) {
10
10
  ...attributes,
11
11
  ["service.name"]: name,
12
12
  ["telemetry.sdk.name"]: "rian",
13
- ["telemetry.sdk.version"]: "0.3.8"
13
+ ["telemetry.sdk.version"]: "0.4.0-beta.2"
14
14
  };
15
15
  }
16
16
  var span_buffer = /* @__PURE__ */ new Set(), wait_promises = /* @__PURE__ */ new WeakMap();
@@ -44,8 +44,8 @@ function span(name, parent_id) {
44
44
  let context = resourceStore.getStore();
45
45
  if (!context)
46
46
  throw Error("no current tracer");
47
- let api = context[0], scope = api.scope, current_span = context[1], should_sample = api.sampler, parent = typeof parent_id == "string" ? tctx.parse(parent_id) : parent_id || current_span?.traceparent, id = parent?.child() || tctx.make(), is_sampling = typeof should_sample == "boolean" ? should_sample : should_sample(name, id, scope);
48
- is_sampling ? tctx.sample(id) : tctx.unsample(id);
47
+ let api = context[0], scope = api.scope, current_span = context[1], should_sample = api.sampler, parent = typeof parent_id == "string" ? traceparent.parse(parent_id) : parent_id || current_span?.traceparent, id = parent?.child() || traceparent.make(), is_sampling = typeof should_sample == "boolean" ? should_sample : should_sample(id.parent_id, parent, name, scope);
48
+ is_sampling ? traceparent.sample(id) : traceparent.unsample(id);
49
49
  let span_obj = {
50
50
  id,
51
51
  parent,
package/async.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  // src/async.ts
2
2
  import * as async_hooks from "node:async_hooks";
3
3
  import { measure } from "rian/utils";
4
- import * as tctx from "tctx";
4
+ import * as traceparent from "tctx/traceparent";
5
5
 
6
6
  // src/_internal/index.ts
7
7
  var resource = {};
@@ -10,7 +10,7 @@ function configure(name, attributes = {}) {
10
10
  ...attributes,
11
11
  ["service.name"]: name,
12
12
  ["telemetry.sdk.name"]: "rian",
13
- ["telemetry.sdk.version"]: "0.3.8"
13
+ ["telemetry.sdk.version"]: "0.4.0-beta.2"
14
14
  };
15
15
  }
16
16
  var span_buffer = /* @__PURE__ */ new Set(), wait_promises = /* @__PURE__ */ new WeakMap();
@@ -44,8 +44,8 @@ function span(name, parent_id) {
44
44
  let context = resourceStore.getStore();
45
45
  if (!context)
46
46
  throw Error("no current tracer");
47
- let api = context[0], scope = api.scope, current_span = context[1], should_sample = api.sampler, parent = typeof parent_id == "string" ? tctx.parse(parent_id) : parent_id || current_span?.traceparent, id = parent?.child() || tctx.make(), is_sampling = typeof should_sample == "boolean" ? should_sample : should_sample(name, id, scope);
48
- is_sampling ? tctx.sample(id) : tctx.unsample(id);
47
+ let api = context[0], scope = api.scope, current_span = context[1], should_sample = api.sampler, parent = typeof parent_id == "string" ? traceparent.parse(parent_id) : parent_id || current_span?.traceparent, id = parent?.child() || traceparent.make(), is_sampling = typeof should_sample == "boolean" ? should_sample : should_sample(id.parent_id, parent, name, scope);
48
+ is_sampling ? traceparent.sample(id) : traceparent.unsample(id);
49
49
  let span_obj = {
50
50
  id,
51
51
  parent,
package/index.d.ts CHANGED
@@ -27,7 +27,7 @@ export type Options = {
27
27
  /**
28
28
  * @borrows {@link Sampler}
29
29
  */
30
- sampler?: Sampler | boolean;
30
+ sampler?: typeof Sampler | boolean;
31
31
 
32
32
  clock?: ClockLike;
33
33
  };
@@ -47,20 +47,24 @@ export type Context = {
47
47
  * Return true if the span should be sampled, and reported to the {@link Exporter}.
48
48
  * Return false if the span should not be sampled, and not reported to the {@link Exporter}.
49
49
  */
50
- export type Sampler = (
50
+ export function Sampler(
51
51
  /**
52
- * The name of the span.
52
+ * The id of the new span looking for a sampling decision.
53
+ */
54
+ id: string,
55
+ /**
56
+ * The parent id of the new span looking for a sampling decision.
53
57
  */
54
- name: string,
58
+ parent: Traceparent | undefined,
55
59
  /**
56
- * The traceparent id of the span.
60
+ * The name of the span.
57
61
  */
58
- id: Traceparent,
62
+ name: string,
59
63
  /**
60
64
  * The tracer this span belongs to.
61
65
  */
62
66
  tracer: { readonly name: string },
63
- ) => boolean;
67
+ ): boolean;
64
68
 
65
69
  // --- spans
66
70
 
package/index.js CHANGED
@@ -8,7 +8,7 @@ function configure(name, attributes = {}) {
8
8
  ...attributes,
9
9
  ["service.name"]: name,
10
10
  ["telemetry.sdk.name"]: "rian",
11
- ["telemetry.sdk.version"]: "0.3.8"
11
+ ["telemetry.sdk.version"]: "0.4.0-beta.2"
12
12
  };
13
13
  }
14
14
  var span_buffer = /* @__PURE__ */ new Set(), wait_promises = /* @__PURE__ */ new WeakMap();
@@ -31,13 +31,13 @@ async function report(exporter) {
31
31
  }
32
32
 
33
33
  // src/index.ts
34
- const tctx = require('tctx');
34
+ const traceparent = require('tctx/traceparent');
35
35
  function tracer(name, options) {
36
36
  let should_sample = options?.sampler ?? !0, clock = options?.clock ?? Date, scope = { name }, ps = /* @__PURE__ */ new Set();
37
37
  wait_promises.set(scope, ps);
38
38
  let span = (name2, parent_id) => {
39
- let parent = typeof parent_id == "string" ? tctx.parse(parent_id) : parent_id, id = parent?.child() || tctx.make(), is_sampling = typeof should_sample == "boolean" ? should_sample : should_sample(name2, id, scope);
40
- is_sampling ? tctx.sample(id) : tctx.unsample(id);
39
+ let parent = typeof parent_id == "string" ? traceparent.parse(parent_id) : parent_id, id = parent?.child() || traceparent.make(), is_sampling = typeof should_sample == "boolean" ? should_sample : should_sample(id.parent_id, parent, name2, scope);
40
+ is_sampling ? traceparent.sample(id) : traceparent.unsample(id);
41
41
  let span_obj = {
42
42
  id,
43
43
  parent,
package/index.mjs CHANGED
@@ -8,7 +8,7 @@ function configure(name, attributes = {}) {
8
8
  ...attributes,
9
9
  ["service.name"]: name,
10
10
  ["telemetry.sdk.name"]: "rian",
11
- ["telemetry.sdk.version"]: "0.3.8"
11
+ ["telemetry.sdk.version"]: "0.4.0-beta.2"
12
12
  };
13
13
  }
14
14
  var span_buffer = /* @__PURE__ */ new Set(), wait_promises = /* @__PURE__ */ new WeakMap();
@@ -31,13 +31,13 @@ async function report(exporter) {
31
31
  }
32
32
 
33
33
  // src/index.ts
34
- import * as tctx from "tctx";
34
+ import * as traceparent from "tctx/traceparent";
35
35
  function tracer(name, options) {
36
36
  let should_sample = options?.sampler ?? !0, clock = options?.clock ?? Date, scope = { name }, ps = /* @__PURE__ */ new Set();
37
37
  wait_promises.set(scope, ps);
38
38
  let span = (name2, parent_id) => {
39
- let parent = typeof parent_id == "string" ? tctx.parse(parent_id) : parent_id, id = parent?.child() || tctx.make(), is_sampling = typeof should_sample == "boolean" ? should_sample : should_sample(name2, id, scope);
40
- is_sampling ? tctx.sample(id) : tctx.unsample(id);
39
+ let parent = typeof parent_id == "string" ? traceparent.parse(parent_id) : parent_id, id = parent?.child() || traceparent.make(), is_sampling = typeof should_sample == "boolean" ? should_sample : should_sample(id.parent_id, parent, name2, scope);
40
+ is_sampling ? traceparent.sample(id) : traceparent.unsample(id);
41
41
  let span_obj = {
42
42
  id,
43
43
  parent,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rian",
3
- "version": "0.3.8",
3
+ "version": "0.4.0-beta.2",
4
4
  "description": "Effective tracing for the edge and origins",
5
5
  "keywords": [
6
6
  "opentelemetry",
@@ -72,8 +72,8 @@
72
72
  },
73
73
  "prettier": "@marais/prettier",
74
74
  "dependencies": {
75
- "flattie": "^1.1.0",
76
- "tctx": "^0.1.0"
75
+ "flattie": "^1.1.1",
76
+ "tctx": "^0.2.3"
77
77
  },
78
78
  "devDependencies": {
79
79
  "@marais/prettier": "0.0.4",