1 | "use strict";
|
2 | var __extends = (this && this.__extends) || (function () {
|
3 | var extendStatics = function (d, b) {
|
4 | extendStatics = Object.setPrototypeOf ||
|
5 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
6 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
7 | return extendStatics(d, b);
|
8 | };
|
9 | return function (d, b) {
|
10 | extendStatics(d, b);
|
11 | function __() { this.constructor = d; }
|
12 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
13 | };
|
14 | })();
|
15 | Object.defineProperty(exports, "__esModule", { value: true });
|
16 |
|
17 | var opentracing = require("../index");
|
18 | var mock_report_1 = require("./mock_report");
|
19 | var mock_span_1 = require("./mock_span");
|
20 |
|
21 |
|
22 |
|
23 | var MockTracer = (function (_super) {
|
24 | __extends(MockTracer, _super);
|
25 |
|
26 |
|
27 |
|
28 | function MockTracer() {
|
29 | var _this = _super.call(this) || this;
|
30 | _this._spans = [];
|
31 | return _this;
|
32 | }
|
33 |
|
34 |
|
35 |
|
36 | MockTracer.prototype._startSpan = function (name, fields) {
|
37 |
|
38 |
|
39 |
|
40 | var span = this._allocSpan();
|
41 | span.setOperationName(name);
|
42 | this._spans.push(span);
|
43 | if (fields.references) {
|
44 | for (var _i = 0, _a = fields.references; _i < _a.length; _i++) {
|
45 | var ref = _a[_i];
|
46 | span.addReference(ref);
|
47 | }
|
48 | }
|
49 |
|
50 | span._startStack = new Error().stack;
|
51 | return span;
|
52 | };
|
53 | MockTracer.prototype._inject = function (span, format, carrier) {
|
54 | throw new Error('NOT YET IMPLEMENTED');
|
55 | };
|
56 | MockTracer.prototype._extract = function (format, carrier) {
|
57 | throw new Error('NOT YET IMPLEMENTED');
|
58 | };
|
59 | MockTracer.prototype._allocSpan = function () {
|
60 | return new mock_span_1.default(this);
|
61 | };
|
62 | |
63 |
|
64 |
|
65 | MockTracer.prototype.clear = function () {
|
66 | this._spans = [];
|
67 | };
|
68 | |
69 |
|
70 |
|
71 |
|
72 | MockTracer.prototype.report = function () {
|
73 | return new mock_report_1.default(this._spans);
|
74 | };
|
75 | return MockTracer;
|
76 | }(opentracing.Tracer));
|
77 | exports.MockTracer = MockTracer;
|
78 | exports.default = MockTracer;
|
79 |
|
\ | No newline at end of file |