rian 0.3.3 → 0.3.5

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 +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.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;
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 l(e,t={}){s={...t,"service.name":e,"telemetry.sdk.name":"rian","telemetry.sdk.version":"0.3.5"}}var c=new Set,p=new WeakMap;async function u(e){let t=[],n=new Map;for(let[e,r]of c){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 c.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,a){let s=m.getStore();if(!s)throw Error("TODO");let l=s[0],u=l.scope,i=s[1],f=l.sampler,g=null!=a?"string"==typeof a?r(a):a:i?.traceparent,w=g?g.child():n(),h="boolean"!=typeof f?f(e,w,u):f;h?w.flags|=o:w.flags&=~o;let k={id:w,parent:g,start:l.clock.now(),name:e,events:[],context:{}};h&&c.add([k,u]);let v=e=>m.run([l,v],t,v,e);v.traceparent=w,v.span=e=>m.run([l,v],d,e),v.set_context=e=>{"function"!=typeof e?Object.assign(k.context,e):k.context=e(k.context)},v.add_event=(e,t)=>{k.events.push({name:e,timestamp:l.clock.now(),attributes:t||{}})},v.end=()=>{null==k.end&&(k.end=l.clock.now())};let x=p.get(u);return v.__add_promise=e=>{x.add(e),e.then((()=>x.delete(e)))},v}function g(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=l;exports.currentSpan=f;exports.report=u;exports.span=d;exports.tracer=g;
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.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};
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 l(e,t={}){s={...t,"service.name":e,"telemetry.sdk.name":"rian","telemetry.sdk.version":"0.3.5"}}var c=new Set,p=new WeakMap;async function u(e){let t=[],n=new Map;for(let[e,r]of c){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 c.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,a){let s=m.getStore();if(!s)throw Error("TODO");let l=s[0],u=l.scope,i=s[1],f=l.sampler,g=null!=a?"string"==typeof a?r(a):a:i?.traceparent,w=g?g.child():n(),h="boolean"!=typeof f?f(e,w,u):f;h?w.flags|=o:w.flags&=~o;let k={id:w,parent:g,start:l.clock.now(),name:e,events:[],context:{}};h&&c.add([k,u]);let v=e=>m.run([l,v],t,v,e);v.traceparent=w,v.span=e=>m.run([l,v],d,e),v.set_context=e=>{"function"!=typeof e?Object.assign(k.context,e):k.context=e(k.context)},v.add_event=(e,t)=>{k.events.push({name:e,timestamp:l.clock.now(),attributes:t||{}})},v.end=()=>{null==k.end&&(k.end=l.clock.now())};let x=p.get(u);return v.__add_promise=e=>{x.add(e),e.then((()=>x.delete(e)))},v}function g(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{l as configure,f as currentSpan,u as report,d as span,g as tracer};
package/index.d.ts CHANGED
@@ -5,10 +5,18 @@ import type { Traceparent } from 'tctx';
5
5
  /**
6
6
  * The exporter is called when the {@link report} method is called.
7
7
  */
8
- export type Exporter = (trace: {
9
- resource: Context;
8
+ export type Exporter = (trace: Trace) => any;
9
+
10
+ type Resource = {
11
+ 'service.name': string;
12
+ 'telemetry.sdk.name': string;
13
+ 'telemetry.sdk.version': string;
14
+ } & Context;
15
+
16
+ export type Trace = {
17
+ resource: Resource;
10
18
  scopeSpans: IterableIterator<ScopedSpans>;
11
- }) => any;
19
+ };
12
20
 
13
21
  export type ScopedSpans = {
14
22
  readonly scope: { readonly name: string };
@@ -43,15 +51,15 @@ export type Sampler = (
43
51
  /**
44
52
  * The name of the span.
45
53
  */
46
- readonly name: string,
54
+ name: string,
47
55
  /**
48
56
  * The traceparent id of the span.
49
57
  */
50
- readonly id: Traceparent,
58
+ id: Traceparent,
51
59
  /**
52
60
  * The tracer this span belongs to.
53
61
  */
54
- readonly tracer: { readonly name: string },
62
+ tracer: { readonly name: string },
55
63
  ) => boolean;
56
64
 
57
65
  // --- spans
@@ -229,7 +237,7 @@ export async function report<T extends Exporter>(
229
237
  * configure('my-service', { 'deployment.environment': 'production', 'k8s.namespace.name': 'default' });
230
238
  * ```
231
239
  */
232
- export function configure(name: string, attributes: Context = {}): void;
240
+ export function configure(name: string, attributes: Context): void;
233
241
 
234
242
  /**
235
243
  * Provinding a clock allows you to control the time of the span.
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: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;
1
+ const { measure:e } = require('rian/utils');const { make:t, parse:n, SAMPLED_FLAG:a } = require('tctx');const { is_sampled:s } = require('tctx');var o={};function r(e,t={}){o={...t,"service.name":e,"telemetry.sdk.name":"rian","telemetry.sdk.version":"0.3.5"}}var l=new Set,i=new WeakMap;async function p(e){let t=[],n=new Map;for(let[e,a]of l){let s;n.has(a)?s=n.get(a).spans:n.set(a,{scope:a,spans:s=[]}),s.push(e),i.has(a)&&(t.push(...i.get(a)),i.delete(a))}return l.clear(),t.length&&await Promise.all(t),e({resource:o,scopeSpans:n.values()})}function c(e,t){return s(t)}function d(s,o){let r=o?.sampler??c,p=o?.clock??Date,d={name:s},m=new Set;i.set(d,m);let u=(s,o)=>{let i=null!=o?"string"==typeof o?n(o):o:void 0,c=i?i.child():t(),f="boolean"!=typeof r?r(s,c,d):r;f?c.flags|=a:c.flags&=~a;let v={id:c,parent:i,start:p.now(),name:s,events:[],context:{}};f&&l.add([v,d]);let h=t=>e(h,t);return h.traceparent=c,h.span=(e,t)=>u(e,t||c),h.set_context=e=>"function"==typeof e?void(v.context=e(v.context)):void Object.assign(v.context,e),h.add_event=(e,t)=>{v.events.push({name:e,timestamp:p.now(),attributes:t||{}})},h.end=()=>{null==v.end&&(v.end=p.now())},h.__add_promise=e=>{m.add(e),e.then((()=>m.delete(e)))},h};return{span:u}}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 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};
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 s}from"tctx";var o={};function r(e,t={}){o={...t,"service.name":e,"telemetry.sdk.name":"rian","telemetry.sdk.version":"0.3.5"}}var l=new Set,i=new WeakMap;async function p(e){let t=[],n=new Map;for(let[e,a]of l){let s;n.has(a)?s=n.get(a).spans:n.set(a,{scope:a,spans:s=[]}),s.push(e),i.has(a)&&(t.push(...i.get(a)),i.delete(a))}return l.clear(),t.length&&await Promise.all(t),e({resource:o,scopeSpans:n.values()})}function c(e,t){return s(t)}function d(s,o){let r=o?.sampler??c,p=o?.clock??Date,d={name:s},m=new Set;i.set(d,m);let u=(s,o)=>{let i=null!=o?"string"==typeof o?n(o):o:void 0,c=i?i.child():t(),f="boolean"!=typeof r?r(s,c,d):r;f?c.flags|=a:c.flags&=~a;let v={id:c,parent:i,start:p.now(),name:s,events:[],context:{}};f&&l.add([v,d]);let h=t=>e(h,t);return h.traceparent=c,h.span=(e,t)=>u(e,t||c),h.set_context=e=>"function"==typeof e?void(v.context=e(v.context)):void Object.assign(v.context,e),h.add_event=(e,t)=>{v.events.push({name:e,timestamp:p.now(),attributes:t||{}})},h.end=()=>{null==v.end&&(v.end=p.now())},h.__add_promise=e=>{m.add(e),e.then((()=>m.delete(e)))},h};return{span:u}}export{r as configure,p as report,d as tracer};
package/license CHANGED
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
18
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
21
+ SOFTWARE.
package/package.json CHANGED
@@ -1,87 +1,87 @@
1
1
  {
2
- "name": "rian",
3
- "version": "0.3.3",
4
- "description": "Effective tracing for the edge and origins",
5
- "keywords": [
6
- "opentelemetry",
7
- "trace-context",
8
- "opentracing",
9
- "traceparent",
10
- "measure",
11
- "monitor",
12
- "observe",
13
- "tracing",
14
- "zipkin",
15
- "tracer",
16
- "trace"
17
- ],
18
- "repository": "maraisr/rian",
19
- "license": "MIT",
20
- "author": "Marais Rossow <me@marais.dev> (https://marais.io)",
21
- "sideEffects": false,
22
- "exports": {
23
- ".": {
24
- "types": "./index.d.ts",
25
- "import": "./index.mjs",
26
- "require": "./index.js"
27
- },
28
- "./async": {
29
- "types": "./async.d.ts",
30
- "import": "./async.mjs",
31
- "require": "./async.js"
32
- },
33
- "./exporter.otel.http": {
34
- "types": "./exporter.otel.http.d.ts",
35
- "import": "./exporter.otel.http.mjs",
36
- "require": "./exporter.otel.http.js"
37
- },
38
- "./exporter.zipkin": {
39
- "types": "./exporter.zipkin.d.ts",
40
- "import": "./exporter.zipkin.mjs",
41
- "require": "./exporter.zipkin.js"
42
- },
43
- "./utils": {
44
- "types": "./utils.d.ts",
45
- "import": "./utils.mjs",
46
- "require": "./utils.js"
47
- },
48
- "./package.json": "./package.json"
49
- },
50
- "main": "./index.js",
51
- "module": "./index.mjs",
52
- "types": "index.d.ts",
53
- "files": [
54
- "*.mjs",
55
- "*.js",
56
- "*.d.ts",
57
- "!global.d.ts",
58
- "exporter.*/*",
59
- "utils/*"
60
- ],
61
- "scripts": {
62
- "bench": "node -r tsm bench/index.ts",
63
- "build": "bundt --minify",
64
- "format": "prettier --write \"{*,{src,test}/**/*,examples/*/**,bench/*,.github/**/*}.+(ts|js|json|yml|md)\"",
65
- "pretest": "pnpm run build",
66
- "test": "uvu -r tsm test \".spec.m?ts$\"",
67
- "typecheck": "tsc --noEmit --skipLibCheck"
68
- },
69
- "dependencies": {
70
- "flattie": "^1.1.0",
71
- "tctx": "^0.0.10"
72
- },
73
- "devDependencies": {
74
- "@marais/prettier": "0.0.1",
75
- "@marais/tsconfig": "0.0.3",
76
- "bundt": "2.0.0-next.5",
77
- "nanospy": "0.5.0",
78
- "prettier": "2.7.1",
79
- "tsm": "2.2.2",
80
- "typescript": "4.8.4",
81
- "uvu": "0.5.6"
82
- },
83
- "prettier": "@marais/prettier",
84
- "volta": {
85
- "node": "17.2.0"
86
- }
2
+ "name": "rian",
3
+ "version": "0.3.5",
4
+ "description": "Effective tracing for the edge and origins",
5
+ "keywords": [
6
+ "opentelemetry",
7
+ "trace-context",
8
+ "opentracing",
9
+ "traceparent",
10
+ "measure",
11
+ "monitor",
12
+ "observe",
13
+ "tracing",
14
+ "zipkin",
15
+ "tracer",
16
+ "trace"
17
+ ],
18
+ "repository": "maraisr/rian",
19
+ "license": "MIT",
20
+ "author": "Marais Rossow <me@marais.dev> (https://marais.io)",
21
+ "sideEffects": false,
22
+ "exports": {
23
+ ".": {
24
+ "types": "./index.d.ts",
25
+ "import": "./index.mjs",
26
+ "require": "./index.js"
27
+ },
28
+ "./async": {
29
+ "types": "./async.d.ts",
30
+ "import": "./async.mjs",
31
+ "require": "./async.js"
32
+ },
33
+ "./exporter.otel.http": {
34
+ "types": "./exporter.otel.http.d.ts",
35
+ "import": "./exporter.otel.http.mjs",
36
+ "require": "./exporter.otel.http.js"
37
+ },
38
+ "./exporter.zipkin": {
39
+ "types": "./exporter.zipkin.d.ts",
40
+ "import": "./exporter.zipkin.mjs",
41
+ "require": "./exporter.zipkin.js"
42
+ },
43
+ "./utils": {
44
+ "types": "./utils.d.ts",
45
+ "import": "./utils.mjs",
46
+ "require": "./utils.js"
47
+ },
48
+ "./package.json": "./package.json"
49
+ },
50
+ "main": "./index.js",
51
+ "module": "./index.mjs",
52
+ "types": "index.d.ts",
53
+ "files": [
54
+ "*.mjs",
55
+ "*.js",
56
+ "*.d.ts",
57
+ "!global.d.ts",
58
+ "exporter.*/*",
59
+ "utils/*"
60
+ ],
61
+ "scripts": {
62
+ "bench": "node -r tsm bench/index.ts",
63
+ "build": "bundt --minify",
64
+ "format": "prettier --write \"{*,{src,test}/**/*,examples/*/**,bench/*,.github/**/*}.+(ts|js|json|yml|md)\"",
65
+ "pretest": "pnpm run build",
66
+ "test": "uvu src \".test.ts$\" -r tsm",
67
+ "typecheck": "tsc --noEmit"
68
+ },
69
+ "prettier": "@marais/prettier",
70
+ "dependencies": {
71
+ "flattie": "^1.1.0",
72
+ "tctx": "^0.0.13"
73
+ },
74
+ "devDependencies": {
75
+ "@marais/prettier": "0.0.4",
76
+ "@marais/tsconfig": "0.0.4",
77
+ "bundt": "2.0.0-next.5",
78
+ "nanospy": "1.0.0",
79
+ "prettier": "2.8.8",
80
+ "tsm": "2.3.0",
81
+ "typescript": "5.1.3",
82
+ "uvu": "0.5.4"
83
+ },
84
+ "volta": {
85
+ "node": "18.16.1"
86
+ }
87
87
  }
package/readme.md CHANGED
@@ -87,7 +87,7 @@ http.listen((req, executionCtx) => {
87
87
  /*
88
88
  And we end up with something like this in our reporting tool:
89
89
 
90
- [ GET /data .................,,...................... (1.2ms) ] { request }
90
+ [ GET /data ......................................... (1.2ms) ] { request }
91
91
  [ db::read .... (0.5ms) ] [ process records .... (0.5ms) ]
92
92
  ^ ^ ^ ^
93
93
  { user_id } ev { id: 1 } | |