rian 0.2.1 → 0.2.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/exporter.otel.http/index.js +1 -110
 - package/exporter.otel.http/index.mjs +1 -110
 - package/exporter.zipkin/index.js +1 -43
 - package/exporter.zipkin/index.mjs +1 -43
 - package/index.js +1 -76
 - package/index.mjs +1 -76
 - package/package.json +2 -2
 - package/utils/index.js +1 -30
 - package/utils/index.mjs +1 -30
 
| 
         @@ -1,110 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
       2 
     | 
    
         
            -
            const { name:rian_name, version:rian_version } = require('rian/package.json');
         
     | 
| 
       3 
     | 
    
         
            -
            var SpanStatusCode_UNSET = 0;
         
     | 
| 
       4 
     | 
    
         
            -
            var SpanStatusCode_ERROR = 2;
         
     | 
| 
       5 
     | 
    
         
            -
            var convert_value_to_anyvalue = (value) => {
         
     | 
| 
       6 
     | 
    
         
            -
              let type = typeof value, any_value = {};
         
     | 
| 
       7 
     | 
    
         
            -
              if (type === "string")
         
     | 
| 
       8 
     | 
    
         
            -
                any_value.stringValue = value;
         
     | 
| 
       9 
     | 
    
         
            -
              else if (type === "number")
         
     | 
| 
       10 
     | 
    
         
            -
                if (Number.isInteger(value))
         
     | 
| 
       11 
     | 
    
         
            -
                  any_value.intValue = value;
         
     | 
| 
       12 
     | 
    
         
            -
                else
         
     | 
| 
       13 
     | 
    
         
            -
                  any_value.doubleValue = value;
         
     | 
| 
       14 
     | 
    
         
            -
              else if (type === "boolean")
         
     | 
| 
       15 
     | 
    
         
            -
                any_value.boolValue = value;
         
     | 
| 
       16 
     | 
    
         
            -
              else if (Array.isArray(value))
         
     | 
| 
       17 
     | 
    
         
            -
                any_value.arrayValue = {
         
     | 
| 
       18 
     | 
    
         
            -
                  values: value.map((i) => convert_value_to_anyvalue(i))
         
     | 
| 
       19 
     | 
    
         
            -
                };
         
     | 
| 
       20 
     | 
    
         
            -
              else if (value)
         
     | 
| 
       21 
     | 
    
         
            -
                any_value.kvlistValue = { values: convert_object_to_kv(value) };
         
     | 
| 
       22 
     | 
    
         
            -
              return any_value;
         
     | 
| 
       23 
     | 
    
         
            -
            };
         
     | 
| 
       24 
     | 
    
         
            -
            var convert_object_to_kv = (input) => {
         
     | 
| 
       25 
     | 
    
         
            -
              const value = [];
         
     | 
| 
       26 
     | 
    
         
            -
              for (let key of Object.keys(input)) {
         
     | 
| 
       27 
     | 
    
         
            -
                value.push({
         
     | 
| 
       28 
     | 
    
         
            -
                  key,
         
     | 
| 
       29 
     | 
    
         
            -
                  value: convert_value_to_anyvalue(input[key])
         
     | 
| 
       30 
     | 
    
         
            -
                });
         
     | 
| 
       31 
     | 
    
         
            -
              }
         
     | 
| 
       32 
     | 
    
         
            -
              return value;
         
     | 
| 
       33 
     | 
    
         
            -
            };
         
     | 
| 
       34 
     | 
    
         
            -
            var map_kind = (kind) => {
         
     | 
| 
       35 
     | 
    
         
            -
              switch (kind) {
         
     | 
| 
       36 
     | 
    
         
            -
                default:
         
     | 
| 
       37 
     | 
    
         
            -
                case "INTERNAL": {
         
     | 
| 
       38 
     | 
    
         
            -
                  return 1;
         
     | 
| 
       39 
     | 
    
         
            -
                }
         
     | 
| 
       40 
     | 
    
         
            -
                case "SERVER": {
         
     | 
| 
       41 
     | 
    
         
            -
                  return 2;
         
     | 
| 
       42 
     | 
    
         
            -
                }
         
     | 
| 
       43 
     | 
    
         
            -
                case "CLIENT": {
         
     | 
| 
       44 
     | 
    
         
            -
                  return 3;
         
     | 
| 
       45 
     | 
    
         
            -
                }
         
     | 
| 
       46 
     | 
    
         
            -
                case "PRODUCER": {
         
     | 
| 
       47 
     | 
    
         
            -
                  return 4;
         
     | 
| 
       48 
     | 
    
         
            -
                }
         
     | 
| 
       49 
     | 
    
         
            -
                case "CONSUMER": {
         
     | 
| 
       50 
     | 
    
         
            -
                  return 5;
         
     | 
| 
       51 
     | 
    
         
            -
                }
         
     | 
| 
       52 
     | 
    
         
            -
              }
         
     | 
| 
       53 
     | 
    
         
            -
            };
         
     | 
