autotel
Version:
Write Once, Observe Anywhere
100 lines (97 loc) • 3.46 kB
JavaScript
;
var chunkUTZR7P7E_cjs = require('./chunk-UTZR7P7E.cjs');
// src/semantic-helpers.ts
function traceLLM(config) {
return (fnFactory) => {
return chunkUTZR7P7E_cjs.trace((ctx) => {
ctx.setAttribute("gen.ai.request.model", config.model);
ctx.setAttribute("gen.ai.operation.name", config.operation || "chat");
if (config.provider) {
ctx.setAttribute("gen.ai.system", config.provider);
}
if (config.attributes) {
for (const [key, value] of Object.entries(config.attributes)) {
if (value !== void 0 && value !== null) {
const attrValue = typeof value === "string" || typeof value === "number" || typeof value === "boolean" ? value : JSON.stringify(value);
ctx.setAttribute(key, attrValue);
}
}
}
return fnFactory(ctx);
});
};
}
function traceDB(config) {
return (fnFactory) => {
return chunkUTZR7P7E_cjs.trace((ctx) => {
ctx.setAttribute("db.system", config.system);
if (config.operation) {
ctx.setAttribute("db.operation", config.operation);
}
if (config.database) {
ctx.setAttribute("db.name", config.database);
}
if (config.collection) {
ctx.setAttribute("db.collection.name", config.collection);
}
if (config.attributes) {
for (const [key, value] of Object.entries(config.attributes)) {
if (value !== void 0 && value !== null) {
const attrValue = typeof value === "string" || typeof value === "number" || typeof value === "boolean" ? value : JSON.stringify(value);
ctx.setAttribute(key, attrValue);
}
}
}
return fnFactory(ctx);
});
};
}
function traceHTTP(config) {
return (fnFactory) => {
return chunkUTZR7P7E_cjs.trace((ctx) => {
if (config.method) {
ctx.setAttribute("http.request.method", config.method);
}
if (config.url) {
ctx.setAttribute("url.full", config.url);
}
if (config.attributes) {
for (const [key, value] of Object.entries(config.attributes)) {
if (value !== void 0 && value !== null) {
const attrValue = typeof value === "string" || typeof value === "number" || typeof value === "boolean" ? value : JSON.stringify(value);
ctx.setAttribute(key, attrValue);
}
}
}
return fnFactory(ctx);
});
};
}
function traceMessaging(config) {
return (fnFactory) => {
return chunkUTZR7P7E_cjs.trace((ctx) => {
ctx.setAttribute("messaging.system", config.system);
if (config.operation) {
ctx.setAttribute("messaging.operation", config.operation);
}
if (config.destination) {
ctx.setAttribute("messaging.destination.name", config.destination);
}
if (config.attributes) {
for (const [key, value] of Object.entries(config.attributes)) {
if (value !== void 0 && value !== null) {
const attrValue = typeof value === "string" || typeof value === "number" || typeof value === "boolean" ? value : JSON.stringify(value);
ctx.setAttribute(key, attrValue);
}
}
}
return fnFactory(ctx);
});
};
}
exports.traceDB = traceDB;
exports.traceHTTP = traceHTTP;
exports.traceLLM = traceLLM;
exports.traceMessaging = traceMessaging;
//# sourceMappingURL=chunk-YEVCD6DR.cjs.map
//# sourceMappingURL=chunk-YEVCD6DR.cjs.map