rian 0.3.1 → 0.3.3

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.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { CallableScope, Options, Scope } from 'rian';
2
+ import type { Traceparent } from 'tctx';
2
3
 
3
4
  export { report, configure } from 'rian';
4
5
 
@@ -34,7 +35,10 @@ export function currentSpan(): Scope;
34
35
  * });
35
36
  * ```
36
37
  */
37
- export function span(name: string): CallableScope;
38
+ export function span(
39
+ name: string,
40
+ parent_id?: Traceparent | string,
41
+ ): CallableScope;
38
42
 
39
43
  export type Tracer<T> = (cb: T) => ReturnType<T>;
40
44
 
package/async.js CHANGED
@@ -1 +1 @@
1
- const e = require('node:async_hooks');const { measure:t } = require('rian/utils');const { make:n, parse:r, SAMPLED_FLAG:o } = require('tctx');const { is_sampled:a } = require('tctx');var s={};function c(e,t={}){s={...t,"service.name":e,"telemetry.sdk.name":"rian","telemetry.sdk.version":"0.3.1"}}var l=new Set,i=new WeakMap;async function p(e){let t=[],n=new Map;for(let[e,r]of l){let o;n.has(r)?o=n.get(r).spans:n.set(r,{scope:r,spans:o=[]}),o.push(e),i.has(r)&&(t.push(...i.get(r)),i.delete(r))}return l.clear(),t.length&&await Promise.all(t),e({resource:s,scopeSpans:n.values()})}function u(e,t){return a(t)}var d=new e.AsyncLocalStorage;function m(){let e=d.getStore()?.[1];if(null==e)throw new Error("no current span");return e}function f(e){let r=d.getStore();if(!r)throw Error("TODO");let o=r[0],a=o.scope,s=r[1],c=o.sampler,p=s?.traceparent??o.root_id,u=p?p.child():n(),m="boolean"!=typeof c?c(e,u,a):c;u.flags;let w={id:u,parent:p,start:o.clock.now(),name:e,events:[],context:{}};m&&l.add([w,a]);let g=e=>d.run([o,g],t,g,e);g.traceparent=u,g.span=e=>d.run([o,g],f,e),g.set_context=e=>{"function"!=typeof e?Object.assign(w.context,e):w.context=e(w.context)},g.add_event=(e,t)=>{w.events.push({name:e,timestamp:o.clock.now(),attributes:t||{}})},g.end=()=>{null==w.end&&(w.end=o.clock.now())};let h=i.get(a);return g.__add_promise=e=>{h.add(e),e.then((()=>h.delete(e)))},g}function w(e,t){let n=t?.sampler??u,o={name:e},a={root_id:"string"==typeof t?.traceparent?r(t.traceparent):void 0,scope:o,sampler:n,clock:t?.clock??Date};return i.set(o,new Set),function(e){let t=d.getStore();return a.root_id||(a.root_id=t?.[0].root_id),d.run([a,t?.[1]||null],e)}}exports.configure=c;exports.currentSpan=m;exports.report=p;exports.span=f;exports.tracer=w;
1
+ const e = require('node:async_hooks');const { measure:t } = require('rian/utils');const { make:n, parse:r, SAMPLED_FLAG:o } = require('tctx');const { is_sampled:a } = require('tctx');var s={};function c(e,t={}){s={...t,"service.name":e,"telemetry.sdk.name":"rian","telemetry.sdk.version":"0.3.3"}}var l=new Set,p=new WeakMap;async function u(e){let t=[],n=new Map;for(let[e,r]of l){let o;n.has(r)?o=n.get(r).spans:n.set(r,{scope:r,spans:o=[]}),o.push(e),p.has(r)&&(t.push(...p.get(r)),p.delete(r))}return l.clear(),t.length&&await Promise.all(t),e({resource:s,scopeSpans:n.values()})}function i(e,t){return a(t)}var m=new e.AsyncLocalStorage;function f(){let e=m.getStore()?.[1];if(null==e)throw new Error("no current span");return e}function d(e,o){let a=m.getStore();if(!a)throw Error("TODO");let s=a[0],c=s.scope,u=a[1],i=s.sampler,f=null!=o?"string"==typeof o?r(o):o:u?.traceparent,w=f?f.child():n(),g="boolean"!=typeof i?i(e,w,c):i;w.flags;let h={id:w,parent:f,start:s.clock.now(),name:e,events:[],context:{}};g&&l.add([h,c]);let k=e=>m.run([s,k],t,k,e);k.traceparent=w,k.span=e=>m.run([s,k],d,e),k.set_context=e=>{"function"!=typeof e?Object.assign(h.context,e):h.context=e(h.context)},k.add_event=(e,t)=>{h.events.push({name:e,timestamp:s.clock.now(),attributes:t||{}})},k.end=()=>{null==h.end&&(h.end=s.clock.now())};let v=p.get(c);return k.__add_promise=e=>{v.add(e),e.then((()=>v.delete(e)))},k}function w(e,t){let n={name:e},r={scope:n,sampler:t?.sampler??i,clock:t?.clock??Date};return p.set(n,new Set),function(e){let t=m.getStore();return m.run([r,t?.[1]||null],e)}}exports.configure=c;exports.currentSpan=f;exports.report=u;exports.span=d;exports.tracer=w;
package/async.mjs CHANGED
@@ -1 +1 @@
1
- import*as e from"node:async_hooks";import{measure as t}from"rian/utils";import{make as n,parse as r,SAMPLED_FLAG as o}from"tctx";import{is_sampled as a}from"tctx";var s={};function c(e,t={}){s={...t,"service.name":e,"telemetry.sdk.name":"rian","telemetry.sdk.version":"0.3.1"}}var l=new Set,i=new WeakMap;async function p(e){let t=[],n=new Map;for(let[e,r]of l){let o;n.has(r)?o=n.get(r).spans:n.set(r,{scope:r,spans:o=[]}),o.push(e),i.has(r)&&(t.push(...i.get(r)),i.delete(r))}return l.clear(),t.length&&await Promise.all(t),e({resource:s,scopeSpans:n.values()})}function u(e,t){return a(t)}var d=new e.AsyncLocalStorage;function m(){let e=d.getStore()?.[1];if(null==e)throw new Error("no current span");return e}function f(e){let r=d.getStore();if(!r)throw Error("TODO");let o=r[0],a=o.scope,s=r[1],c=o.sampler,p=s?.traceparent??o.root_id,u=p?p.child():n(),m="boolean"!=typeof c?c(e,u,a):c;u.flags;let w={id:u,parent:p,start:o.clock.now(),name:e,events:[],context:{}};m&&l.add([w,a]);let g=e=>d.run([o,g],t,g,e);g.traceparent=u,g.span=e=>d.run([o,g],f,e),g.set_context=e=>{"function"!=typeof e?Object.assign(w.context,e):w.context=e(w.context)},g.add_event=(e,t)=>{w.events.push({name:e,timestamp:o.clock.now(),attributes:t||{}})},g.end=()=>{null==w.end&&(w.end=o.clock.now())};let h=i.get(a);return g.__add_promise=e=>{h.add(e),e.then((()=>h.delete(e)))},g}function w(e,t){let n=t?.sampler??u,o={name:e},a={root_id:"string"==typeof t?.traceparent?r(t.traceparent):void 0,scope:o,sampler:n,clock:t?.clock??Date};return i.set(o,new Set),function(e){let t=d.getStore();return a.root_id||(a.root_id=t?.[0].root_id),d.run([a,t?.[1]||null],e)}}export{c as configure,m as currentSpan,p as report,f as span,w as tracer};
1
+ import*as e from"node:async_hooks";import{measure as t}from"rian/utils";import{make as n,parse as r,SAMPLED_FLAG as o}from"tctx";import{is_sampled as a}from"tctx";var s={};function c(e,t={}){s={...t,"service.name":e,"telemetry.sdk.name":"rian","telemetry.sdk.version":"0.3.3"}}var l=new Set,p=new WeakMap;async function u(e){let t=[],n=new Map;for(let[e,r]of l){let o;n.has(r)?o=n.get(r).spans:n.set(r,{scope:r,spans:o=[]}),o.push(e),p.has(r)&&(t.push(...p.get(r)),p.delete(r))}return l.clear(),t.length&&await Promise.all(t),e({resource:s,scopeSpans:n.values()})}function i(e,t){return a(t)}var m=new e.AsyncLocalStorage;function f(){let e=m.getStore()?.[1];if(null==e)throw new Error("no current span");return e}function d(e,o){let a=m.getStore();if(!a)throw Error("TODO");let s=a[0],c=s.scope,u=a[1],i=s.sampler,f=null!=o?"string"==typeof o?r(o):o:u?.traceparent,w=f?f.child():n(),g="boolean"!=typeof i?i(e,w,c):i;w.flags;let h={id:w,parent:f,start:s.clock.now(),name:e,events:[],context:{}};g&&l.add([h,c]);let k=e=>m.run([s,k],t,k,e);k.traceparent=w,k.span=e=>m.run([s,k],d,e),k.set_context=e=>{"function"!=typeof e?Object.assign(h.context,e):h.context=e(h.context)},k.add_event=(e,t)=>{h.events.push({name:e,timestamp:s.clock.now(),attributes:t||{}})},k.end=()=>{null==h.end&&(h.end=s.clock.now())};let v=p.get(c);return k.__add_promise=e=>{v.add(e),e.then((()=>v.delete(e)))},k}function w(e,t){let n={name:e},r={scope:n,sampler:t?.sampler??i,clock:t?.clock??Date};return p.set(n,new Set),function(e){let t=m.getStore();return m.run([r,t?.[1]||null],e)}}export{c as configure,f as currentSpan,u as report,d as span,w as tracer};
package/index.d.ts CHANGED
@@ -21,14 +21,6 @@ export type Options = {
21
21
  */
22
22
  sampler?: Sampler | boolean;
23
23
 
24
- /**
25
- * A root, or extracted w3c traceparent string header.
26
- *
27
- * If the id is malformed, the {@link create} method will throw an exception. If no root is
28
- * provided then one will be created obeying the {@link Options.sampler|sampling} rules on each span.
29
- */
30
- traceparent?: string | null;
31
-
32
24
  clock?: ClockLike;
33
25
  };
34
26
 
@@ -162,6 +154,7 @@ export type Scope = {
162
154
  * @borrows {@link Span.name}
163
155
  */
164
156
  name: string,
157
+ parent_id?: Traceparent | string,
165
158
  ): CallableScope;
166
159
 
167
160
  /**
package/index.js CHANGED
@@ -1 +1 @@
1
- const { measure:e } = require('rian/utils');const { make:t, parse:n, SAMPLED_FLAG:a } = require('tctx');const { is_sampled:r } = require('tctx');var o={};function s(e,t={}){o={...t,"service.name":e,"telemetry.sdk.name":"rian","telemetry.sdk.version":"0.3.1"}}var p=new Set,c=new WeakMap;async function i(e){let t=[],n=new Map;for(let[e,a]of p){let r;n.has(a)?r=n.get(a).spans:n.set(a,{scope:a,spans:r=[]}),r.push(e),c.has(a)&&(t.push(...c.get(a)),c.delete(a))}return p.clear(),t.length&&await Promise.all(t),e({resource:o,scopeSpans:n.values()})}function l(e,t){return r(t)}function d(a,r){let o=r?.sampler??l,s=r?.clock??Date,i={name:a},d=new Set;c.set(i,d);let m="string"==typeof r?.traceparent?n(r.traceparent):void 0,u=(n,a)=>{let r=a?a.child():t(),c="boolean"!=typeof o?o(n,r,i):o;r.flags;let l={id:r,parent:a,start:s.now(),name:n,events:[],context:{}};c&&p.add([l,i]);let m=t=>e(m,t);return m.traceparent=r,m.span=e=>u(e,r),m.set_context=e=>"function"==typeof e?void(l.context=e(l.context)):void Object.assign(l.context,e),m.add_event=(e,t)=>{l.events.push({name:e,timestamp:s.now(),attributes:t||{}})},m.end=()=>{null==l.end&&(l.end=s.now())},m.__add_promise=e=>{d.add(e),e.then((()=>d.delete(e)))},m};return{span:e=>u(e,m)}}exports.configure=s;exports.report=i;exports.tracer=d;
1
+ const { measure:e } = require('rian/utils');const { make:t, parse:n, SAMPLED_FLAG:a } = require('tctx');const { is_sampled:o } = require('tctx');var s={};function r(e,t={}){s={...t,"service.name":e,"telemetry.sdk.name":"rian","telemetry.sdk.version":"0.3.3"}}var l=new Set,i=new WeakMap;async function p(e){let t=[],n=new Map;for(let[e,a]of l){let o;n.has(a)?o=n.get(a).spans:n.set(a,{scope:a,spans:o=[]}),o.push(e),i.has(a)&&(t.push(...i.get(a)),i.delete(a))}return l.clear(),t.length&&await Promise.all(t),e({resource:s,scopeSpans:n.values()})}function c(e,t){return o(t)}function d(a,o){let s=o?.sampler??c,r=o?.clock??Date,p={name:a},d=new Set;i.set(p,d);let m=(a,o)=>{let i=null!=o?"string"==typeof o?n(o):o:void 0,c=i?i.child():t(),u="boolean"!=typeof s?s(a,c,p):s;c.flags;let f={id:c,parent:i,start:r.now(),name:a,events:[],context:{}};u&&l.add([f,p]);let v=t=>e(v,t);return v.traceparent=c,v.span=m,v.set_context=e=>"function"==typeof e?void(f.context=e(f.context)):void Object.assign(f.context,e),v.add_event=(e,t)=>{f.events.push({name:e,timestamp:r.now(),attributes:t||{}})},v.end=()=>{null==f.end&&(f.end=r.now())},v.__add_promise=e=>{d.add(e),e.then((()=>d.delete(e)))},v};return{span:m}}exports.configure=r;exports.report=p;exports.tracer=d;
package/index.mjs CHANGED
@@ -1 +1 @@
1
- import{measure as e}from"rian/utils";import{make as t,parse as n,SAMPLED_FLAG as a}from"tctx";import{is_sampled as r}from"tctx";var o={};function s(e,t={}){o={...t,"service.name":e,"telemetry.sdk.name":"rian","telemetry.sdk.version":"0.3.1"}}var p=new Set,c=new WeakMap;async function i(e){let t=[],n=new Map;for(let[e,a]of p){let r;n.has(a)?r=n.get(a).spans:n.set(a,{scope:a,spans:r=[]}),r.push(e),c.has(a)&&(t.push(...c.get(a)),c.delete(a))}return p.clear(),t.length&&await Promise.all(t),e({resource:o,scopeSpans:n.values()})}function l(e,t){return r(t)}function d(a,r){let o=r?.sampler??l,s=r?.clock??Date,i={name:a},d=new Set;c.set(i,d);let m="string"==typeof r?.traceparent?n(r.traceparent):void 0,u=(n,a)=>{let r=a?a.child():t(),c="boolean"!=typeof o?o(n,r,i):o;r.flags;let l={id:r,parent:a,start:s.now(),name:n,events:[],context:{}};c&&p.add([l,i]);let m=t=>e(m,t);return m.traceparent=r,m.span=e=>u(e,r),m.set_context=e=>"function"==typeof e?void(l.context=e(l.context)):void Object.assign(l.context,e),m.add_event=(e,t)=>{l.events.push({name:e,timestamp:s.now(),attributes:t||{}})},m.end=()=>{null==l.end&&(l.end=s.now())},m.__add_promise=e=>{d.add(e),e.then((()=>d.delete(e)))},m};return{span:e=>u(e,m)}}export{s as configure,i as report,d as tracer};
1
+ import{measure as e}from"rian/utils";import{make as t,parse as n,SAMPLED_FLAG as a}from"tctx";import{is_sampled as o}from"tctx";var s={};function r(e,t={}){s={...t,"service.name":e,"telemetry.sdk.name":"rian","telemetry.sdk.version":"0.3.3"}}var l=new Set,i=new WeakMap;async function p(e){let t=[],n=new Map;for(let[e,a]of l){let o;n.has(a)?o=n.get(a).spans:n.set(a,{scope:a,spans:o=[]}),o.push(e),i.has(a)&&(t.push(...i.get(a)),i.delete(a))}return l.clear(),t.length&&await Promise.all(t),e({resource:s,scopeSpans:n.values()})}function c(e,t){return o(t)}function d(a,o){let s=o?.sampler??c,r=o?.clock??Date,p={name:a},d=new Set;i.set(p,d);let m=(a,o)=>{let i=null!=o?"string"==typeof o?n(o):o:void 0,c=i?i.child():t(),u="boolean"!=typeof s?s(a,c,p):s;c.flags;let f={id:c,parent:i,start:r.now(),name:a,events:[],context:{}};u&&l.add([f,p]);let v=t=>e(v,t);return v.traceparent=c,v.span=m,v.set_context=e=>"function"==typeof e?void(f.context=e(f.context)):void Object.assign(f.context,e),v.add_event=(e,t)=>{f.events.push({name:e,timestamp:r.now(),attributes:t||{}})},v.end=()=>{null==f.end&&(f.end=r.now())},v.__add_promise=e=>{d.add(e),e.then((()=>d.delete(e)))},v};return{span:m}}export{r as configure,p as report,d as tracer};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rian",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "Effective tracing for the edge and origins",
5
5
  "keywords": [
6
6
  "opentelemetry",
package/readme.md CHANGED
@@ -115,7 +115,7 @@ isn't accessible.
115
115
 
116
116
  > 💡 Note ~> this module should be used mutually exclusively with the main `rian` module.
117
117
 
118
- <detials>
118
+ <details>
119
119
 
120
120
  <summary>Example</summary>
121
121