| 
       54 
     | 
    
         
            -
            var exporter = (request) => (spans, context) => {
         
     | 
| 
       55 
     | 
    
         
            -
              const otel_spans = [];
         
     | 
| 
       56 
     | 
    
         
            -
              for (let span of spans) {
         
     | 
| 
       57 
     | 
    
         
            -
                const { kind, error, ...span_ctx } = span.context;
         
     | 
| 
       58 
     | 
    
         
            -
                let status;
         
     | 
| 
       59 
     | 
    
         
            -
                if (error) {
         
     | 
| 
       60 
     | 
    
         
            -
                  status = {
         
     | 
| 
       61 
     | 
    
         
            -
                    code: SpanStatusCode_ERROR
         
     | 
| 
       62 
     | 
    
         
            -
                  };
         
     | 
| 
       63 
     | 
    
         
            -
                  if ("message" in error) {
         
     | 
| 
       64 
     | 
    
         
            -
                    status.message = error.message;
         
     | 
| 
       65 
     | 
    
         
            -
                  }
         
     | 
| 
       66 
     | 
    
         
            -
                }
         
     | 
| 
       67 
     | 
    
         
            -
                otel_spans.push({
         
     | 
| 
       68 
     | 
    
         
            -
                  traceId: span.id.trace_id,
         
     | 
| 
       69 
     | 
    
         
            -
                  spanId: span.id.parent_id,
         
     | 
| 
       70 
     | 
    
         
            -
                  parentSpanId: span.parent?.parent_id,
         
     | 
| 
       71 
     | 
    
         
            -
                  name: span.name,
         
     | 
| 
       72 
     | 
    
         
            -
                  kind: map_kind(kind || "INTERNAL"),
         
     | 
| 
       73 
     | 
    
         
            -
                  startTimeUnixNano: span.start * 1e6,
         
     | 
| 
       74 
     | 
    
         
            -
                  endTimeUnixNano: span.end ? span.end * 1e6 : void 0,
         
     | 
| 
       75 
     | 
    
         
            -
                  droppedAttributesCount: 0,
         
     | 
| 
       76 
     | 
    
         
            -
                  droppedEventsCount: 0,
         
     | 
| 
       77 
     | 
    
         
            -
                  droppedLinksCount: 0,
         
     | 
| 
       78 
     | 
    
         
            -
                  attributes: convert_object_to_kv(span_ctx),
         
     | 
| 
       79 
     | 
    
         
            -
                  status: status || { code: SpanStatusCode_UNSET },
         
     | 
| 
       80 
     | 
    
         
            -
                  events: span.events.map((i) => ({
         
     | 
| 
       81 
     | 
    
         
            -
                    name: i.name,
         
     | 
| 
       82 
     | 
    
         
            -
                    attributes: convert_object_to_kv(i.attributes),
         
     | 
| 
       83 
     | 
    
         
            -
                    droppedAttributesCount: 0,
         
     | 
| 
       84 
     | 
    
         
            -
                    timeUnixNano: i.timestamp * 1e6
         
     | 
| 
       85 
     | 
    
         
            -
                  }))
         
     | 
| 
       86 
     | 
    
         
            -
                });
         
     | 
| 
       87 
     | 
    
         
            -
              }
         
     | 
| 
       88 
     | 
    
         
            -
              return request({
         
     | 
| 
       89 
     | 
    
         
            -
                resourceSpans: [
         
     | 
| 
       90 
     | 
    
         
            -
                  {
         
     | 
| 
       91 
     | 
    
         
            -
                    resource: {
         
     | 
| 
       92 
     | 
    
         
            -
                      attributes: convert_object_to_kv(context),
         
     | 
| 
       93 
     | 
    
         
            -
                      droppedAttributesCount: 0
         
     | 
| 
       94 
     | 
    
         
            -
                    },
         
     | 
| 
       95 
     | 
    
         
            -
                    instrumentationLibrarySpans: [
         
     | 
| 
       96 
     | 
    
         
            -
                      {
         
     | 
| 
       97 
     | 
    
         
            -
                        instrumentationLibrary: {
         
     | 
| 
       98 
     | 
    
         
            -
                          name: rian_name,
         
     | 
| 
       99 
     | 
    
         
            -
                          version: rian_version
         
     | 
| 
       100 
     | 
    
         
            -
                        },
         
     | 
| 
       101 
     | 
    
         
            -
                        spans: otel_spans
         
     | 
| 
       102 
     | 
    
         
            -
                      }
         
     | 
| 
       103 
     | 
    
         
            -
                    ]
         
     | 
| 
       104 
     | 
    
         
            -
                  }
         
     | 
| 
       105 
     | 
    
         
            -
                ]
         
     | 
| 
       106 
     | 
    
         
            -
              });
         
     | 
| 
       107 
     | 
    
         
            -
            };
         
     | 
| 
       108 
     | 
    
         
            -
             
     | 
| 
       109 
     | 
    
         
            -
             
     | 
| 
       110 
     | 
    
         
            -
            exports.exporter = exporter;
         
     | 
| 
      
 1 
     | 
    
         
            +
            const { name:e, version:t } = require('rian/package.json');var r=e=>{let t=typeof e,n={};return"string"===t?n.stringValue=e:"number"===t?Number.isInteger(e)?n.intValue=e:n.doubleValue=e:"boolean"===t?n.boolValue=e:Array.isArray(e)?n.arrayValue={values:e.map((e=>r(e)))}:e&&(n.kvlistValue={values:a(e)}),n},a=e=>{let t=[];for(let a of Object.keys(e))t.push({key:a,value:r(e[a])});return t},n=e=>{switch(e){default:case"INTERNAL":return 1;case"SERVER":return 2;case"CLIENT":return 3;case"PRODUCER":return 4;case"CONSUMER":return 5}},s=r=>(s,i)=>{let u=[];for(let e of s){let t,{kind:r,error:s,...i}=e.context;s&&(t={code:2},"message"in s&&(t.message=s.message)),u.push({traceId:e.id.trace_id,spanId:e.id.parent_id,parentSpanId:e.parent?.parent_id,name:e.name,kind:n(r||"INTERNAL"),startTimeUnixNano:1e6*e.start,endTimeUnixNano:e.end?1e6*e.end:void 0,droppedAttributesCount:0,droppedEventsCount:0,droppedLinksCount:0,attributes:a(i),status:t||{code:0},events:e.events.map((e=>({name:e.name,attributes:a(e.attributes),droppedAttributesCount:0,timeUnixNano:1e6*e.timestamp})))})}return r({resourceSpans:[{resource:{attributes:a(i),droppedAttributesCount:0},instrumentationLibrarySpans:[{instrumentationLibrary:{name:e,version:t},spans:u}]}]})};exports.exporter=s;
         
     | 
| 
         @@ -1,110 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
       2 
     | 
    
         
            -
            import { name as rian_name, version as rian_version } from "rian/package.json";
         
     | 
| 
       3 
     | 
    
         
            -
            var SpanStatusCode_UNSET = 0;
         
     | 
| 
       4 
     | 
    
         
            -
            var SpanStatusCode_ERROR = 2;
         
     | 
| 
       5 
     | 
    
         
            -
            var convert_value_to_anyvalue = (value) => {
         
     | 
| 
       6 
     | 
    
         
            -
              let type = typeof value, any_value = {};
         
     | 
| 
       7 
     | 
    
         
            -
              if (type === "string")
         
     | 
| 
       8 
     | 
    
         
            -
                any_value.stringValue = value;
         
     | 
| 
       9 
     | 
    
         
            -
              else if (type === "number")
         
     | 
| 
       10 
     | 
    
         
            -
                if (Number.isInteger(value))
         
     | 
| 
       11 
     | 
    
         
            -
                  any_value.intValue = value;
         
     | 
| 
       12 
     | 
    
         
            -
                else
         
     | 
| 
       13 
     | 
    
         
            -
                  any_value.doubleValue = value;
         
     | 
| 
       14 
     | 
    
         
            -
              else if (type === "boolean")
         
     | 
| 
       15 
     | 
    
         
            -
                any_value.boolValue = value;
         
     | 
| 
       16 
     | 
    
         
            -
              else if (Array.isArray(value))
         
     | 
| 
       17 
     | 
    
         
            -
                any_value.arrayValue = {
         
     | 
| 
       18 
     | 
    
         
            -
                  values: value.map((i) => convert_value_to_anyvalue(i))
         
     | 
| 
       19 
     | 
    
         
            -
                };
         
     | 
| 
       20 
     | 
    
         
            -
              else if (value)
         
     | 
| 
       21 
     | 
    
         
            -
                any_value.kvlistValue = { values: convert_object_to_kv(value) };
         
     | 
| 
       22 
     | 
    
         
            -
              return any_value;
         
     | 
| 
       23 
     | 
    
         
            -
            };
         
     | 
| 
       24 
     | 
    
         
            -
            var convert_object_to_kv = (input) => {
         
     | 
| 
       25 
     | 
    
         
            -
              const value = [];
         
     | 
| 
       26 
     | 
    
         
            -
              for (let key of Object.keys(input)) {
         
     | 
| 
       27 
     | 
    
         
            -
                value.push({
         
     | 
| 
       28 
     | 
    
         
            -
                  key,
         
     | 
| 
       29 
     | 
    
         
            -
                  value: convert_value_to_anyvalue(input[key])
         
     | 
| 
       30 
     | 
    
         
            -
                });
         
     | 
| 
       31 
     | 
    
         
            -
              }
         
     | 
| 
       32 
     | 
    
         
            -
              return value;
         
     | 
| 
       33 
     | 
    
         
            -
            };
         
     | 
