From e9d143d1e9eb873411497c53d980402e17a9a405 Mon Sep 17 00:00:00 2001 From: ZetaoZhuang <106119232+ZetaoZhuang@users.noreply.github.com> Date: Tue, 18 Oct 2022 18:55:46 -0700 Subject: [PATCH] fix: declare the core.lock to be a pointer to make core concurrency safe (#1626) declare core.lock to be a pointer, so the lock in cloned core can point to the same pointer --- zapai/core.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/zapai/core.go b/zapai/core.go index 1a06e4a65..d980e716a 100644 --- a/zapai/core.go +++ b/zapai/core.go @@ -32,7 +32,7 @@ type Core struct { fieldMappers map[string]fieldTagMapper fields []zapcore.Field out zapcore.WriteSyncer - lock sync.Mutex + lock *sync.Mutex } // NewCore creates a new appinsights zap core. Should only be initialized using an appinsights Sink as the @@ -43,6 +43,7 @@ func NewCore(le zapcore.LevelEnabler, out zapcore.WriteSyncer) *Core { enc: newTraceEncoder(), fieldMappers: make(map[string]fieldTagMapper), out: out, + lock: &sync.Mutex{}, } }