From 96b5c5c4dcaaf81f697e7aefb2d96126f521a12c Mon Sep 17 00:00:00 2001 From: Pagan Gazzard Date: Fri, 20 Dec 2024 18:02:45 +0000 Subject: [PATCH] Loki: reduce unnecessary recreation of structured metadata Change-type: patch --- src/features/device-logs/lib/backends/loki.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/features/device-logs/lib/backends/loki.ts b/src/features/device-logs/lib/backends/loki.ts index 7ad2cfa0b..9088cea2f 100644 --- a/src/features/device-logs/lib/backends/loki.ts +++ b/src/features/device-logs/lib/backends/loki.ts @@ -379,6 +379,7 @@ export class LokiBackend implements DeviceLogsBackend { ctx: LogContext, logs: Array, ) { + const structuredMetadata = this.getStructuredMetadata(ctx); return logs.map((log) => { const timestamp = new loki.Timestamp(); timestamp.setSeconds(Math.floor(Number(log.nanoTimestamp / 1000000000n))); @@ -388,7 +389,6 @@ export class LokiBackend implements DeviceLogsBackend { { ...log, version: VERSION }, omitNanoTimestamp, ); - const structuredMetadata = this.getStructuredMetadata(ctx); // create entry with labels, line and timestamp return new loki.EntryAdapter() .setLine(logJson)