@vtex/diagnostics-nodejs
Version:
Diagnostics library for Node.js applications
60 lines • 1.57 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Span = void 0;
const api_1 = require("@opentelemetry/api");
class Span {
constructor(span, name, kind = api_1.SpanKind.INTERNAL) {
this._span = span;
this.name = name;
this.kind = kind;
this.attributes = {};
}
_getOtelSpan() {
return this._span;
}
spanContext() {
return this._span.spanContext();
}
setAttribute(key, value) {
this.attributes[key] = value;
this._span.setAttribute(key, value);
return this;
}
setAttributes(attributes) {
this.attributes = { ...this.attributes, ...attributes };
this._span.setAttributes(this.attributes);
return this;
}
addEvent(name, attributesOrStartTime, startTime) {
this._span.addEvent(name, attributesOrStartTime, startTime);
return this;
}
addLink(link) {
this._span.addLink(link);
return this;
}
addLinks(links) {
this._span.addLinks(links);
return this;
}
setStatus(status) {
this._span.setStatus(status);
return this;
}
updateName(name) {
this.name = name;
this._span.updateName(name);
return this;
}
end(endTime) {
this._span.end(endTime);
}
isRecording() {
return this._span.isRecording();
}
recordException(exception, time) {
this._span.recordException(exception, time);
}
}
exports.Span = Span;
//# sourceMappingURL=span.js.map