| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145 | 1×
1×
1×
1×
16×
7×
9×
9×
9×
9×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
2×
1×
1×
1×
1×
1×
1×
1×
1×
5×
3×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
6×
1×
1×
1×
1×
1×
1×
1×
7×
1×
1×
1×
1×
1×
1×
1×
1×
4×
2×
1×
1×
6×
6×
6×
6×
6×
6×
6×
6×
8×
8×
8×
8×
8×
2×
6×
6×
6×
5×
5×
5×
5×
5×
5×
5×
2×
3×
3×
3×
3×
1×
2×
2×
1×
1×
1×
1×
1×
9×
1×
1×
1×
1×
2×
1×
6×
1×
1×
1×
3×
3×
3×
3×
3×
1×
1×
1×
1×
1×
1×
6×
6×
1×
1×
1×
1×
1×
3×
3×
1×
1×
1×
3×
3×
1×
1×
1×
1×
1×
1×
2×
1×
1×
1×
1×
2×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
| require("source-map-support").install();
module.exports =
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
module.exports = __webpack_require__(1);
/***/ },
/* 1 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
var _singleton = __webpack_require__(2);
var _singleton2 = _interopRequireDefault(_singleton);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
module.exports = new _singleton2.default();
/***/ },
/* 2 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; Eif ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { Eif (protoProps) defineProperties(Constructor.prototype, protoProps); Iif (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _tracer = __webpack_require__(3);
var _tracer2 = _interopRequireDefault(_tracer);
var _constants = __webpack_require__(6);
var Constants = _interopRequireWildcard(_constants);
var _binary_carrier = __webpack_require__(8);
var _binary_carrier2 = _interopRequireDefault(_binary_carrier);
var _reference = __webpack_require__(7);
var _reference2 = _interopRequireDefault(_reference);
function _interopRequireWildcard(obj) { Iif (obj && obj.__esModule) { return obj; } else { var newObj = {}; Eif (obj != null) { for (var key in obj) { Eif (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { Iif (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { Iif (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { Iif (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); Eif (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
/**
* The Singleton object is the default export of the package and extends the
* standard Tracer object so that the default
* exported object of the package can be conveniently be used both as the
* default tracer and an interface to the library.
*/
var Singleton = function (_Tracer) {
_inherits(Singleton, _Tracer);
_createClass(Singleton, [{
key: 'initGlobalTracer',
// ---------------------------------------------------------------------- //
// OpenTracing API methods
// ---------------------------------------------------------------------- //
/**
* Set the global Tracer's underlying implementation.
*
* The behavior is undefined if this function is called more than once.
*
* @param {TracerImp} tracerImp - the Tracer implementation object
*/
value: function initGlobalTracer(tracerImp) {
this._imp = tracerImp;
// Provide the implementation with a handle to the interface. This can
// also be used a post-initialization signal.
Eif (tracerImp) {
tracerImp.setInterface(this);
}
}
/**
* Create a new Tracer object with the given underlying implementation.
*
* @return {Tracer} a new Tracer object
*/
}, {
key: 'initNewTracer',
value: function initNewTracer(tracerImp) {
var tracer = new _tracer2.default(tracerImp);
Iif (tracerImp) {
tracerImp.setInterface(this);
}
return tracer;
}
// ---------------------------------------------------------------------- //
// Private and non-standard methods
// ---------------------------------------------------------------------- //
/* For internal use only:
*
* Creates the Singleton with no underlying implementation (i.e. defaults
* to no-op behavior for all functions).
*
* The OpenTracing package-level object acts both at the singleton and the
* package interface itself, so this Singleton is both a the Tracer and
* also includes all the global library symbols.
*
* Note: this should never be called directly by consumers of the library.
*/
}]);
function Singleton() {
_classCallCheck(this, Singleton);
// Merge the constants into the singleton object so they are accessible at the
// package level.
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Singleton).call(this));
for (var key in Constants) {
// eslint-disable-line no-restricted-syntax
_this[key] = Constants[key];
}
_this.Reference = _reference2.default;
// Carrier objects to be exposed at the package level
_this.BinaryCarrier = _binary_carrier2.default;
return _this;
}
return Singleton;
}(_tracer2.default);
exports.default = Singleton;
module.exports = exports['default'];
/***/ },
/* 3 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; Eif ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { Eif (protoProps) defineProperties(Constructor.prototype, protoProps); Iif (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _span = __webpack_require__(4);
var _span2 = _interopRequireDefault(_span);
var _span_context = __webpack_require__(5);
var _span_context2 = _interopRequireDefault(_span_context);
var _constants = __webpack_require__(6);
var _constants2 = _interopRequireDefault(_constants);
var _reference = __webpack_require__(7);
var _reference2 = _interopRequireDefault(_reference);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { Iif (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* Tracer is the entry-point between the instrumentation API and the tracing
* implementation.
*
* The default object acts as a no-op implementation.
*/
var Tracer = function () {
_createClass(Tracer, [{
key: 'startSpan',
// ---------------------------------------------------------------------- //
// OpenTracing API methods
// ---------------------------------------------------------------------- //
/**
* Starts and returns a new Span representing a logical unit of work.
*
* For example:
*
* // Start a new (parentless) root Span:
* var parent = Tracer.startSpan('DoWork');
*
* // Start a new (child) Span:
* var child = Tracer.startSpan('Subroutine', {
* reference: Tracer.childOf(parent.context()),
* });
*
* @param {string|object} nameOrFields - if the given argument is a
* string, it is the name of the operation and the second `fields`
* argument is optional. If it is an object, it is treated as the
* fields argument and a second argument should not be provided.
* @param {object} [fields] - the fields to set on the newly created span.
* @param {string} [fields.operationName] - the name to use for the newly
* created span. Required if called with a single argument.
* @param {SpanContext} [fields.childOf] - a parent SpanContext (or Span,
* for convenience) that the newly-started span will be the child of
* (per REFERENCE_CHILD_OF). If specified, `fields.references` must
* be unspecified.
* @param {array} [fields.references] - an array of Reference instances,
* each pointing to a causal parent SpanContext. If specified,
* `fields.childOf` must be unspecified.
* @param {object} [fields.tags] - set of key-value pairs which will be set
* as tags on the newly created Span. Ownership of the object is
* passed to the created span for efficiency reasons (the caller
* should not modify this object after calling startSpan).
* @param {number} [fields.startTime] - a manually specified start time for
* the created Span object. The time should be specified in
* milliseconds as Unix timestamp. Decimal value are supported
* to represent time values with sub-millisecond accuracy.
* @return {Span} - a new Span object.
*/
value: function startSpan(nameOrFields, fields) {
Eif (true) {
Iif (arguments.length > 2) {
throw new Error('Invalid number of arguments.');
}
Iif (typeof nameOrFields !== 'string' && typeof nameOrFields !== 'object') {
throw new Error('argument expected to be a string or object');
}
Iif (typeof nameOrFields === 'string' && nameOrFields.length === 0) {
throw new Error('operation name cannot be length zero');
}
Iif (typeof nameOrFields === 'object') {
if (arguments.length !== 1) {
throw new Error('Unexpected number of arguments');
}
if (nameOrFields === null) {
throw new Error('fields should not be null');
}
if (!nameOrFields.operationName) {
throw new Error('operationName is a required parameter');
}
}
}
var spanImp = null;
Iif (this._imp) {
// Normalize the argument so the implementation is always provided
// an associative array of fields.
if (arguments.length === 1) {
if (typeof nameOrFields === 'string') {
fields = {
operationName: nameOrFields
};
} else {
fields = nameOrFields;
}
} else {
fields.operationName = nameOrFields;
}
if (true) {
if (fields.childOf && fields.references) {
throw new Error('At most one of `childOf` and ' + '`references` may be specified');
}
if (fields.childOf && !(fields.childOf instanceof _span2.default || fields.childOf instanceof _span_context2.default)) {
throw new Error('childOf must be a Span or SpanContext instance');
}
}
// Convert fields.childOf to fields.references as needed.
if (fields.childOf) {
// Convert from a Span or a SpanContext into a Reference.
var childOf = this.childOf(fields.childOf);
if (fields.references) {
fields.references.push(childOf);
} else {
fields.references = [childOf];
}
delete fields.childOf;
}
spanImp = this._imp.startSpan(fields);
}
return new _span2.default(spanImp);
}
/**
* Return a new REFERENCE_CHILD_OF reference.
*
* @param {SpanContext} spanContext - the parent SpanContext instance to
* reference.
* @return a REFERENCE_CHILD_OF reference pointing to `spanContext`
*/
}, {
key: 'childOf',
value: function childOf(spanContext) {
return new _reference2.default(_constants2.default.REFERENCE_CHILD_OF, spanContext);
}
/**
* Return a new REFERENCE_FOLLOWS_FROM reference.
*
* @param {SpanContext} spanContext - the parent SpanContext instance to
* reference.
* @return a REFERENCE_FOLLOWS_FROM reference pointing to `spanContext`
*/
}, {
key: 'followsFrom',
value: function followsFrom(spanContext) {
return new _reference2.default(_constants2.default.REFERENCE_FOLLOWS_FROM, spanContext);
}
/**
* Injects the given SpanContext instance for cross-process propagation
* within `carrier`. The expected type of `carrier` depends on the value of
* `format.
*
* OpenTracing defines a common set of `format` values (see
* FORMAT_TEXT_MAP, FORMAT_HTTP_HEADERS, and FORMAT_BINARY), and each has
* an expected carrier type.
*
* Consider this pseudocode example:
*
* var clientSpan = ...;
* ...
* // Inject clientSpan into a text carrier.
* var headersCarrier = {};
* Tracer.inject(clientSpan.context(), Tracer.FORMAT_HTTP_HEADERS, headersCarrier);
* // Incorporate the textCarrier into the outbound HTTP request header
* // map.
* Object.assign(outboundHTTPReq.headers, headersCarrier);
* // ... send the httpReq
*
* @param {SpanContext} spanContext - the SpanContext to inject into the
* carrier object. As a convenience, a Span instance may be passed
* in instead (in which case its .context() is used for the
* inject()).
* @param {string} format - the format of the carrier.
* @param {any} carrier - see the documentation for the chosen `format`
* for a description of the carrier object.
*/
}, {
key: 'inject',
value: function inject(spanContext, format, carrier) {
Eif (true) {
Iif (arguments.length !== 3) {
throw new Error('Invalid number of arguments.');
}
Iif (!(spanContext instanceof _span_context2.default || spanContext instanceof _span2.default)) {
throw new Error('first argument must be a SpanContext or Span instance');
}
Iif (typeof format !== 'string') {
throw new Error('format expected to be a string. Found: ' + typeof format);
}
if (format === _constants2.default.FORMAT_TEXT_MAP && typeof carrier !== 'object') {
throw new Error('Unexpected carrier object for FORMAT_TEXT_MAP');
}
Iif (format === _constants2.default.FORMAT_HTTP_HEADERS && typeof carrier !== 'object') {
throw new Error('Unexpected carrier object for FORMAT_HTTP_HEADERS');
}
Iif (format === _constants2.default.FORMAT_BINARY && typeof carrier !== 'object') {
throw new Error('Unexpected carrier object for FORMAT_BINARY');
}
}
Iif (this._imp) {
// Allow the user to pass a Span instead of a SpanContext
if (spanContext instanceof _span2.default) {
spanContext = spanContext.context();
}
this._imp.inject(spanContext._imp, format, carrier);
}
}
/**
* Returns a SpanContext instance extracted from `carrier` in the given
* `format`.
*
* OpenTracing defines a common set of `format` values (see
* FORMAT_TEXT_MAP, FORMAT_HTTP_HEADERS, and FORMAT_BINARY), and each has
* an expected carrier type.
*
* Consider this pseudocode example:
*
* // Use the inbound HTTP request's headers as a text map carrier.
* var headersCarrier = inboundHTTPReq.headers;
* var wireCtx = Tracer.extract(Tracer.FORMAT_HTTP_HEADERS, headersCarrier);
* var serverSpan = Tracer.startSpan('...', { childOf : wireCtx });
*
* @param {string} format - the format of the carrier.
* @param {any} carrier - the type of the carrier object is determined by
* the format.
* @return {SpanContext}
* The extracted SpanContext, or null if no such SpanContext could
* be found in `carrier`
*/
}, {
key: 'extract',
value: function extract(format, carrier) {
Eif (true) {
Iif (arguments.length !== 2) {
throw new Error('Invalid number of arguments.');
}
Iif (typeof format !== 'string' || !format.length) {
throw new Error('format is expected to be a string of non-zero length');
}
Iif (format === _constants2.default.FORMAT_TEXT_MAP && !(typeof carrier === 'object')) {
throw new Error('Unexpected carrier object for FORMAT_TEXT_MAP');
}
Iif (format === _constants2.default.FORMAT_HTTP_HEADERS && !(typeof carrier === 'object')) {
throw new Error('Unexpected carrier object for FORMAT_HTTP_HEADERS');
}
Eif (format === _constants2.default.FORMAT_BINARY) {
if (carrier.buffer !== undefined && typeof carrier.buffer !== 'object') {
throw new Error('Unexpected carrier object for FORMAT_BINARY');
}
}
}
var spanContextImp = null;
Iif (this._imp) {
spanContextImp = this._imp.extract(format, carrier);
}
Iif (spanContextImp !== null) {
return new _span_context2.default(spanContextImp);
}
return null;
}
/**
* Request that any buffered or in-memory data is flushed out of the process.
*
* @param {function(err: objectg)} done - optional callback function with
* the signature `function(err)` that will be called as soon as the
* flush completes. `err` should be null or undefined if the flush
* was successful.
*/
}, {
key: 'flush',
value: function flush(done) {
if (true) {
if (arguments.length > 1) {
throw new Error('Invalid number of arguments');
}
if (done !== undefined && typeof done !== 'function') {
throw new Error('callback expected to be a function');
}
}
if (!this._imp) {
done(null);
return;
}
this._imp.flush(done);
}
// ---------------------------------------------------------------------- //
// Private and non-standard methods
// ---------------------------------------------------------------------- //
/**
* Note: this constructor should not be called directly by consumers of this
* code. The singleton's initNewTracer() method should be invoked instead.
*/
}]);
function Tracer(imp) {
_classCallCheck(this, Tracer);
this._imp = imp || null;
}
/**
* Handle to implementation object.
*
* Use of this method is discouraged as it greatly reduces the portability of
* the calling code. Use only when implementation-specific functionality must
* be used and cannot accessed otherwise.
*
* @return {object}
* An implementation-dependent object.
*/
_createClass(Tracer, [{
key: 'imp',
value: function imp() {
return this._imp;
}
}]);
return Tracer;
}();
exports.default = Tracer;
module.exports = exports['default'];
/***/ },
/* 4 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; Eif ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { Eif (protoProps) defineProperties(Constructor.prototype, protoProps); Iif (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _tracer = __webpack_require__(3);
var _tracer2 = _interopRequireDefault(_tracer);
var _span_context = __webpack_require__(5);
var _span_context2 = _interopRequireDefault(_span_context);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _classCallCheck(instance, Constructor) { Iif (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var defaultTracer = __webpack_require__(1);
/**
* Span represents a logical unit of work as part of a broader Trace. Examples
* of span might include remote procedure calls or a in-process function calls
* to sub-components. A Trace has a single, top-level "root" Span that in turn
* may have zero or more child Spans, which in turn may have children.
*/
var Span = function () {
_createClass(Span, [{
key: 'context',
// ---------------------------------------------------------------------- //
// OpenTracing API methods
// ---------------------------------------------------------------------- //
/**
* Returns the SpanContext object associated with this Span.
*
* @return {SpanContext}
*/
value: function context() {
Eif (true) {
Iif (arguments.length !== 0) {
throw new Error('Invalid number of arguments');
}
}
var spanContextImp = null;
Iif (this._imp) {
spanContextImp = this._imp.context();
}
return new _span_context2.default(spanContextImp);
}
/**
* Returns the Tracer object used to create this Span.
*
* @return {Tracer}
*/
}, {
key: 'tracer',
value: function tracer() {
if (true) {
if (arguments.length !== 0) {
throw new Error('Invalid number of arguments');
}
}
if (this._imp) {
return new _tracer2.default(this._imp.tracer());
}
return defaultTracer;
}
/**
* Sets the string name for the logical operation this span represents.
*
* @param {string} name
*/
}, {
key: 'setOperationName',
value: function setOperationName(name) {
if (true) {
if (arguments.length !== 1) {
throw new Error('Invalid number of arguments');
}
if (typeof name !== 'string' || name.length === 0) {
throw new Error('Name must be a string of length > 0');
}
}
if (this._imp) {
this._imp.setOperationName(name);
}
return this;
}
/**
* Adds a single tag to the span. See `AddTags()` for details.
*
* @param {string} key
* @param {any} value
*/
}, {
key: 'setTag',
value: function setTag(key, value) {
if (true) {
if (arguments.length !== 2) {
throw new Error('Invalid number of arguments');
}
if (typeof key !== 'string') {
throw new Error('Tag key must be a string');
}
}
this.addTags(_defineProperty({}, key, value));
return this;
}
/**
* Adds the given key value pairs to the set of span tags.
*
* Multiple calls to addTags() results in the tags being the superset of
* all calls.
*
* The behavior of setting the same key multiple times on the same span
* is undefined.
*
* The supported type of the values is implementation-dependent.
* Implementations are expected to safely handle all types of values but
* may choose to ignore unrecognized / unhandle-able values (e.g. objects
* with cyclic references, function objects).
*
* @return {[type]} [description]
*/
}, {
key: 'addTags',
value: function addTags(keyValuePairs) {
if (true) {
if (arguments.length !== 1) {
throw new Error('Invalid number of arguments');
}
if (typeof keyValuePairs !== 'object') {
throw new Error('Invalid argument type');
}
}
if (!this._imp) {
return;
}
this._imp.addTags(keyValuePairs);
return this;
}
/**
* Explicitly create a log record associated with the span.
*
* @param {object} fields - object containing the log record properties
* @param {number} [fields.timestamp] - optional field specifying the
* timestamp in milliseconds as a Unix timestamp. Fractional values
* are allowed so that timestamps with sub-millisecond accuracy
* can be represented. If not specified, the implementation is
* expected to use it's notion of the current time of the call.
* @param {string} [fields.event] - the event name
* @param {object} [fields.payload] - an arbitrary structured payload. It is
* implementation-dependent how this will be processed.
*/
}, {
key: 'log',
value: function log(fields) {
if (true) {
if (arguments.length !== 1) {
throw new Error('Invalid number of arguments');
}
if (typeof fields !== 'object') {
throw new Error('Expected fields to be an object');
}
}
if (!this._imp) {
return;
}
this._imp.log(fields);
return this;
}
/**
* Logs a event with an optional payload.
*
* @param {string} eventName - string associated with the log record
* @param {object} [payload] - arbitrary payload object associated with the
* log record.
*/
}, {
key: 'logEvent',
value: function logEvent(eventName, payload) {
return this.log({
event: eventName,
payload: payload
});
}
/**
* Sets the end timestamp and finalizes Span state.
*
* With the exception of calls to Span.context() (which are always allowed),
* finish() must be the last call made to any span instance, and to do
* otherwise leads to undefined behavior.
*
* @param {Number} finishTime
* Optional finish time in milliseconds as a Unix timestamp. Decimal
* values are supported for timestamps with sub-millisecond accuracy.
* If not specified, the current time (as defined by the
* implementation) will be used.
*/
}, {
key: 'finish',
value: function finish(finishTime) {
Eif (true) {
Iif (arguments.length > 1) {
throw new Error('Invalid arguments');
}
Iif (arguments.length === 1 && typeof finishTime !== 'number') {
throw new Error('Unexpected argument type');
}
}
Eif (!this._imp) {
return;
}
this._imp.finish(finishTime);
}
// ---------------------------------------------------------------------- //
// Private and non-standard methods
// ---------------------------------------------------------------------- //
/**
* Constructs a new Span object, this method should not be called directly;
* Tracer.startSpan() or Tracer.join() should be used instead.
*/
}]);
function Span(imp) {
_classCallCheck(this, Span);
this._imp = imp;
}
/**
* Returns the Span implementation object. The returned object is by its
* nature entirely implementation-dependent.
*/
_createClass(Span, [{
key: 'imp',
value: function imp() {
return this._imp;
}
}]);
return Span;
}();
exports.default = Span;
module.exports = exports['default'];
/***/ },
/* 5 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
/**
* SpanContext represents Span state that must propagate to descendant Spans
* and across process boundaries.
*
* SpanContext is logically divided into two pieces: the user-level "Baggage"
* (see setBaggageItem and getBaggageItem) that propagates across Span
* boundaries and any Tracer-implementation-specific fields that are needed to
* identify or otherwise contextualize the associated Span instance (e.g., a
* <trace_id, span_id, sampled> tuple).
*/
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; Eif ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { Eif (protoProps) defineProperties(Constructor.prototype, protoProps); Iif (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { Iif (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var SpanContext = function () {
_createClass(SpanContext, [{
key: 'setBaggageItem',
/**
* Sets a key:value pair on this SpanContext that also propagates to future
* children of the associated Span.
*
* setBaggageItem() enables powerful functionality given a full-stack
* opentracing integration (e.g., arbitrary application data from a web
* client can make it, transparently, all the way into the depths of a
* storage system), and with it some powerful costs: use this feature with
* care.
*
* IMPORTANT NOTE #1: setBaggageItem() will only propagate baggage items to
* *future* causal descendants of the associated Span.
*
* IMPORTANT NOTE #2: Use this thoughtfully and with care. Every key and
* value is copied into every local *and remote* child of the associated
* Span, and that can add up to a lot of network and cpu overhead.
*
* @param {string} key
* @param {string} value
*/
value: function setBaggageItem(key, value) {
if (true) {
if (arguments.length !== 2) {
throw new Error('Invalid number of arguments');
}
}
if (this._imp) {
this._imp.setBaggageItem(key, value);
}
}
/**
* Returns the value for a baggage item given its key.
*
* @param {string} key
* The key for the given trace attribute.
* @return {string}
* String value for the given key, or undefined if the key does not
* correspond to a set trace attribute.
*/
}, {
key: 'getBaggageItem',
value: function getBaggageItem(key) {
if (true) {
if (arguments.length !== 1) {
throw new Error('Invalid number of arguments');
}
}
if (this._imp) {
return this._imp.getBaggageItem(key);
}
return undefined;
}
/**
* Constructs a new SpanContext object.
*
* This method should not be called directly; Span.context() should be used
* instead.
*/
}]);
function SpanContext(imp) {
_classCallCheck(this, SpanContext);
this._imp = imp;
}
/**
* Returns the SpanContext implementation object. The returned object is by
* its nature entirely implementation-dependent.
*/
_createClass(SpanContext, [{
key: 'imp',
value: function imp() {
return this._imp;
}
}]);
return SpanContext;
}();
exports.default = SpanContext;
module.exports = exports['default'];
/***/ },
/* 6 */
/***/ function(module, exports) {
'use strict';
module.exports = {
/**
* The FORMAT_BINARY format represents SpanContexts in an opaque binary
* carrier.
*
* Tracer.inject() will set the buffer field to an Array-like (Array,
* ArrayBuffer, or TypedBuffer) object containing the injected binary data.
* Any valid Object can be used as long as the buffer field of the object
* can be set.
*
* Tracer.extract() will look for `carrier.buffer`, and that field is
* expected to be an Array-like object (Array, ArrayBuffer, or
* TypedBuffer).
*/
FORMAT_BINARY: 'binary',
/**
* The FORMAT_TEXT_MAP format represents SpanContexts using a
* string->string map (backed by a Javascript Object) as a carrier.
*
* NOTE: Unlike FORMAT_HTTP_HEADERS, FORMAT_TEXT_MAP places no restrictions
* on the characters used in either the keys or the values of the map
* entries.
*
* The FORMAT_TEXT_MAP carrier map may contain unrelated data (e.g.,
* arbitrary gRPC metadata); as such, the Tracer implementation should use
* a prefix or other convention to distinguish Tracer-specific key:value
* pairs.
*/
FORMAT_TEXT_MAP: 'text_map',
/**
* The FORMAT_HTTP_HEADERS format represents SpanContexts using a
* character-restricted string->string map (backed by a Javascript Object)
* as a carrier.
*
* Keys and values in the FORMAT_HTTP_HEADERS carrier must be suitable for
* use as HTTP headers (without modification or further escaping). That is,
* the keys have a greatly restricted character set, casing for the keys
* may not be preserved by various intermediaries, and the values should be
* URL-escaped.
*
* The FORMAT_HTTP_HEADERS carrier map may contain unrelated data (e.g.,
* arbitrary HTTP headers); as such, the Tracer implementation should use a
* prefix or other convention to distinguish Tracer-specific key:value
* pairs.
*/
FORMAT_HTTP_HEADERS: 'http_headers',
/**
* A Span may be the "child of" a parent Span. In a “child of” reference,
* the parent Span depends on the child Span in some capacity.
*
* See more about reference types at http://opentracing.io/spec/
*/
REFERENCE_CHILD_OF: 'child_of',
/**
* Some parent Spans do not depend in any way on the result of their child
* Spans. In these cases, we say merely that the child Span “follows from”
* the parent Span in a causal sense.
*
* See more about reference types at http://opentracing.io/spec/
*/
REFERENCE_FOLLOWS_FROM: 'follows_from'
};
/***/ },
/* 7 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; Eif ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { Eif (protoProps) defineProperties(Constructor.prototype, protoProps); Iif (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _span = __webpack_require__(4);
var _span2 = _interopRequireDefault(_span);
var _span_context = __webpack_require__(5);
var _span_context2 = _interopRequireDefault(_span_context);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { Iif (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* Reference pairs a reference type constant (e.g., REFERENCE_CHILD_OF or
* REFERENCE_FOLLOWS_FROM) with the SpanContext it points to.
*
* See the exported childOf() and followsFrom() functions at the package level.
*/
var Reference = function () {
_createClass(Reference, [{
key: 'type',
/**
* @return {string} The Reference type (e.g., REFERENCE_CHILD_OF or
* REFERENCE_FOLLOWS_FROM).
*/
value: function type() {
return this._type;
}
/**
* @return {SpanContext} The SpanContext being referred to (e.g., the
* parent in a REFERENCE_CHILD_OF Reference).
*/
}, {
key: 'referencedContext',
value: function referencedContext() {
return this._referencedContext;
}
/**
* Initialize a new Reference instance.
*
* @param {string} type - the Reference type constant (e.g.,
* REFERENCE_CHILD_OF or REFERENCE_FOLLOWS_FROM).
* @param {SpanContext} referencedContext - the SpanContext being referred
* to. As a convenience, a Span instance may be passed in instead
* (in which case its .context() is used here).
*/
}]);
function Reference(type, referencedContext) {
_classCallCheck(this, Reference);
Eif (true) {
Iif (!(referencedContext instanceof _span_context2.default || referencedContext instanceof _span2.default)) {
throw new Error('referencedContext must be a Span or SpanContext instance');
}
}
this._type = type;
this._referencedContext = referencedContext instanceof _span2.default ? referencedContext.context() : referencedContext;
}
return Reference;
}();
exports.default = Reference;
module.exports = exports['default'];
/***/ },
/* 8 */
/***/ function(module, exports) {
'use strict';
/**
* Convenience class to use as a binary carrier.
*
* Any valid Object with a field named `buffer` may be used as a binary carrier;
* this class is only one such type of object that can be used.
*/
Object.defineProperty(exports, "__esModule", {
value: true
});
function _classCallCheck(instance, Constructor) { Iif (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var BinaryCarrier = function BinaryCarrier(binaryData) {
_classCallCheck(this, BinaryCarrier);
this.buffer = binaryData;
};
exports.default = BinaryCarrier;
module.exports = exports['default'];
/***/ }
/******/ ]);
//# sourceMappingURL=opentracing-node-debug.js.map |