| 
       34 
     | 
    
         
            -
            var map_kind = (kind) => {
         
     | 
| 
       35 
     | 
    
         
            -
              switch (kind) {
         
     | 
| 
       36 
     | 
    
         
            -
                default:
         
     | 
| 
       37 
     | 
    
         
            -
                case "INTERNAL": {
         
     | 
| 
       38 
     | 
    
         
            -
                  return 1;
         
     | 
| 
       39 
     | 
    
         
            -
                }
         
     | 
| 
       40 
     | 
    
         
            -
                case "SERVER": {
         
     | 
| 
       41 
     | 
    
         
            -
                  return 2;
         
     | 
| 
       42 
     | 
    
         
            -
                }
         
     | 
| 
       43 
     | 
    
         
            -
                case "CLIENT": {
         
     | 
| 
       44 
     | 
    
         
            -
                  return 3;
         
     | 
| 
       45 
     | 
    
         
            -
                }
         
     | 
| 
       46 
     | 
    
         
            -
                case "PRODUCER": {
         
     | 
| 
       47 
     | 
    
         
            -
                  return 4;
         
     | 
| 
       48 
     | 
    
         
            -
                }
         
     | 
| 
       49 
     | 
    
         
            -
                case "CONSUMER": {
         
     | 
| 
       50 
     | 
    
         
            -
                  return 5;
         
     | 
| 
       51 
     | 
    
         
            -
                }
         
     | 
| 
       52 
     | 
    
         
            -
              }
         
     | 
| 
       53 
     | 
    
         
            -
            };
         
     | 
| 
       54 
     | 
    
         
            -
            var exporter = (request) => (spans, context) => {
         
     | 
| 
       55 
     | 
    
         
            -
              const otel_spans = [];
         
     | 
| 
       56 
     | 
    
         
            -
              for (let span of spans) {
         
     | 
| 
       57 
     | 
    
         
            -
                const { kind, error, ...span_ctx } = span.context;
         
     | 
| 
       58 
     | 
    
         
            -
                let status;
         
     | 
| 
       59 
     | 
    
         
            -
                if (error) {
         
     | 
| 
       60 
     | 
    
         
            -
                  status = {
         
     | 
| 
       61 
     | 
    
         
            -
                    code: SpanStatusCode_ERROR
         
     | 
| 
       62 
     | 
    
         
            -
                  };
         
     | 
| 
       63 
     | 
    
         
            -
                  if ("message" in error) {
         
     | 
| 
       64 
     | 
    
         
            -
                    status.message = error.message;
         
     | 
| 
       65 
     | 
    
         
            -
                  }
         
     | 
| 
       66 
     | 
    
         
            -
                }
         
     | 
| 
       67 
     | 
    
         
            -
                otel_spans.push({
         
     | 
| 
       68 
     | 
    
         
            -
                  traceId: span.id.trace_id,
         
     | 
| 
       69 
     | 
    
         
            -
                  spanId: span.id.parent_id,
         
     | 
| 
       70 
     | 
    
         
            -
                  parentSpanId: span.parent?.parent_id,
         
     | 
| 
       71 
     | 
    
         
            -
                  name: span.name,
         
     | 
| 
       72 
     | 
    
         
            -
                  kind: map_kind(kind || "INTERNAL"),
         
     | 
| 
       73 
     | 
    
         
            -
                  startTimeUnixNano: span.start * 1e6,
         
     | 
| 
       74 
     | 
    
         
            -
                  endTimeUnixNano: span.end ? span.end * 1e6 : void 0,
         
     | 
| 
       75 
     | 
    
         
            -
                  droppedAttributesCount: 0,
         
     | 
| 
       76 
     | 
    
         
            -
                  droppedEventsCount: 0,
         
     | 
| 
       77 
     | 
    
         
            -
                  droppedLinksCount: 0,
         
     | 
| 
       78 
     | 
    
         
            -
                  attributes: convert_object_to_kv(span_ctx),
         
     | 
| 
       79 
     | 
    
         
            -
                  status: status || { code: SpanStatusCode_UNSET },
         
     | 
| 
       80 
     | 
    
         
            -
                  events: span.events.map((i) => ({
         
     | 
| 
       81 
     | 
    
         
            -
                    name: i.name,
         
     | 
| 
       82 
     | 
    
         
            -
                    attributes: convert_object_to_kv(i.attributes),
         
     | 
| 
       83 
     | 
    
         
            -
                    droppedAttributesCount: 0,
         
     | 
| 
       84 
     | 
    
         
            -
                    timeUnixNano: i.timestamp * 1e6
         
     | 
| 
       85 
     | 
    
         
            -
                  }))
         
     | 
| 
       86 
     | 
    
         
            -
                });
         
     | 
| 
       87 
     | 
    
         
            -
              }
         
     | 
| 
       88 
     | 
    
         
            -
              return request({
         
     | 
| 
       89 
     | 
    
         
            -
                resourceSpans: [
         
     | 
| 
       90 
     | 
    
         
            -
                  {
         
     | 
| 
       91 
     | 
    
         
            -
                    resource: {
         
     | 
| 
       92 
     | 
    
         
            -
                      attributes: convert_object_to_kv(context),
         
     | 
| 
       93 
     | 
    
         
            -
                      droppedAttributesCount: 0
         
     | 
| 
       94 
     | 
    
         
            -
                    },
         
     | 
| 
       95 
     | 
    
         
            -
                    instrumentationLibrarySpans: [
         
     | 
| 
       96 
     | 
    
         
            -
                      {
         
     | 
| 
       97 
     | 
    
         
            -
                        instrumentationLibrary: {
         
     | 
| 
       98 
     | 
    
         
            -
                          name: rian_name,
         
     | 
| 
       99 
     | 
    
         
            -
                          version: rian_version
         
     | 
| 
       100 
     | 
    
         
            -
                        },
         
     | 
| 
       101 
     | 
    
         
            -
                        spans: otel_spans
         
     | 
| 
       102 
     | 
    
         
            -
                      }
         
     | 
| 
       103 
     | 
    
         
            -
                    ]
         
     | 
| 
       104 
     | 
    
         
            -
                  }
         
     | 
| 
       105 
     | 
    
         
            -
                ]
         
     | 
| 
       106 
     | 
    
         
            -
              });
         
     | 
| 
       107 
     | 
    
         
            -
            };
         
     | 
| 
       108 
     | 
    
         
            -
            export {
         
     | 
| 
       109 
     | 
    
         
            -
              exporter
         
     | 
| 
       110 
     | 
    
         
            -
            };
         
     | 
