opentracing
Version:
[![Build Status][ci-img]][ci] [![Coverage Status][cov-img]][cov] [![NPM Published Version][npm-img]][npm] ![Node Version][node-img] [;
/**
* Index a collection of reported MockSpans in a way that's easy to run unit
* test assertions against.
*/
var MockReport = /** @class */ (function () {
function MockReport(spans) {
var _this = this;
this.spans = spans;
this.spansByUUID = {};
this.spansByTag = {};
this.debugSpans = [];
this.unfinishedSpans = [];
spans.forEach(function (span) {
if (span._finishMs === 0) {
_this.unfinishedSpans.push(span);
}
_this.spansByUUID[span.uuid()] = span;
_this.debugSpans.push(span.debug());
var tags = span.tags();
Object.keys(tags).forEach(function (key) {
var val = tags[key];
_this.spansByTag[key] = _this.spansByTag[key] || {};
_this.spansByTag[key][val] = _this.spansByTag[key][val] || [];
_this.spansByTag[key][val].push(span);
});
});
}
MockReport.prototype.firstSpanWithTagValue = function (key, val) {
var m = this.spansByTag[key];
if (!m) {
return null;
}
var n = m[val];
if (!n) {
return null;
}
return n[0];
};
return MockReport;
}());
exports.MockReport = MockReport;
exports.default = MockReport;
//# sourceMappingURL=mock_report.js.map
;