nestjs-otel
Version:
NestJS OpenTelemetry Library
27 lines (26 loc) • 1.09 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Traceable = Traceable;
const span_1 = require("./span");
/**
* Decorator that applies the @Span decorator to all methods of a class.
*
* @param options SpanOptions to be applied to all methods
*/
function Traceable(options) {
return (target) => {
for (const propertyKey of Object.getOwnPropertyNames(target.prototype)) {
if (propertyKey === "constructor") {
continue;
}
const descriptor = Object.getOwnPropertyDescriptor(target.prototype, propertyKey);
if (descriptor && typeof descriptor.value === "function") {
// Apply Span decorator
// Span() returns a decorator function: (target, propertyKey, descriptor) => void
(0, span_1.Span)(options)(target.prototype, propertyKey, descriptor);
// Re-define the property with the modified descriptor
Object.defineProperty(target.prototype, propertyKey, descriptor);
}
}
};
}