Skip to content

Commit 5adfeac

Browse files
committed
fix: removing debug logs
1 parent f65680f commit 5adfeac

File tree

4 files changed

+7
-25
lines changed

4 files changed

+7
-25
lines changed

src/plugins/common.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package plugins
22

33
import (
4-
"fmt"
54
"github.com/nginx/agent/sdk/v2/client"
65
"github.com/nginx/agent/v2/src/core"
76
"github.com/nginx/agent/v2/src/core/config"
@@ -36,8 +35,6 @@ func LoadPlugins(commander client.Commander, binary core.NginxBinary, env core.E
3635
}
3736

3837
if (loadedConfig.IsFeatureEnabled(agent_config.FeatureMetrics) || loadedConfig.IsFeatureEnabled(agent_config.FeatureMetricsSender)) && reporter != nil {
39-
fmt.Println(fmt.Sprintf("metrics enabled : %t", loadedConfig.IsExtensionEnabled(agent_config.FeatureMetrics)))
40-
fmt.Println(fmt.Sprintf("metrics-sender enabled : %t", loadedConfig.IsExtensionEnabled(agent_config.FeatureMetricsSender)))
4138
corePlugins = append(corePlugins,
4239
NewMetricsSender(reporter, loadedConfig),
4340
)

src/plugins/config_reader.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,6 @@ func (r *ConfigReader) updateAgentConfig(payloadAgentConfig *proto.AgentConfig)
107107

108108
sort.Strings(onDiskAgentConfig.Features)
109109
sort.Strings(payloadAgentConfig.Details.Features)
110-
log.Debugf("OnDisk Agent Features %v", onDiskAgentConfig.Features)
111-
log.Debugf("Payload Agent Features %v", payloadAgentConfig.Details.Features)
112110
r.detailsMu.Unlock()
113111

114112
r.detailsMu.RLock()
@@ -139,7 +137,7 @@ func (r *ConfigReader) updateAgentConfig(payloadAgentConfig *proto.AgentConfig)
139137
log.Errorf("Failed updating Agent config - %v", err)
140138
}
141139
if configUpdated {
142-
log.Debugf("Updated agent config on disk %v %v", features, synchronizeFeatures)
140+
log.Debugf("Updated agent config on disk")
143141
}
144142
}
145143

@@ -154,13 +152,12 @@ func (r *ConfigReader) updateAgentConfig(payloadAgentConfig *proto.AgentConfig)
154152
}
155153

156154
if synchronizeFeatures {
157-
log.Debugf("agent config changed, synchronizeFeatures")
155+
log.Debugf("agent config features changed, synchronizing features")
158156
r.synchronizeFeatures(payloadAgentConfig)
157+
r.config.Features = payloadAgentConfig.Details.Features
159158
}
160159

161-
log.Debugf("agent config changed, updating all plugins %v", payloadAgentConfig)
162160
r.messagePipeline.Process(core.NewMessage(core.AgentConfigChanged, payloadAgentConfig))
163-
r.config.Features = payloadAgentConfig.Details.Features
164161
}
165162
}
166163

