rian 0.2.3 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- package/index.d.ts +14 -0
- package/index.js +1 -1
- package/index.mjs +1 -1
- package/package.json +1 -2
- package/readme.md +6 -7
package/index.d.ts
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
import type { Traceparent } from 'tctx';
|
2
|
+
|
1
3
|
/**
|
2
4
|
* Spans are units within a distributed trace. Spans encapsulate mainly 3 pieces of information, a
|
3
5
|
* {@link Span.name|name}, and a {@link Span.start|start} and {@link Span.end|end} time.
|
@@ -151,6 +153,16 @@ export type Sampler = (
|
|
151
153
|
context?: Context,
|
152
154
|
) => boolean;
|
153
155
|
|
156
|
+
/**
|
157
|
+
* Provinding a clock allows you to control the time of the span.
|
158
|
+
*/
|
159
|
+
export type ClockLike = {
|
160
|
+
/**
|
161
|
+
* Must return the number of milliseconds since the epoch.
|
162
|
+
*/
|
163
|
+
now(): number;
|
164
|
+
};
|
165
|
+
|
154
166
|
export interface Options {
|
155
167
|
/**
|
156
168
|
* @borrows {@link Exporter}
|
@@ -171,6 +183,8 @@ export interface Options {
|
|
171
183
|
* provided then one will be created obeying the {@link Options.sampler|sampling} rules.
|
172
184
|
*/
|
173
185
|
traceparent?: string | null;
|
186
|
+
|
187
|
+
clock?: ClockLike;
|
174
188
|
}
|
175
189
|
|
176
190
|
export const create: (name: string, options: Options) => Tracer;
|
package/index.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
const { measureFn:e } = require('rian/utils');const t = require('tctx');var n=(e,n)=>!n||t.is_sampled(n),a={"telemetry.sdk.name":"rian","telemetry.sdk.version":"0.2.
|
1
|
+
const { measureFn:e } = require('rian/utils');const t = require('tctx');var n=(e,n)=>!n||t.is_sampled(n),a={"telemetry.sdk.name":"rian","telemetry.sdk.version":"0.2.5"},r=(r,o)=>{let s=new Set,d=new Set,i=o.sampler||n,c="boolean"!=typeof i,p=o.clock||Date,l=(n,a)=>{let r=c?i(n,a,o.context):i,m=a?a.child(r):t.make(r),x={id:m,parent:a,start:p.now(),name:n,events:[],context:{}};r&&s.add(x);let u=t=>e(u,t);return u.traceparent=m,u.fork=e=>l(e,m),u.set_context=e=>{"function"!=typeof e?Object.assign(x.context,e):x.context=e(x.context)},u.add_event=(e,t)=>{x.events.push({name:e,timestamp:p.now(),attributes:t||{}})},u.end=()=>{null==x.end&&(x.end=p.now())},u.__add_promise=d.add.bind(d),u},m=l(r,"string"==typeof o.traceparent?t.parse(o.traceparent):void 0),x=m.end.bind(m);return m.end=async()=>(x(),d.size>0&&await Promise.all([...d.values()]),o.exporter(s,{...o.context||{},...a})),m};exports.create=r;
|
package/index.mjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
import{measureFn as e}from"rian/utils";import*as t from"tctx";var n=(e,n)=>!n||t.is_sampled(n),a={"telemetry.sdk.name":"rian","telemetry.sdk.version":"0.2.
|
1
|
+
import{measureFn as e}from"rian/utils";import*as t from"tctx";var n=(e,n)=>!n||t.is_sampled(n),a={"telemetry.sdk.name":"rian","telemetry.sdk.version":"0.2.5"},r=(r,o)=>{let s=new Set,d=new Set,i=o.sampler||n,c="boolean"!=typeof i,p=o.clock||Date,l=(n,a)=>{let r=c?i(n,a,o.context):i,m=a?a.child(r):t.make(r),x={id:m,parent:a,start:p.now(),name:n,events:[],context:{}};r&&s.add(x);let u=t=>e(u,t);return u.traceparent=m,u.fork=e=>l(e,m),u.set_context=e=>{"function"!=typeof e?Object.assign(x.context,e):x.context=e(x.context)},u.add_event=(e,t)=>{x.events.push({name:e,timestamp:p.now(),attributes:t||{}})},u.end=()=>{null==x.end&&(x.end=p.now())},u.__add_promise=d.add.bind(d),u},m=l(r,"string"==typeof o.traceparent?t.parse(o.traceparent):void 0),x=m.end.bind(m);return m.end=async()=>(x(),d.size>0&&await Promise.all([...d.values()]),o.exporter(s,{...o.context||{},...a})),m};export{r as create};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "rian",
|
3
|
-
"version": "0.2.
|
3
|
+
"version": "0.2.5",
|
4
4
|
"description": "Effective tracing for the edge and origins",
|
5
5
|
"keywords": [
|
6
6
|
"opentelemetry",
|
@@ -19,7 +19,6 @@
|
|
19
19
|
"license": "MIT",
|
20
20
|
"author": "Marais Rossow <me@marais.dev> (https://marais.io)",
|
21
21
|
"sideEffects": false,
|
22
|
-
"type": "module",
|
23
22
|
"exports": {
|
24
23
|
".": {
|
25
24
|
"types": "./index.d.ts",
|
package/readme.md
CHANGED
@@ -249,9 +249,9 @@ Validation :: single span
|
|
249
249
|
✔ opentracing
|
250
250
|
|
251
251
|
Benchmark :: single span
|
252
|
-
rian x
|
253
|
-
opentelemetry x
|
254
|
-
opentracing x
|
252
|
+
rian x 381,751 ops/sec ±4.17% (84 runs sampled)
|
253
|
+
opentelemetry x 201,584 ops/sec ±13.97% (63 runs sampled)
|
254
|
+
opentracing x 57,881 ops/sec ±38.08% (96 runs sampled)
|
255
255
|
|
256
256
|
Validation :: child span
|
257
257
|
✔ rian
|
@@ -259,10 +259,9 @@ Validation :: child span
|
|
259
259
|
✔ opentracing
|
260
260
|
|
261
261
|
Benchmark :: child span
|
262
|
-
rian x
|
263
|
-
opentelemetry x
|
264
|
-
opentracing x
|
265
|
-
|
262
|
+
rian x 204,952 ops/sec ±5.78% (82 runs sampled)
|
263
|
+
opentelemetry x 128,768 ops/sec ±11.47% (68 runs sampled)
|
264
|
+
opentracing x 36,181 ops/sec ±0.64% (97 runs sampled)
|
266
265
|
```
|
267
266
|
|
268
267
|
> And please... I know these results are anything but the full story. But it's a number and point on comparison.
|