UNPKG

@embrace-io/web-sdk

Version:
72 lines (71 loc) 1.83 kB
import { KEY_EMB_ERROR_CODE } from "../../constants/attributes.js"; //#region src/managers/EmbraceTraceManager/EmbraceExtendedSpan.ts /** * EmbraceSpan for the most part simply delegates to the underlying Span it receives on initialization so * that it satisfies the Span interface. In addition, it gives us a spot where we can implement helpers that are part * of the EmbraceSpan interface. */ var EmbraceExtendedSpan = class { _span; constructor(span) { this._span = span; } /** * Expose attributes by extending OpenTelemetry's ReadableSpan. */ get attributes() { return this._span.attributes; } 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; } end(endTime) { this._span.end(endTime); } isRecording() { return this._span.isRecording(); } recordException(exception, time) { this._span.recordException(exception, time); } setAttribute(key, value) { this._span.setAttribute(key, value); return this; } setAttributes(attributes) { this._span.setAttributes(attributes); return this; } removeAttribute(key) { const { [key]: _, ...attributes } = this._span.attributes; this._span.attributes = attributes; return this; } setStatus(status) { this._span.setStatus(status); return this; } spanContext() { return this._span.spanContext(); } updateName(name) { this._span.updateName(name); return this; } fail(options = { code: "failure" }) { if (options.code) this._span.setAttribute(KEY_EMB_ERROR_CODE, options.code.toUpperCase()); this._span.end(options.endTime); } }; //#endregion export { EmbraceExtendedSpan }; //# sourceMappingURL=EmbraceExtendedSpan.js.map