rian 0.3.1 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- package/async.d.ts +5 -1
- package/async.js +1 -1
- package/async.mjs +1 -1
- package/index.d.ts +1 -8
- package/index.js +1 -1
- package/index.mjs +1 -1
- package/package.json +1 -1
- package/readme.md +1 -1
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(
|
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
|
+
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
|
+
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:
|
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
|
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