| 
      
 1 
     | 
    
         
            +
            import{name as e,version as t}from"rian/package.json";var r=e=>{let t=typeof e,n={};return"string"===t?n.stringValue=e:"number"===t?Number.isInteger(e)?n.intValue=e:n.doubleValue=e:"boolean"===t?n.boolValue=e:Array.isArray(e)?n.arrayValue={values:e.map((e=>r(e)))}:e&&(n.kvlistValue={values:a(e)}),n},a=e=>{let t=[];for(let a of Object.keys(e))t.push({key:a,value:r(e[a])});return t},n=e=>{switch(e){default:case"INTERNAL":return 1;case"SERVER":return 2;case"CLIENT":return 3;case"PRODUCER":return 4;case"CONSUMER":return 5}},s=r=>(s,i)=>{let u=[];for(let e of s){let t,{kind:r,error:s,...i}=e.context;s&&(t={code:2},"message"in s&&(t.message=s.message)),u.push({traceId:e.id.trace_id,spanId:e.id.parent_id,parentSpanId:e.parent?.parent_id,name:e.name,kind:n(r||"INTERNAL"),startTimeUnixNano:1e6*e.start,endTimeUnixNano:e.end?1e6*e.end:void 0,droppedAttributesCount:0,droppedEventsCount:0,droppedLinksCount:0,attributes:a(i),status:t||{code:0},events:e.events.map((e=>({name:e.name,attributes:a(e.attributes),droppedAttributesCount:0,timeUnixNano:1e6*e.timestamp})))})}return r({resourceSpans:[{resource:{attributes:a(i),droppedAttributesCount:0},instrumentationLibrarySpans:[{instrumentationLibrary:{name:e,version:t},spans:u}]}]})};export{s as exporter};
         
     | 
    
        package/exporter.zipkin/index.js
    CHANGED
    
    | 
         @@ -1,43 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
       2 
     | 
    
         
            -
            const { flattie } = require('flattie');
         
     | 
| 
       3 
     | 
    
         
            -
            var exporter = (request) => (spans, context) => {
         
     | 
| 
       4 
     | 
    
         
            -
              const zipkin = [];
         
     | 
| 
       5 
     | 
    
         
            -
              for (let span of spans) {
         
     | 
| 
       6 
     | 
    
         
            -
                const { kind, error, ...span_ctx } = span.context;
         
     | 
| 
       7 
     | 
    
         
            -
                if (error) {
         
     | 
| 
       8 
     | 
    
         
            -
                  if ("message" in error) {
         
     | 
| 
       9 
     | 
    
         
            -
                    span_ctx.error = {
         
     | 
| 
       10 
     | 
    
         
            -
                      name: error.name,
         
     | 
| 
       11 
     | 
    
         
            -
                      message: error.message,
         
     | 
| 
       12 
     | 
    
         
            -
                      stack: error.stack
         
     | 
| 
       13 
     | 
    
         
            -
                    };
         
     | 
| 
       14 
     | 
    
         
            -
                  } else {
         
     | 
| 
       15 
     | 
    
         
            -
                    span_ctx.error = true;
         
     | 
| 
       16 
     | 
    
         
            -
                  }
         
     | 
| 
       17 
     | 
    
         
            -
                }
         
     | 
| 
       18 
     | 
    
         
            -
                zipkin.push({
         
     | 
| 
       19 
     | 
    
         
            -
                  id: span.id.parent_id,
         
     | 
| 
       20 
     | 
    
         
            -
                  traceId: span.id.trace_id,
         
     | 
| 
       21 
     | 
    
         
            -
                  parentId: span.parent ? span.parent.parent_id : void 0,
         
     | 
| 
       22 
     | 
    
         
            -
                  name: span.name,
         
     | 
| 
       23 
     | 
    
         
            -
                  kind: kind === "INTERNAL" ? void 0 : kind,
         
     | 
| 
       24 
     | 
    
         
            -
                  timestamp: span.start * 1e3,
         
     | 
| 
       25 
     | 
    
         
            -
                  duration: span.end ? (span.end - span.start) * 1e3 : void 0,
         
     | 
| 
       26 
     | 
    
         
            -
                  localEndpoint: context.localEndpoint || {
         
     | 
| 
       27 
     | 
    
         
            -
                    serviceName: span_ctx["service.name"]
         
     | 
| 
       28 
     | 
    
         
            -
                  },
         
     | 
| 
       29 
     | 
    
         
            -
                  tags: flattie({
         
     | 
| 
       30 
     | 
    
         
            -
                    ...context,
         
     | 
| 
       31 
     | 
    
         
            -
                    ...span_ctx
         
     | 
| 
       32 
     | 
    
         
            -
                  }, ".", true),
         
     | 
| 
       33 
     | 
    
         
            -
                  annotations: span.events.map((i) => ({
         
     | 
| 
       34 
     | 
    
         
            -
                    value: `${i.name} :: ${JSON.stringify(i.attributes)}`,
         
     | 
| 
       35 
     | 
    
         
            -
                    timestamp: i.timestamp * 1e3
         
     | 
| 
       36 
     | 
    
         
            -
                  }))
         
     | 
| 
       37 
     | 
    
         
            -
                });
         
     | 
| 
       38 
     | 
    
         
            -
              }
         
     | 
| 
       39 
     | 
    
         
            -
              return request(zipkin);
         
     | 
| 
       40 
     | 
    
         
            -
            };
         
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
     | 
    
         
            -
            exports.exporter = exporter;
         
     | 
| 
      
 1 
     | 
    
         
            +
            const { flattie:e } = require('flattie');var t=t=>(a,n)=>{let r=[];for(let t of a){let{kind:a,error:i,...s}=t.context;i&&(s.error=!("message"in i)||{name:i.name,message:i.message,stack:i.stack}),r.push({id:t.id.parent_id,traceId:t.id.trace_id,parentId:t.parent?t.parent.parent_id:void 0,name:t.name,kind:"INTERNAL"===a?void 0:a,timestamp:1e3*t.start,duration:t.end?1e3*(t.end-t.start):void 0,localEndpoint:n.localEndpoint||{serviceName:s["service.name"]},tags:e({...n,...s},".",!0),annotations:t.events.map((e=>({value:`${e.name} :: ${JSON.stringify(e.attributes)}`,timestamp:1e3*e.timestamp})))})}return t(r)};exports.exporter=t;
         
     | 
| 
         @@ -1,43 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
       2 
     | 
    
         
            -
            import { flattie } from "flattie";
         
     | 
