logs: simpler nanoscecond timestamp handling (#48773)

This commit is contained in:
Gábor Farkas 2022-05-06 10:55:12 +02:00 committed by GitHub
parent b6c5f29373
commit c4edab884e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 2 additions and 25 deletions

View File

@ -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),

View File

@ -62,7 +62,6 @@ describe('loki backendResultTransformer', () => {
lokiQueryStatKey: 'Summary: total bytes processed',
},
};
expectedFrame.fields[3].type = FieldType.time;
const expected: DataQueryResponse = { data: [expectedFrame] };

View File

@ -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<string, LokiQuery>): DataFrame[] {