"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.OISpan = void 0;
const maskingRules_1 = require("./maskingRules");
/**
 * A wrapper around the OpenTelemetry {@link Span} interface that masks sensitive information based on the passed in {@link TraceConfig}.
 */
class OISpan {
    constructor({ span, config }) {
        this.span = span;
        this.config = config;
    }
    setAttribute(key, value) {
        const maskedValue = (0, maskingRules_1.mask)({ config: this.config, key, value });
        if (maskedValue != null) {
            this.span.setAttribute(key, maskedValue);
        }
        return this;
    }
    setAttributes(attributes) {
        const maskedAttributes = Object.entries(attributes).reduce((maskedAttributes, [key, value]) => {
            maskedAttributes[key] = (0, maskingRules_1.mask)({ config: this.config, key, value });
            return maskedAttributes;
        }, {});
        this.span.setAttributes(maskedAttributes);
        return this;
    }
    addEvent(name, attributesOrStartTime, startTime) {
        this.span.addEvent(name, attributesOrStartTime, startTime);
        return this;
    }
    setStatus(status) {
        this.span.setStatus(status);
        return this;
    }
    updateName(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);
    }
    spanContext() {
        return this.span.spanContext();
    }
    addLink(link) {
        this.span.addLink(link);
        return this;
    }
    addLinks(links) {
        this.span.addLinks(links);
        return this;
    }
}
exports.OISpan = OISpan;
//# sourceMappingURL=OISpan.js.map