| 
       3 
     | 
    
         
            -
            var exporter = (request) => (spans, context) => {
         
     | 
| 
       4 
     | 
    
         
            -
              const zipkin = [];
         
     | 
| 
       5 
     | 
    
         
            -
              for (let span of spans) {
         
     | 
| 
       6 
     | 
    
         
            -
                const { kind, error, ...span_ctx } = span.context;
         
     | 
| 
       7 
     | 
    
         
            -
                if (error) {
         
     | 
| 
       8 
     | 
    
         
            -
                  if ("message" in error) {
         
     | 
| 
       9 
     | 
    
         
            -
                    span_ctx.error = {
         
     | 
| 
       10 
     | 
    
         
            -
                      name: error.name,
         
     | 
| 
       11 
     | 
    
         
            -
                      message: error.message,
         
     | 
| 
       12 
     | 
    
         
            -
                      stack: error.stack
         
     | 
| 
       13 
     | 
    
         
            -
                    };
         
     | 
| 
       14 
     | 
    
         
            -
                  } else {
         
     | 
| 
       15 
     | 
    
         
            -
                    span_ctx.error = true;
         
     | 
| 
       16 
     | 
    
         
            -
                  }
         
     | 
| 
       17 
     | 
    
         
            -
                }
         
     | 
| 
       18 
     | 
    
         
            -
                zipkin.push({
         
     | 
| 
       19 
     | 
    
         
            -
                  id: span.id.parent_id,
         
     | 
| 
       20 
     | 
    
         
            -
                  traceId: span.id.trace_id,
         
     | 
| 
       21 
     | 
    
         
            -
                  parentId: span.parent ? span.parent.parent_id : void 0,
         
     | 
| 
       22 
     | 
    
         
            -
                  name: span.name,
         
     | 
| 
       23 
     | 
    
         
            -
                  kind: kind === "INTERNAL" ? void 0 : kind,
         
     | 
| 
       24 
     | 
    
         
            -
                  timestamp: span.start * 1e3,
         
     | 
| 
       25 
     | 
    
         
            -
                  duration: span.end ? (span.end - span.start) * 1e3 : void 0,
         
     | 
| 
       26 
     | 
    
         
            -
                  localEndpoint: context.localEndpoint || {
         
     | 
| 
       27 
     | 
    
         
            -
                    serviceName: span_ctx["service.name"]
         
     | 
| 
       28 
     | 
    
         
            -
                  },
         
     | 
| 
       29 
     | 
    
         
            -
                  tags: flattie({
         
     | 
| 
       30 
     | 
    
         
            -
                    ...context,
         
     | 
| 
       31 
     | 
    
         
            -
                    ...span_ctx
         
     | 
| 
       32 
     | 
    
         
            -
                  }, ".", true),
         
     | 
| 
       33 
     | 
    
         
            -
                  annotations: span.events.map((i) => ({
         
     | 
| 
       34 
     | 
    
         
            -
                    value: `${i.name} :: ${JSON.stringify(i.attributes)}`,
         
     | 
| 
       35 
     | 
    
         
            -
                    timestamp: i.timestamp * 1e3
         
     | 
| 
       36 
     | 
    
         
            -
                  }))
         
     | 
| 
       37 
     | 
    
         
            -
                });
         
     | 
| 
       38 
     | 
    
         
            -
              }
         
     | 
| 
       39 
     | 
    
         
            -
              return request(zipkin);
         
     | 
| 
       40 
     | 
    
         
            -
            };
         
     | 
| 
       41 
     | 
    
         
            -
            export {
         
     | 
| 
       42 
     | 
    
         
            -
              exporter
         
     | 
| 
       43 
     | 
    
         
            -
            };
         
     | 
| 
      
 1 
     | 
    
         
            +
            import{flattie as e}from"flattie";var t=t=>(a,n)=>{let r=[];for(let t of a){let{kind:a,error:i,...s}=t.context;i&&(s.error=!("message"in i)||{name:i.name,message:i.message,stack:i.stack}),r.push({id:t.id.parent_id,traceId:t.id.trace_id,parentId:t.parent?t.parent.parent_id:void 0,name:t.name,kind:"INTERNAL"===a?void 0:a,timestamp:1e3*t.start,duration:t.end?1e3*(t.end-t.start):void 0,localEndpoint:n.localEndpoint||{serviceName:s["service.name"]},tags:e({...n,...s},".",!0),annotations:t.events.map((e=>({value:`${e.name} :: ${JSON.stringify(e.attributes)}`,timestamp:1e3*e.timestamp})))})}return t(r)};export{t as exporter};
         
     | 
    
        package/index.js
    CHANGED
    
    | 
         @@ -1,76 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
       2 
     | 
    
         
            -
            const { name:rian_name, version:rian_version } = require('rian/package.json');
         
     | 
| 
       3 
     | 
    
         
            -
            const tctx = require('tctx');
         
     | 
| 
       4 
     | 
    
         
            -
            const { measureFn } = require('rian/utils');
         
     | 
| 
       5 
     | 
    
         
            -
            var PROMISES = /* @__PURE__ */ new WeakMap();
         
     | 
| 
       6 
     | 
    
         
            -
            var ADD_PROMISE = (scope, promise) => {
         
     | 
| 
       7 
     | 
    
         
            -
              if (PROMISES.has(scope))
         
     | 
| 
       8 
     | 
    
         
            -
                PROMISES.get(scope).push(promise);
         
     | 
| 
       9 
     | 
    
         
            -
              else
         
     | 
| 
       10 
     | 
    
         
            -
                PROMISES.set(scope, [promise]);
         
     | 
| 
       11 
     | 
    
         
            -
            };
         
     | 
| 
       12 
     | 
    
         
            -
            var defaultSampler = (_name, parentId) => {
         
     | 
| 
       13 
     | 
    
         
            -
              if (!parentId)
         
     | 
| 
       14 
     | 
    
         
            -
                return true;
         
     | 
| 
       15 
     | 
    
         
            -
              return tctx.is_sampled(parentId);
         
     | 
| 
       16 
     | 
    
         
            -
            };
         
     | 
| 
       17 
     | 
    
         
            -
            var sdk_object = {
         
     | 
| 
       18 
     | 
    
         
            -
              "telemetry.sdk.name": rian_name,
         
     | 
| 
       19 
     | 
    
         
            -
              "telemetry.sdk.version": rian_version
         
     | 
| 
       20 
     | 
    
         
            -
            };
         
     | 
