From c4edab884e7cdc4f28ef65b8d52891656fdae961 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Farkas?= Date: Fri, 6 May 2022 10:55:12 +0200 Subject: [PATCH] logs: simpler nanoscecond timestamp handling (#48773) --- public/app/core/logs_model.ts | 4 +--- .../loki/backendResultTransformer.test.ts | 1 - .../loki/backendResultTransformer.ts | 22 +------------------ 3 files changed, 2 insertions(+), 25 deletions(-) diff --git a/public/app/core/logs_model.ts b/public/app/core/logs_model.ts index bde1bd525a0..2e16093b144 100644 --- a/public/app/core/logs_model.ts +++ b/public/app/core/logs_model.ts @@ -364,9 +364,7 @@ export function logSeriesToLogsModel(logSeries: DataFrame[]): LogsModel | undefi series, timeField, labelsField, - timeNanosecondField: fieldCache.hasFieldWithNameAndType('tsNs', FieldType.time) - ? fieldCache.getFieldByName('tsNs') - : undefined, + timeNanosecondField: fieldCache.getFieldByName('tsNs'), stringField, logLevelField: fieldCache.getFieldByName('level'), idField: getIdField(fieldCache), diff --git a/public/app/plugins/datasource/loki/backendResultTransformer.test.ts b/public/app/plugins/datasource/loki/backendResultTransformer.test.ts index 2d01b584b63..89ee35f8dfd 100644 --- a/public/app/plugins/datasource/loki/backendResultTransformer.test.ts +++ b/public/app/plugins/datasource/loki/backendResultTransformer.test.ts @@ -62,7 +62,6 @@ describe('loki backendResultTransformer', () => { lokiQueryStatKey: 'Summary: total bytes processed', }, }; - expectedFrame.fields[3].type = FieldType.time; const expected: DataQueryResponse = { data: [expectedFrame] }; diff --git a/public/app/plugins/datasource/loki/backendResultTransformer.ts b/public/app/plugins/datasource/loki/backendResultTransformer.ts index cff060731d7..d2d8004f6f2 100644 --- a/public/app/plugins/datasource/loki/backendResultTransformer.ts +++ b/public/app/plugins/datasource/loki/backendResultTransformer.ts @@ -28,28 +28,8 @@ function processStreamFrame(frame: DataFrame, query: LokiQuery | undefined): Dat lokiQueryStatKey: 'Summary: total bytes processed', }, }; - const newFrame = setFrameMeta(frame, meta); - const newFields = newFrame.fields.map((field) => { - switch (field.name) { - case 'tsNs': { - // we need to switch the field-type to be `time` - return { - ...field, - type: FieldType.time, - }; - } - default: { - // no modification needed - return field; - } - } - }); - - return { - ...newFrame, - fields: newFields, - }; + return setFrameMeta(frame, meta); } function processStreamsFrames(frames: DataFrame[], queryMap: Map): DataFrame[] {