"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Trace = Trace;
const api_1 = require("@opentelemetry/api");
const tracer = api_1.trace.getTracer('repoburg-backend');
function Trace() {
    return function (target, propertyKey, descriptor) {
        const originalMethod = descriptor.value;
        descriptor.value = function (...args) {
            const spanName = `${target.constructor.name}#${propertyKey}`;
            return tracer.startActiveSpan(spanName, async (span) => {
                try {
                    return await originalMethod.apply(this, args);
                }
                catch (error) {
                    span.recordException(error);
                    span.setStatus({
                        code: api_1.SpanStatusCode.ERROR,
                        message: error.message,
                    });
                    throw error;
                }
                finally {
                    span.end();
                }
            });
        };
        return descriptor;
    };
}
//# sourceMappingURL=trace.decorator.js.map