This commit is contained in:
Simon Larsen 2023-10-23 15:51:38 +01:00
parent 9fe998a43d
commit 03f9c36f06
No known key found for this signature in database
GPG Key ID: AB45983AA9C81CDE
2 changed files with 14 additions and 16 deletions

View File

@ -191,19 +191,24 @@ router.post(
req.body = req.body.toJSON();
const resourceLogs = req.body['resourceLogs'] as JSONArray;
const resourceLogs: JSONArray = req.body[
'resourceLogs'
] as JSONArray;
const dbLogs: Array<Log> = [];
for (const resourceLog of resourceLogs) {
const scopeLogs = resourceLog['scopeLogs'] as JSONArray;
const scopeLogs: JSONArray = resourceLog[
'scopeLogs'
] as JSONArray;
for (const scopeLog of scopeLogs) {
const logRecords = scopeLog['logRecords'] as JSONArray;
const logRecords: JSONArray = scopeLog[
'logRecords'
] as JSONArray;
for (const log of logRecords) {
const dbLog = new Log();
const dbLog: Log = new Log();
/*
Example:
@ -225,26 +230,25 @@ router.post(
dbLog.serviceId = ObjectID.getZeroObjectID();
dbLog.timeUnixNano = log['timeUnixNano'] as number;
dbLog.time = OneUptimeDate.fromUnixNano(log['timeUnixNano'] as number);
dbLog.time = OneUptimeDate.fromUnixNano(
log['timeUnixNano'] as number
);
dbLog.severityNumber = log['severityNumber'] as string;
dbLog.severityText = log['severityText'] as string;
const logBody: JSONObject = log['body'] as JSONObject;
dbLog.body = logBody['stringValue'] as string;
dbLog.traceId = log['traceId'] as string;
dbLog.spanId = log['spanId'] as string;
// We need to convert this to date.
const attributes: JSONArray = log[
'attributes'
] as JSONArray;
if (attributes) {
const dbattributes: Array<KeyValueNestedModel> = [];
for (const attribute of attributes) {
@ -274,9 +278,7 @@ router.post(
}
dbLogs.push(dbLog);
}
}
}

View File

@ -29,7 +29,6 @@ export default class Log extends AnalyticsBaseModel {
type: TableColumnType.ObjectID,
}),
new AnalyticsTableColumn({
key: 'time',
title: 'Time',
@ -46,7 +45,6 @@ export default class Log extends AnalyticsBaseModel {
type: TableColumnType.Number,
}),
new AnalyticsTableColumn({
key: 'severityText',
title: 'Severity Text',
@ -63,7 +61,6 @@ export default class Log extends AnalyticsBaseModel {
type: TableColumnType.Text,
}),
new AnalyticsTableColumn({
key: 'attributes',
title: 'Attributes',
@ -157,7 +154,6 @@ export default class Log extends AnalyticsBaseModel {
this.setColumnValue('severityNumber', v);
}
public get attributes(): Array<KeyValueNestedModel> | undefined {
return this.getColumnValue('attributes') as
| Array<KeyValueNestedModel>