| 
       21 
     | 
    
         
            -
            var create = (name, options) => {
         
     | 
| 
       22 
     | 
    
         
            -
              const spans = /* @__PURE__ */ new Set();
         
     | 
| 
       23 
     | 
    
         
            -
              const sampler = options.sampler || defaultSampler;
         
     | 
| 
       24 
     | 
    
         
            -
              const sampler_callable = typeof sampler !== "boolean";
         
     | 
| 
       25 
     | 
    
         
            -
              const span = (name2, parent) => {
         
     | 
| 
       26 
     | 
    
         
            -
                const should_sample = sampler_callable ? sampler(name2, parent, options.context) : sampler;
         
     | 
| 
       27 
     | 
    
         
            -
                const id = parent ? parent.child(should_sample) : tctx.make(should_sample);
         
     | 
| 
       28 
     | 
    
         
            -
                const span_obj = {
         
     | 
| 
       29 
     | 
    
         
            -
                  id,
         
     | 
| 
       30 
     | 
    
         
            -
                  parent,
         
     | 
| 
       31 
     | 
    
         
            -
                  start: Date.now(),
         
     | 
| 
       32 
     | 
    
         
            -
                  name: name2,
         
     | 
| 
       33 
     | 
    
         
            -
                  events: [],
         
     | 
| 
       34 
     | 
    
         
            -
                  context: {}
         
     | 
| 
       35 
     | 
    
         
            -
                };
         
     | 
| 
       36 
     | 
    
         
            -
                if (should_sample)
         
     | 
| 
       37 
     | 
    
         
            -
                  spans.add(span_obj);
         
     | 
| 
       38 
     | 
    
         
            -
                const $ = (cb) => measureFn($, cb);
         
     | 
| 
       39 
     | 
    
         
            -
                $.traceparent = id;
         
     | 
| 
       40 
     | 
    
         
            -
                $.fork = (name3) => span(name3, id);
         
     | 
| 
       41 
     | 
    
         
            -
                $.set_context = (ctx) => {
         
     | 
| 
       42 
     | 
    
         
            -
                  if (typeof ctx === "function")
         
     | 
| 
       43 
     | 
    
         
            -
                    return void (span_obj.context = ctx(span_obj.context));
         
     | 
| 
       44 
     | 
    
         
            -
                  Object.assign(span_obj.context, ctx);
         
     | 
| 
       45 
     | 
    
         
            -
                };
         
     | 
| 
       46 
     | 
    
         
            -
                $.add_event = (name3, attributes) => {
         
     | 
| 
       47 
     | 
    
         
            -
                  span_obj.events.push({
         
     | 
| 
       48 
     | 
    
         
            -
                    name: name3,
         
     | 
| 
       49 
     | 
    
         
            -
                    timestamp: Date.now(),
         
     | 
| 
       50 
     | 
    
         
            -
                    attributes: attributes || {}
         
     | 
| 
       51 
     | 
    
         
            -
                  });
         
     | 
| 
       52 
     | 
    
         
            -
                };
         
     | 
| 
       53 
     | 
    
         
            -
                $.end = () => {
         
     | 
| 
       54 
     | 
    
         
            -
                  if (span_obj.end == null)
         
     | 
| 
       55 
     | 
    
         
            -
                    span_obj.end = Date.now();
         
     | 
| 
       56 
     | 
    
         
            -
                };
         
     | 
| 
       57 
     | 
    
         
            -
                return $;
         
     | 
| 
       58 
     | 
    
         
            -
              };
         
     | 
| 
       59 
     | 
    
         
            -
              const root = span(name, typeof options.traceparent === "string" ? tctx.parse(options.traceparent) : void 0);
         
     | 
| 
       60 
     | 
    
         
            -
              const endRoot = root.end.bind(root);
         
     | 
| 
       61 
     | 
    
         
            -
              root.end = async () => {
         
     | 
| 
       62 
     | 
    
         
            -
                endRoot();
         
     | 
| 
       63 
     | 
    
         
            -
                if (PROMISES.has(root))
         
     | 
| 
       64 
     | 
    
         
            -
                  await Promise.all(PROMISES.get(root));
         
     | 
| 
       65 
     | 
    
         
            -
                return options.exporter(spans, {
         
     | 
| 
       66 
     | 
    
         
            -
                  ...options.context || {},
         
     | 
| 
       67 
     | 
    
         
            -
                  ...sdk_object
         
     | 
| 
       68 
     | 
    
         
            -
                });
         
     | 
| 
       69 
     | 
    
         
            -
              };
         
     | 
| 
       70 
     | 
    
         
            -
              return root;
         
     | 
| 
       71 
     | 
    
         
            -
            };
         
     | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
       73 
     | 
    
         
            -
             
     | 
| 
       74 
     | 
    
         
            -
            exports.ADD_PROMISE = ADD_PROMISE;
         
     | 
| 
       75 
     | 
    
         
            -
            exports.PROMISES = PROMISES;
         
     | 
| 
       76 
     | 
    
         
            -
            exports.create = create;
         
     | 
| 
      
 1 
     | 
    
         
            +
            const e = require('tctx');const { measureFn:t } = require('rian/utils');var n=new WeakMap,a=(e,t)=>{n.has(e)?n.get(e).push(t):n.set(e,[t])},r=(t,n)=>!n||e.is_sampled(n),o={"telemetry.sdk.name":"rian","telemetry.sdk.version":"0.2.2"},s=(a,s)=>{let i=new Set,p=s.sampler||r,d="boolean"!=typeof p,c=(n,a)=>{let r=d?p(n,a,s.context):p,o=a?a.child(r):e.make(r),m={id:o,parent:a,start:Date.now(),name:n,events:[],context:{}};r&&i.add(m);let l=e=>t(l,e);return l.traceparent=o,l.fork=e=>c(e,o),l.set_context=e=>{"function"!=typeof e?Object.assign(m.context,e):m.context=e(m.context)},l.add_event=(e,t)=>{m.events.push({name:e,timestamp:Date.now(),attributes:t||{}})},l.end=()=>{null==m.end&&(m.end=Date.now())},l},m=c(a,"string"==typeof s.traceparent?e.parse(s.traceparent):void 0),l=m.end.bind(m);return m.end=async()=>(l(),n.has(m)&&await Promise.all(n.get(m)),s.exporter(i,{...s.context||{},...o})),m};exports.ADD_PROMISE=a;exports.PROMISES=n;exports.create=s;
         
     | 
    
        package/index.mjs
    CHANGED
    
    | 
         @@ -1,76 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
       2 
     | 
    
         
            -
            import { name as rian_name, version as rian_version } from "rian/package.json";
         
     | 
| 
       3 
     | 
    
         
            -
            import * as tctx from "tctx";
         
     | 
| 
       4 
     | 
    
         
            -
            import { measureFn } from "rian/utils";
         
     | 
| 
       5 
     | 
    
         
            -
            var PROMISES = /* @__PURE__ */ new WeakMap();
         
     | 
| 
       6 
     | 
    
         
            -
            var ADD_PROMISE = (scope, promise) => {
         
     | 
| 
       7 
     | 
    
         
            -
              if (PROMISES.has(scope))
         
     | 
| 
       8 
     | 
    
         
            -
                PROMISES.get(scope).push(promise);
         
     | 
| 
       9 
     | 
    
         
            -
              else
         
     | 
| 
       10 
     | 
    
         
            -
                PROMISES.set(scope, [promise]);
         
     | 
| 
       11 
     | 
    
         
            -
            };
         
     | 
| 
       12 
     | 
    
         
            -
            var defaultSampler = (_name, parentId) => {
         
     | 
| 
       13 
     | 
    
         
            -
              if (!parentId)
         
     | 
| 
       14 
     | 
    
         
            -
                return true;
         
     | 
| 
       15 
     | 
    
         
            -
              return tctx.is_sampled(parentId);
         
     | 
| 
       16 
     | 
    
         
            -
            };
         
     | 
| 
       17 
     | 
    
         
            -
            var sdk_object = {
         
     | 
| 
       18 
     | 
    
         
            -
              "telemetry.sdk.name": rian_name,
         
     | 
| 
       19 
     | 
    
         
            -
              "telemetry.sdk.version": rian_version
         
     | 
| 
       20 
     | 
    
         
            -
            };
         
     | 
