@arms/rum-core 0.0.7 → 0.0.8

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.
@@ -4,7 +4,6 @@ exports.__esModule = true;
4
4
  exports["default"] = void 0;
5
5
  var _rumEvent = require("../types/rum-event");
6
6
  var _exception = require("../utils/exception");
7
- // import { IReporter } from '../types/reporter';
8
7
  var Reporter = exports["default"] = /*#__PURE__*/function () {
9
8
  function Reporter() {
10
9
  this.name = 'reporter';
@@ -2,7 +2,6 @@ import { ICollector } from './collector';
2
2
  import { IProcessor } from './processor';
3
3
  import { IReporter } from './reporter';
4
4
  import { RumEvent, RumEventBundle, IViewData } from './rum-event';
5
- import { ITracingOption } from '../utils/trace';
6
5
  export declare enum EventType {
7
6
  /**
8
7
  * 收集数据
@@ -92,9 +91,5 @@ export interface IConfiguration {
92
91
  * 各个 collector config
93
92
  */
94
93
  collectors?: any;
95
- /**
96
- * tracing 配置 'tracecontext' | 'b3' | 'b3multi' | 'jaeger';
97
- */
98
- tracing?: boolean | ITracingOption;
99
94
  [key: string]: any;
100
95
  }
@@ -4,17 +4,12 @@ export type TraceOption = {
4
4
  match: MatchOption;
5
5
  propagatorTypes: PropagatorType[];
6
6
  };
7
- export type Baggage = {
8
- appType?: string;
9
- pid?: string;
10
- uid?: string;
11
- sid?: string;
12
- };
13
7
  export declare function isTraceOption(option: any): option is TraceOption;
14
8
  export interface ITracingOption {
15
9
  enable?: boolean;
16
10
  sample?: number | undefined;
17
11
  allowedUrls?: Array<MatchOption | TraceOption> | undefined;
12
+ tracestate?: boolean;
18
13
  baggage?: boolean;
19
14
  }
20
15
  export declare function generateTraceId(): any;
@@ -22,5 +17,5 @@ export declare function generateSpanId(): any;
22
17
  export interface ITracingHeaders {
23
18
  [key: string]: string;
24
19
  }
25
- export declare function makeTracingHeaders(traceId: string, spanId: string, sampled: boolean, propagatorTypes: PropagatorType[], baggage?: Baggage): ITracingHeaders;
20
+ export declare function makeTracingHeaders(traceId: string, spanId: string, sampled: boolean, propagatorTypes: PropagatorType[], tracestate?: string, baggage?: string): ITracingHeaders;
26
21
  export declare function parseTracingOptions(tracingOption: boolean | ITracingOption): ITracingOption;
@@ -12,7 +12,7 @@ var SPAN_ID_BYTES = 8;
12
12
  var TRACE_ID_BYTES = 16;
13
13
  var SHARED_CHAR_CODES_ARRAY = Array(32);
14
14
  function isTraceOption(option) {
15
- return option && (0, _match.isMatchOption)(option.match) && Array.isArray(option.propagatorTypes);
15
+ return option && (0, _match.isMatchOption)(option.match) && (0, _is.isArray)(option.propagatorTypes);
16
16
  }
17
17
  function generateId(bytes) {
18
18
  for (var i = 0; i < bytes * 2; i++) {
@@ -38,7 +38,7 @@ function generateTraceId() {
38
38
  function generateSpanId() {
39
39
  return generateId(SPAN_ID_BYTES);
40
40
  }
41
- function makeTracingHeaders(traceId, spanId, sampled, propagatorTypes, baggage) {
41
+ function makeTracingHeaders(traceId, spanId, sampled, propagatorTypes, tracestate, baggage) {
42
42
  var tracingHeaders = {};
43
43
  var sample = sampled ? '1' : '0';
44
44
  propagatorTypes.forEach(function (propagatorType) {
@@ -58,15 +58,14 @@ function makeTracingHeaders(traceId, spanId, sampled, propagatorTypes, baggage)
58
58
  case 'tracecontext': // https://www.w3.org/TR/trace-context/
59
59
  default:
60
60
  tracingHeaders['traceparent'] = "00-" + traceId + "-" + spanId + "-0" + sample;
61
+ if (tracestate) {
62
+ tracingHeaders['tracestate'] = tracestate;
63
+ }
61
64
  break;
62
65
  }
63
66
  });
64
67
  if (baggage) {
65
- var bagValList = ['rum=v2'];
66
- Object.keys(baggage).forEach(function (key) {
67
- bagValList.push(key + "=" + baggage[key]);
68
- });
69
- bagValList.length && (tracingHeaders['baggage'] = bagValList.join(','));
68
+ tracingHeaders['baggage'] = baggage;
70
69
  }
71
70
  return tracingHeaders;
72
71
  }
@@ -76,7 +75,8 @@ function parseTracingOptions(tracingOption) {
76
75
  enable: !!tracingOption,
77
76
  sample: 100,
78
77
  allowedUrls: [],
79
- baggage: true
78
+ tracestate: true,
79
+ baggage: false
80
80
  };
81
81
  }
82
82
  var _tracingOption$enable = tracingOption.enable,
@@ -85,8 +85,10 @@ function parseTracingOptions(tracingOption) {
85
85
  sample = _tracingOption$sample === void 0 ? 100 : _tracingOption$sample,
86
86
  _tracingOption$allowe = tracingOption.allowedUrls,
87
87
  allowedUrls = _tracingOption$allowe === void 0 ? [] : _tracingOption$allowe,
88
+ _tracingOption$traces = tracingOption.tracestate,
89
+ tracestate = _tracingOption$traces === void 0 ? true : _tracingOption$traces,
88
90
  _tracingOption$baggag = tracingOption.baggage,
89
- baggage = _tracingOption$baggag === void 0 ? true : _tracingOption$baggag;
91
+ baggage = _tracingOption$baggag === void 0 ? false : _tracingOption$baggag;
90
92
  var traceOptions = [];
91
93
  if ((0, _is.isArray)(allowedUrls) && allowedUrls.length) {
92
94
  allowedUrls.forEach(function (item) {
@@ -104,6 +106,7 @@ function parseTracingOptions(tracingOption) {
104
106
  enable: (0, _is.isBoolean)(enable) ? enable : true,
105
107
  sample: (0, _is.isNumber)(sample) ? sample : 100,
106
108
  allowedUrls: traceOptions,
109
+ tracestate: tracestate,
107
110
  baggage: baggage
108
111
  };
109
112
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arms/rum-core",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "description": "arms rum javascript sdk core",
5
5
  "author": "guangli.fj <guangli.fj@alibaba-inc.com>",
6
6
  "license": "ISC",