From 40e0251522e4ab7cd3227bd743120b17ba619f24 Mon Sep 17 00:00:00 2001 From: dmathieu <42@dmathieu.com> Date: Wed, 24 Apr 2024 14:08:47 +0200 Subject: [PATCH] simplify appending in convertFields --- bridges/otellogrus/hook.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/bridges/otellogrus/hook.go b/bridges/otellogrus/hook.go index 75894fadc06..967f916e71c 100644 --- a/bridges/otellogrus/hook.go +++ b/bridges/otellogrus/hook.go @@ -185,15 +185,12 @@ func (h *Hook) convertEntry(e *logrus.Entry) log.Record { } func convertFields(fields logrus.Fields) []log.KeyValue { - kvs := make([]log.KeyValue, len(fields)) - - i := 0 + kvs := make([]log.KeyValue, 0, len(fields)) for k, v := range fields { - kvs[i] = log.KeyValue{ + kvs = append(kvs, log.KeyValue{ Key: k, Value: convertValue(v), - } - i++ + }) } return kvs }