add filter

This commit is contained in:
Peter Maquiran
2024-06-17 10:33:35 +01:00
parent 54cdf512c0
commit 768dc10308
10 changed files with 135 additions and 55 deletions
@@ -15,7 +15,7 @@ Device.getInfo().then(e => {
device = e
});
export function XTracerAsync({name, log, bugPrint}: any) {
export function XTracerAsync({ name, log, bugPrint }: any, p0?: any) {
return (
target: unknown,
propertyKey: string,
@@ -26,12 +26,14 @@ export function XTracerAsync({name, log, bugPrint}: any) {
const requestId = uuidv4()
const span = tracerInstance.startSpan(name);
let hasBug:Boolean
const createTracingInstance = (): TracingType => {
const logs: any[] = []
const data = {
event: {},
tags: {}
}
const createTracingInstance = (): TracingType => {
return {
span: span as any,
@@ -42,27 +44,23 @@ export function XTracerAsync({name, log, bugPrint}: any) {
span.setStatus(status);
},
addEvent: (context: string, message?: any, obj?: any) => {
if(log == true) {
// logger.error(obj, context, message)
} else {
logs.push({context, message: message, obj})
}
data.event[context] = message;
const value = [JSON.stringify(message)] as any
span.addEvent(context, value);
},
LocalLogEvent:(context: string, message: any, obj: any) => {
logs.push({context, message, obj})
data.tags[context] = message;
},
setAttribute: (key: string, value: string) => {
data.tags[key] = value;
span.setAttribute(key, value);
},
finish: () => {
span.end();
if(bugPrint && hasBug) {
for(const {context, message, obj} of logs) {
// logger.error(obj, context, message)
}
console.error(name, data)
}
},
bugFlag:() => {
@@ -76,7 +74,7 @@ export function XTracerAsync({name, log, bugPrint}: any) {
const tracing = createTracingInstance()
tracing.setAttribute('current.page', window.location.pathname);
tracing.setAttribute('device.name', device.name || device.model)
tracing.setAttribute('device.name', device?.name || device?.model)
args.push(tracing)
@@ -111,9 +109,12 @@ export function XTracer({name, log, bugPrint}: any) {
let hasBug:Boolean
const createTracingInstance = (): TracingType => {
const logs: any[] = []
const data = {
event: {},
tags: {}
}
const createTracingInstance = (): TracingType => {
return {
span: span as any,
@@ -124,27 +125,23 @@ export function XTracer({name, log, bugPrint}: any) {
span.setStatus(status);
},
addEvent: (context: string, message?: any, obj?: any) => {
if(log == true) {
// logger.error(obj, context, message)
} else {
logs.push({context, message: message, obj})
}
data.event[context] = message;
const value = [JSON.stringify(message)] as any
span.addEvent(context, value);
},
LocalLogEvent:(context: string, message: any, obj: any) => {
logs.push({context, message, obj})
data.tags[context] = message;
},
setAttribute: (key: string, value: any) => {
setAttribute: (key: string, value: string) => {
data.tags[key] = value;
span.setAttribute(key, value);
},
finish: () => {
span.end();
if(bugPrint && hasBug) {
for(const {context, message, obj} of logs) {
// logger.error(obj, context, message)
}
console.error(name, data)
}
},
bugFlag:() => {
@@ -158,7 +155,7 @@ export function XTracer({name, log, bugPrint}: any) {
const tracing = createTracingInstance()
tracing.setAttribute('current.page', window.location.pathname);
tracing.setAttribute('device.name', device.name || device.model)
tracing.setAttribute('device.name', device?.name || device?.model)
args.push(tracing)