| 
       21 
     | 
    
         
            -
            var create = (name, options) => {
         
     | 
| 
       22 
     | 
    
         
            -
              const spans = /* @__PURE__ */ new Set();
         
     | 
| 
       23 
     | 
    
         
            -
              const sampler = options.sampler || defaultSampler;
         
     | 
| 
       24 
     | 
    
         
            -
              const sampler_callable = typeof sampler !== "boolean";
         
     | 
| 
       25 
     | 
    
         
            -
              const span = (name2, parent) => {
         
     | 
| 
       26 
     | 
    
         
            -
                const should_sample = sampler_callable ? sampler(name2, parent, options.context) : sampler;
         
     | 
| 
       27 
     | 
    
         
            -
                const id = parent ? parent.child(should_sample) : tctx.make(should_sample);
         
     | 
| 
       28 
     | 
    
         
            -
                const span_obj = {
         
     | 
| 
       29 
     | 
    
         
            -
                  id,
         
     | 
| 
       30 
     | 
    
         
            -
                  parent,
         
     | 
| 
       31 
     | 
    
         
            -
                  start: Date.now(),
         
     | 
| 
       32 
     | 
    
         
            -
                  name: name2,
         
     | 
| 
       33 
     | 
    
         
            -
                  events: [],
         
     | 
| 
       34 
     | 
    
         
            -
                  context: {}
         
     | 
| 
       35 
     | 
    
         
            -
                };
         
     | 
| 
       36 
     | 
    
         
            -
                if (should_sample)
         
     | 
| 
       37 
     | 
    
         
            -
                  spans.add(span_obj);
         
     | 
| 
       38 
     | 
    
         
            -
                const $ = (cb) => measureFn($, cb);
         
     | 
| 
       39 
     | 
    
         
            -
                $.traceparent = id;
         
     | 
| 
       40 
     | 
    
         
            -
                $.fork = (name3) => span(name3, id);
         
     | 
| 
       41 
     | 
    
         
            -
                $.set_context = (ctx) => {
         
     | 
| 
       42 
     | 
    
         
            -
                  if (typeof ctx === "function")
         
     | 
| 
       43 
     | 
    
         
            -
                    return void (span_obj.context = ctx(span_obj.context));
         
     | 
| 
       44 
     | 
    
         
            -
                  Object.assign(span_obj.context, ctx);
         
     | 
| 
       45 
     | 
    
         
            -
                };
         
     | 
| 
       46 
     | 
    
         
            -
                $.add_event = (name3, attributes) => {
         
     | 
| 
       47 
     | 
    
         
            -
                  span_obj.events.push({
         
     | 
| 
       48 
     | 
    
         
            -
                    name: name3,
         
     | 
| 
       49 
     | 
    
         
            -
                    timestamp: Date.now(),
         
     | 
| 
       50 
     | 
    
         
            -
                    attributes: attributes || {}
         
     | 
| 
       51 
     | 
    
         
            -
                  });
         
     | 
| 
       52 
     | 
    
         
            -
                };
         
     | 
| 
       53 
     | 
    
         
            -
                $.end = () => {
         
     | 
| 
       54 
     | 
    
         
            -
                  if (span_obj.end == null)
         
     | 
| 
       55 
     | 
    
         
            -
                    span_obj.end = Date.now();
         
     | 
| 
       56 
     | 
    
         
            -
                };
         
     | 
| 
       57 
     | 
    
         
            -
                return $;
         
     | 
| 
       58 
     | 
    
         
            -
              };
         
     | 
| 
       59 
     | 
    
         
            -
              const root = span(name, typeof options.traceparent === "string" ? tctx.parse(options.traceparent) : void 0);
         
     | 
| 
       60 
     | 
    
         
            -
              const endRoot = root.end.bind(root);
         
     | 
| 
       61 
     | 
    
         
            -
              root.end = async () => {
         
     | 
| 
       62 
     | 
    
         
            -
                endRoot();
         
     | 
| 
       63 
     | 
    
         
            -
                if (PROMISES.has(root))
         
     | 
| 
       64 
     | 
    
         
            -
                  await Promise.all(PROMISES.get(root));
         
     | 
| 
       65 
     | 
    
         
            -
                return options.exporter(spans, {
         
     | 
| 
       66 
     | 
    
         
            -
                  ...options.context || {},
         
     | 
| 
       67 
     | 
    
         
            -
                  ...sdk_object
         
     | 
| 
       68 
     | 
    
         
            -
                });
         
     | 
| 
       69 
     | 
    
         
            -
              };
         
     | 
| 
       70 
     | 
    
         
            -
              return root;
         
     | 
| 
       71 
     | 
    
         
            -
            };
         
     | 
| 
       72 
     | 
    
         
            -
            export {
         
     | 
| 
       73 
     | 
    
         
            -
              ADD_PROMISE,
         
     | 
| 
       74 
     | 
    
         
            -
              PROMISES,
         
     | 
| 
       75 
     | 
    
         
            -
              create
         
     | 
| 
       76 
     | 
    
         
            -
            };
         
     | 