@@ -169,7 +166,7 @@ func (r *ConfigReader) synchronizeFeatures(agtCfg *proto.AgentConfig) {
169166
r.detailsMu.RLock()
170167
for _, feature := range r.config.Features {
171168
if feature != agent_config.FeatureRegistration && feature != agent_config.FeatureNginxConfigAsync {
172-
log.Debugf("synchronizeFeatures: deregistering the feature %s", feature)
169+
log.Debugf("config_reader: deregistering the feature %s", feature)
173170
r.deRegisterPlugin(feature)
174171
}
175172
}

src/plugins/features.go

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -113,25 +113,20 @@ func (f *Features) Process(msg *core.Message) {
113113
plugins := []core.Plugin{}
114114

115115
if msg.Topic() == core.EnableFeature {
116-
log.Debugf("received a request for enabling the feature")
117116
for _, feature := range data.([]string) {
118117
if initFeature, ok := f.featureMap[feature]; ok {
119-
log.Debugf("enabling feature: %s", feature)
120118
featurePlugins := initFeature(feature)
121119
plugins = append(plugins, featurePlugins...)
122120
}
123121
}
124122

125123
err := f.pipeline.Register(f.conf.QueueSize, plugins, nil)
126-
log.Debugf("registring plugins: %v", plugins)
127124
if err != nil {
128125
log.Warnf("Unable to register features: %v", err)
129126
}
130127

131128
for _, plugin := range plugins {
132-
log.Debugf("initializing plugin %s", plugin)
133129
plugin.Init(f.pipeline)
134-
log.Debugf("initialized plugin %s", plugin)
135130
}
136131
} else if msg.Topic() == core.NginxDetailProcUpdate {
137132
f.processes = msg.Data().([]*core.Process)
@@ -140,7 +135,7 @@ func (f *Features) Process(msg *core.Message) {
140135

141136
func (f *Features) enableMetricsFeature(_ string) []core.Plugin {
142137
if !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureMetrics) {
143-
log.Debugf("inside features.go, enabling metrics, throttle and sender")
138+
log.Debugf("features.go: enabling metrics feature")
144139
conf, err := config.GetConfig(f.conf.ClientID)
145140
if err != nil {
146141
log.Warnf("Unable to get agent config, %v", err)
@@ -152,8 +147,6 @@ func (f *Features) enableMetricsFeature(_ string) []core.Plugin {
152147
metricsSender := NewMetricsSender(f.commander, conf)
153148

154149
return []core.Plugin{metrics, metricsThrottle, metricsSender}
155-
} else {
156-
log.Debugf("metrics features.go, already enabled so skipping the enablement")
157150
}
158151
return []core.Plugin{}
159152
}
@@ -195,7 +188,7 @@ func (f *Features) enableMetricsThrottleFeature(_ string) []core.Plugin {
195188
func (f *Features) enableMetricsSenderFeature(_ string) []core.Plugin {
196189
if !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureMetrics) &&
197190
!f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureMetricsSender) {
198-
log.Debugf("inside features.go, enabling metrics_sender")
191+
log.Debugf("features.go: enabling metrics_sender")
199192
conf, err := config.GetConfig(f.conf.ClientID)
200193
if err != nil {
201194
log.Warnf("Unable to get agent config, %v", err)
@@ -205,8 +198,6 @@ func (f *Features) enableMetricsSenderFeature(_ string) []core.Plugin {
205198
metricsSender := NewMetricsSender(f.commander, conf)
206199

207200
return []core.Plugin{metricsSender}
208-
} else {
209-
log.Debugf("inside features.go, already enabled metrics_sender")
210201
}
211202
return []core.Plugin{}
212203
}

src/plugins/metrics_sender.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ package plugins
99

1010
import (
1111
"context"
12-
"github.com/nginx/agent/sdk/v2"
1312
agent_config "github.com/nginx/agent/sdk/v2/agent/config"
1413
"github.com/nginx/agent/sdk/v2/client"
1514
"github.com/nginx/agent/sdk/v2/proto"
@@ -49,7 +48,7 @@ func (r *MetricsSender) Init(pipeline core.MessagePipeInterface) {
4948
r.started.Toggle()
5049
r.pipeline = pipeline
5150
r.ctx = pipeline.Context()
52-
log.Infof("MetricsSender initializing %v %v", r.started, r.readyToSend)
51+
log.Info("MetricsSender initializing")
5352
}
5453

5554
func (r *MetricsSender) Close() {
@@ -91,15 +90,13 @@ func (r *MetricsSender) Process(msg *core.Message) {
9190
switch report := p.(type) {
9291
case *proto.MetricsReport:
9392
message := client.MessageFromMetrics(report)
94-
log.Debugf("metrics_sender sending the metrics report")
9593
err := r.reporter.Send(r.ctx, message)
9694
if err != nil {
9795
log.Errorf("Failed to send MetricsReport: %v", err)
9896
} else {
9997
r.pipeline.Process(core.NewMessage(core.MetricReportSent, nil))
10098
}
10199
case *models.EventReport:
102-
log.Debugf("metrics_sender sending the events report")
103100
err := r.reporter.Send(r.ctx, client.MessageFromEvents(report))
104101
if err != nil {
105102
l := len(report.Events)

0 commit comments

Comments
 (0)