From bc279382b858299317077535089b9017b5377066 Mon Sep 17 00:00:00 2001 From: quzard <1191890118@qq.com> Date: Tue, 26 Dec 2023 13:32:13 +0000 Subject: [PATCH 1/4] fix context --- pluginmanager/plugin_runner_v1.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pluginmanager/plugin_runner_v1.go b/pluginmanager/plugin_runner_v1.go index 147109e947..59dbd36015 100644 --- a/pluginmanager/plugin_runner_v1.go +++ b/pluginmanager/plugin_runner_v1.go @@ -432,10 +432,11 @@ func (p *pluginv1Runner) ReceiveRawLog(log *pipeline.LogWithContext) { } func (p *pluginv1Runner) ReceiveLogGroup(logGroup pipeline.LogGroupWithContext) { - context := logGroup.Context topic := logGroup.LogGroup.GetTopic() - context[ctxKeyTopic] = topic for _, log := range logGroup.LogGroup.Logs { + context := map[string]interface{}{} + context[ctxKeySource] = logGroup.Context[ctxKeySource] + context[ctxKeyTopic] = topic if len(topic) > 0 { log.Contents = append(log.Contents, &protocol.Log_Content{Key: tagKeyLogTopic, Value: topic}) } From 50ec570f8cf5fe1134f9697d159946d64ce4013b Mon Sep 17 00:00:00 2001 From: quzard <1191890118@qq.com> Date: Wed, 27 Dec 2023 02:28:04 +0000 Subject: [PATCH 2/4] fix --- pluginmanager/plugin_runner_v1.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pluginmanager/plugin_runner_v1.go b/pluginmanager/plugin_runner_v1.go index 59dbd36015..2b4798dfa4 100644 --- a/pluginmanager/plugin_runner_v1.go +++ b/pluginmanager/plugin_runner_v1.go @@ -435,7 +435,9 @@ func (p *pluginv1Runner) ReceiveLogGroup(logGroup pipeline.LogGroupWithContext) topic := logGroup.LogGroup.GetTopic() for _, log := range logGroup.LogGroup.Logs { context := map[string]interface{}{} - context[ctxKeySource] = logGroup.Context[ctxKeySource] + for key, value := range logGroup.Context { + context[key] = value + } context[ctxKeyTopic] = topic if len(topic) > 0 { log.Contents = append(log.Contents, &protocol.Log_Content{Key: tagKeyLogTopic, Value: topic}) @@ -445,6 +447,8 @@ func (p *pluginv1Runner) ReceiveLogGroup(logGroup pipeline.LogGroupWithContext) context[ctxKeyTags] = logGroup.LogGroup.LogTags p.ReceiveRawLog(&pipeline.LogWithContext{Log: log, Context: context}) } else { + context := logGroup.Context + context[ctxKeyTopic] = topic for _, tag := range logGroup.LogGroup.LogTags { log.Contents = append(log.Contents, &protocol.Log_Content{ Key: tagPrefix + tag.GetKey(), From 7bd27224c65b91f6b3f2c7cd7e4168aeeded6bc5 Mon Sep 17 00:00:00 2001 From: quzard <1191890118@qq.com> Date: Wed, 27 Dec 2023 02:34:59 +0000 Subject: [PATCH 3/4] fix --- pluginmanager/plugin_runner_v1.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pluginmanager/plugin_runner_v1.go b/pluginmanager/plugin_runner_v1.go index 2b4798dfa4..113530018c 100644 --- a/pluginmanager/plugin_runner_v1.go +++ b/pluginmanager/plugin_runner_v1.go @@ -434,16 +434,16 @@ func (p *pluginv1Runner) ReceiveRawLog(log *pipeline.LogWithContext) { func (p *pluginv1Runner) ReceiveLogGroup(logGroup pipeline.LogGroupWithContext) { topic := logGroup.LogGroup.GetTopic() for _, log := range logGroup.LogGroup.Logs { - context := map[string]interface{}{} - for key, value := range logGroup.Context { - context[key] = value - } - context[ctxKeyTopic] = topic if len(topic) > 0 { log.Contents = append(log.Contents, &protocol.Log_Content{Key: tagKeyLogTopic, Value: topic}) } // When UsingOldContentTag is set to false, the tag is now put into the context during cgo. if !p.LogstoreConfig.GlobalConfig.UsingOldContentTag { + context := map[string]interface{}{} + for key, value := range logGroup.Context { + context[key] = value + } + context[ctxKeyTopic] = topic context[ctxKeyTags] = logGroup.LogGroup.LogTags p.ReceiveRawLog(&pipeline.LogWithContext{Log: log, Context: context}) } else { From 7db44def8ae4dbc6b3ab759f981ea45ec07ffb2d Mon Sep 17 00:00:00 2001 From: quzard <1191890118@qq.com> Date: Wed, 27 Dec 2023 20:29:12 +0800 Subject: [PATCH 4/4] fix --- pluginmanager/plugin_runner_v1.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pluginmanager/plugin_runner_v1.go b/pluginmanager/plugin_runner_v1.go index 113530018c..a51921d94f 100644 --- a/pluginmanager/plugin_runner_v1.go +++ b/pluginmanager/plugin_runner_v1.go @@ -447,7 +447,10 @@ func (p *pluginv1Runner) ReceiveLogGroup(logGroup pipeline.LogGroupWithContext) context[ctxKeyTags] = logGroup.LogGroup.LogTags p.ReceiveRawLog(&pipeline.LogWithContext{Log: log, Context: context}) } else { - context := logGroup.Context + context := map[string]interface{}{} + for key, value := range logGroup.Context { + context[key] = value + } context[ctxKeyTopic] = topic for _, tag := range logGroup.LogGroup.LogTags { log.Contents = append(log.Contents, &protocol.Log_Content{