| 
      
 1 
     | 
    
         
            +
            import*as e from"tctx";import{measureFn as t}from"rian/utils";var n=new WeakMap,a=(e,t)=>{n.has(e)?n.get(e).push(t):n.set(e,[t])},r=(t,n)=>!n||e.is_sampled(n),o={"telemetry.sdk.name":"rian","telemetry.sdk.version":"0.2.2"},s=(a,s)=>{let i=new Set,p=s.sampler||r,d="boolean"!=typeof p,c=(n,a)=>{let r=d?p(n,a,s.context):p,o=a?a.child(r):e.make(r),m={id:o,parent:a,start:Date.now(),name:n,events:[],context:{}};r&&i.add(m);let l=e=>t(l,e);return l.traceparent=o,l.fork=e=>c(e,o),l.set_context=e=>{"function"!=typeof e?Object.assign(m.context,e):m.context=e(m.context)},l.add_event=(e,t)=>{m.events.push({name:e,timestamp:Date.now(),attributes:t||{}})},l.end=()=>{null==m.end&&(m.end=Date.now())},l},m=c(a,"string"==typeof s.traceparent?e.parse(s.traceparent):void 0),l=m.end.bind(m);return m.end=async()=>(l(),n.has(m)&&await Promise.all(n.get(m)),s.exporter(i,{...s.context||{},...o})),m};export{a as ADD_PROMISE,n as PROMISES,s as create};
         
     | 
    
        package/package.json
    CHANGED
    
    | 
         @@ -1,6 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            {
         
     | 
| 
       2 
2 
     | 
    
         
             
            	"name": "rian",
         
     | 
| 
       3 
     | 
    
         
            -
            	"version": "0.2. 
     | 
| 
      
 3 
     | 
    
         
            +
            	"version": "0.2.2",
         
     | 
| 
       4 
4 
     | 
    
         
             
            	"description": "Effective tracing for the edge and origins",
         
     | 
| 
       5 
5 
     | 
    
         
             
            	"keywords": [
         
     | 
| 
       6 
6 
     | 
    
         
             
            		"opentelemetry",
         
     | 
| 
         @@ -58,7 +58,7 @@ 
     | 
|
| 
       58 
58 
     | 
    
         
             
            		"utils/*"
         
     | 
| 
       59 
59 
     | 
    
         
             
            	],
         
     | 
| 
       60 
60 
     | 
    
         
             
            	"scripts": {
         
     | 
| 
       61 
     | 
    
         
            -
            		"build": "bundt"
         
     | 
| 
      
 61 
     | 
    
         
            +
            		"build": "bundt --minify"
         
     | 
| 
       62 
62 
     | 
    
         
             
            	},
         
     | 
| 
       63 
63 
     | 
    
         
             
            	"dependencies": {
         
     | 
| 
       64 
64 
     | 
    
         
             
            		"flattie": "^1.1.0",
         
     | 
    
        package/utils/index.js
    CHANGED
    
    | 
         @@ -1,30 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
       2 
     | 
    
         
            -
            const { ADD_PROMISE, PROMISES } = require('rian');
         
     | 
| 
       3 
     | 
    
         
            -
            var measureFn = (scope, fn, ...args) => {
         
     | 
| 
       4 
     | 
    
         
            -
              try {
         
     | 
| 
       5 
     | 
    
         
            -
                var r = fn(...args, scope), is_promise = r instanceof Promise;
         
     | 
| 
       6 
     | 
    
         
            -
                if (is_promise && !PROMISES.has(scope))
         
     | 
| 
       7 
     | 
    
         
            -
                  ADD_PROMISE(scope, r.catch((e) => void scope.set_context({
         
     | 
| 
       8 
     | 
    
         
            -
                    error: e
         
     | 
| 
       9 
     | 
    
         
            -
                  })).finally(() => scope.end()));
         
     | 
| 
       10 
     | 
    
         
            -
                return r;
         
     | 
| 
       11 
     | 
    
         
            -
              } catch (e) {
         
     | 
| 
       12 
     | 
    
         
            -
                if (e instanceof Error)
         
     | 
| 
       13 
     | 
    
         
            -
                  scope.set_context({
         
     | 
| 
       14 
     | 
    
         
            -
                    error: e
         
     | 
| 
       15 
     | 
    
         
            -
                  });
         
     | 
| 
       16 
     | 
    
         
            -
                throw e;
         
     | 
| 
       17 
     | 
    
         
            -
              } finally {
         
     | 
| 
       18 
     | 
    
         
            -
                if (is_promise !== true)
         
     | 
| 
       19 
     | 
    
         
            -
                  scope.end();
         
     | 
| 
       20 
     | 
    
         
            -
              }
         
     | 
| 
       21 
     | 
    
         
            -
            };
         
     | 
| 
       22 
     | 
    
         
            -
            var measure = (scope, name, fn, ...args) => measureFn(scope.fork(name), fn, ...args);
         
     | 
| 
       23 
     | 
    
         
            -
            var wrap = (scope, name, fn) => function() {
         
     | 
| 
       24 
     | 
    
         
            -
              return measureFn(scope.fork(name), fn, ...arguments);
         
     | 
| 
       25 
     | 
    
         
            -
            };
         
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
            exports.measure = measure;
         
     | 
| 
       29 
     | 
    
         
            -
            exports.measureFn = measureFn;
         
     | 
| 
       30 
     | 
    
         
            -
            exports.wrap = wrap;
         
     | 
| 
      
 1 
     | 
    
         
            +
            const { ADD_PROMISE:r, PROMISES:t } = require('rian');var n=(n,o,...e)=>{try{var a=o(...e,n),c=a instanceof Promise;return c&&!t.has(n)&&r(n,a.catch((r=>{n.set_context({error:r})})).finally((()=>n.end()))),a}catch(r){throw r instanceof Error&&n.set_context({error:r}),r}finally{!0!==c&&n.end()}},o=(r,t,o,...e)=>n(r.fork(t),o,...e),e=(r,t,o)=>function(){return n(r.fork(t),o,...arguments)};exports.measure=o;exports.measureFn=n;exports.wrap=e;
         
     | 
    
        package/utils/index.mjs
    CHANGED
    
    | 
         @@ -1,30 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
       2 
     | 
    
         
            -
            import { ADD_PROMISE, PROMISES } from "rian";
         
     | 
| 
       3 
     | 
    
         
            -
            var measureFn = (scope, fn, ...args) => {
         
     | 
| 
       4 
     | 
    
         
            -
              try {
         
     | 
| 
       5 
     | 
    
         
            -
                var r = fn(...args, scope), is_promise = r instanceof Promise;
         
     | 
| 
       6 
     | 
    
         
            -
                if (is_promise && !PROMISES.has(scope))
         
     | 
| 
       7 
     | 
    
         
            -
                  ADD_PROMISE(scope, r.catch((e) => void scope.set_context({
         
     | 
| 
       8 
     | 
    
         
            -
                    error: e
         
     | 
| 
       9 
     | 
    
         
            -
                  })).finally(() => scope.end()));
         
     | 
| 
       10 
     | 
    
         
            -
                return r;
         
     | 
| 
       11 
     | 
    
         
            -
              } catch (e) {
         
     | 
| 
       12 
     | 
    
         
            -
                if (e instanceof Error)
         
     | 
| 
       13 
     | 
    
         
            -
                  scope.set_context({
         
     | 
| 
       14 
     | 
    
         
            -
                    error: e
         
     | 
| 
       15 
     | 
    
         
            -
                  });
         
     | 
| 
       16 
     | 
    
         
            -
                throw e;
         
     | 
| 
       17 
     | 
    
         
            -
              } finally {
         
     | 
| 
       18 
     | 
    
         
            -
                if (is_promise !== true)
         
     | 
| 
       19 
     | 
    
         
            -
                  scope.end();
         
     | 
| 
       20 
     | 
    
         
            -
              }
         
     | 
| 
       21 
     | 
    
         
            -
            };
         
     | 
| 
       22 
     | 
    
         
            -
            var measure = (scope, name, fn, ...args) => measureFn(scope.fork(name), fn, ...args);
         
     | 
| 
       23 
     | 
    
         
            -
            var wrap = (scope, name, fn) => function() {
         
     | 
| 
       24 
     | 
    
         
            -
              return measureFn(scope.fork(name), fn, ...arguments);
         
     | 
| 
       25 
     | 
    
         
            -
            };
         
     | 
| 
       26 
     | 
    
         
            -
            export {
         
     | 
| 
       27 
     | 
    
         
            -
              measure,
         
     | 
| 
       28 
     | 
    
         
            -
              measureFn,
         
     | 
| 
       29 
     | 
    
         
            -
              wrap
         
     | 
| 
       30 
     | 
    
         
            -
            };
         
     | 
| 
      
 1 
     | 
    
         
            +
            import{ADD_PROMISE as r,PROMISES as t}from"rian";var n=(n,o,...e)=>{try{var a=o(...e,n),c=a instanceof Promise;return c&&!t.has(n)&&r(n,a.catch((r=>{n.set_context({error:r})})).finally((()=>n.end()))),a}catch(r){throw r instanceof Error&&n.set_context({error:r}),r}finally{!0!==c&&n.end()}},o=(r,t,o,...e)=>n(r.fork(t),o,...e),e=(r,t,o)=>function(){return n(r.fork(t),o,...arguments)};export{o as measure,n as measureFn,e as wrap};
         
     |