@vtex/diagnostics-nodejs
Version:
Diagnostics library for Node.js applications
70 lines • 2.01 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SpanEndConfig = exports.SpanConfig = exports.TracesConfig = void 0;
exports.withResourceAttributes = withResourceAttributes;
exports.withContribInstrumentation = withContribInstrumentation;
exports.withExporter = withExporter;
exports.withSpanProcessor = withSpanProcessor;
exports.withSpanAttributes = withSpanAttributes;
exports.withSpanKind = withSpanKind;
exports.withEndTime = withEndTime;
class TracesConfig {
constructor(options = []) {
this.resourceAttributes = {};
this.spanAttributes = {};
this.instrumentations = [];
this.exporters = [];
this.processors = [];
options.forEach(option => option(this));
}
}
exports.TracesConfig = TracesConfig;
function withResourceAttributes(attrs) {
return (config) => {
config.resourceAttributes = { ...config.resourceAttributes, ...attrs };
};
}
function withContribInstrumentation(instrumentation) {
return (config) => {
config.instrumentations.push(instrumentation);
};
}
function withExporter(exporter) {
return (config) => {
config.exporters.push(exporter);
};
}
function withSpanProcessor(processor) {
return (config) => {
config.processors.push(processor);
};
}
class SpanConfig {
constructor(options = []) {
this.attributes = {};
options.forEach(option => option(this));
}
}
exports.SpanConfig = SpanConfig;
function withSpanAttributes(attrs) {
return (config) => {
config.attributes = { ...config.attributes, ...attrs };
};
}
function withSpanKind(kind) {
return (config) => {
config.kind = kind;
};
}
class SpanEndConfig {
constructor(options = []) {
options.forEach(option => option(this));
}
}
exports.SpanEndConfig = SpanEndConfig;
function withEndTime(timestamp) {
return (config) => {
config.timestamp = timestamp;
};
}
//# sourceMappingURL=config.js.map