Skip to content

Commit 088a101

Browse files
committed
CP/DP Split: Remove prometheus logger (#3349)
The prometheus logger is no longer needed since we don't collect nginx metrics in the control plane anymore. Also updated agent dependencies to fix the broken build.
1 parent e309f4b commit 088a101

File tree

8 files changed

+58
-134
lines changed

8 files changed

+58
-134
lines changed

go.mod

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,15 @@ module github.com/nginx/nginx-gateway-fabric
33
go 1.24.2
44

55
require (
6-
github.com/fsnotify/fsnotify v1.8.0
7-
github.com/go-kit/log v0.2.1
6+
github.com/fsnotify/fsnotify v1.9.0
87
github.com/go-logr/logr v1.4.2
98
github.com/google/go-cmp v0.7.0
109
github.com/google/uuid v1.6.0
11-
github.com/nginx/agent/v3 v3.0.0-20250120091728-0f0c0e2478aa
10+
github.com/nginx/agent/v3 v3.0.0-20250429163223-735f50381a9e
1211
github.com/nginx/telemetry-exporter v0.1.4
1312
github.com/onsi/ginkgo/v2 v2.23.4
1413
github.com/onsi/gomega v1.37.0
15-
github.com/prometheus/client_golang v1.20.5
16-
github.com/prometheus/common v0.60.1
14+
github.com/prometheus/client_golang v1.22.0
1715
github.com/spf13/cobra v1.9.1
1816
github.com/spf13/pflag v1.0.6
1917
go.opentelemetry.io/otel v1.35.0
@@ -32,15 +30,14 @@ require (
3230
)
3331

3432
require (
35-
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.33.0-20240401165935-b983156c5e99.1 // indirect
33+
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.4-20250130201111-63bb56e20495.1 // indirect
3634
github.com/beorn7/perks v1.0.1 // indirect
3735
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
3836
github.com/cespare/xxhash/v2 v2.3.0 // indirect
3937
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
4038
github.com/emicklei/go-restful/v3 v3.12.0 // indirect
4139
github.com/evanphx/json-patch/v5 v5.9.11 // indirect
4240
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
43-
github.com/go-logfmt/logfmt v0.6.0 // indirect
4441
github.com/go-logr/stdr v1.2.2 // indirect
4542
github.com/go-logr/zapr v1.3.0 // indirect
4643
github.com/go-openapi/jsonpointer v0.21.0 // indirect
@@ -57,15 +54,15 @@ require (
5754
github.com/inconshreveable/mousetrap v1.1.0 // indirect
5855
github.com/josharian/intern v1.0.0 // indirect
5956
github.com/json-iterator/go v1.1.12 // indirect
60-
github.com/klauspost/compress v1.17.11 // indirect
6157
github.com/mailru/easyjson v0.7.7 // indirect
6258
github.com/maxbrunsfeld/counterfeiter/v6 v6.11.2 // indirect
6359
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
6460
github.com/modern-go/reflect2 v1.0.2 // indirect
6561
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
6662
github.com/pkg/errors v0.9.1 // indirect
6763
github.com/prometheus/client_model v0.6.1 // indirect
68-
github.com/prometheus/procfs v0.15.1 // indirect
64+
github.com/prometheus/common v0.62.0 // indirect
65+
github.com/prometheus/procfs v0.16.0 // indirect
6966
github.com/x448/float16 v0.8.4 // indirect
7067
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
7168
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.35.0 // indirect

go.sum

Lines changed: 36 additions & 44 deletions
Large diffs are not rendered by default.

internal/mode/static/log_level_setters.go

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ package static
33
import (
44
"errors"
55

6-
"github.com/go-kit/log"
7-
"github.com/prometheus/common/promlog"
86
"go.uber.org/zap"
97
"go.uber.org/zap/zapcore"
108
)
@@ -63,41 +61,3 @@ func (z zapLogLevelSetter) SetLevel(level string) error {
6361
func (z zapLogLevelSetter) Enabled(level zapcore.Level) bool {
6462
return z.atomicLevel.Enabled(level)
6563
}
66-
67-
// leveledPrometheusLogger is a leveled prometheus logger.
68-
// This interface is required because the promlog.NewDynamic returns an unexported type *logger.
69-
type leveledPrometheusLogger interface {
70-
log.Logger
71-
SetLevel(level *promlog.AllowedLevel)
72-
}
73-
74-
type promLogLevelSetter struct {
75-
logger leveledPrometheusLogger
76-
}
77-
78-
func newPromLogLevelSetter(logger leveledPrometheusLogger) promLogLevelSetter {
79-
return promLogLevelSetter{logger: logger}
80-
}
81-
82-
func newLeveledPrometheusLogger() (leveledPrometheusLogger, error) {
83-
logFormat := &promlog.AllowedFormat{}
84-
85-
if err := logFormat.Set("json"); err != nil {
86-
return nil, err
87-
}
88-
89-
logConfig := &promlog.Config{Format: logFormat}
90-
logger := promlog.NewDynamic(logConfig)
91-
92-
return logger, nil
93-
}
94-
95-
func (p promLogLevelSetter) SetLevel(level string) error {
96-
al := &promlog.AllowedLevel{}
97-
if err := al.Set(level); err != nil {
98-
return err
99-
}
100-
101-
p.logger.SetLevel(al)
102-
return nil
103-
}

internal/mode/static/log_level_setters_test.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,3 @@ func TestZapLogLevelSetter_SetLevel(t *testing.T) {
5858

5959
g.Expect(zapSetter.SetLevel("invalid")).ToNot(Succeed())
6060
}
61-
62-
func TestPromLogLevelSetter_SetLevel(t *testing.T) {
63-
t.Parallel()
64-
g := NewWithT(t)
65-
66-
logger, err := newLeveledPrometheusLogger()
67-
g.Expect(err).ToNot(HaveOccurred())
68-
69-
promSetter := newPromLogLevelSetter(logger)
70-
71-
g.Expect(promSetter.SetLevel("error")).To(Succeed())
72-
g.Expect(promSetter.SetLevel("info")).To(Succeed())
73-
g.Expect(promSetter.SetLevel("debug")).To(Succeed())
74-
75-
g.Expect(promSetter.SetLevel("invalid")).ToNot(Succeed())
76-
}

internal/mode/static/manager.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,7 @@ func StartManager(cfg config.Config) error {
107107
recorderName := fmt.Sprintf("nginx-gateway-fabric-%s", cfg.GatewayClassName)
108108
recorder := mgr.GetEventRecorderFor(recorderName)
109109

110-
promLogger, err := newLeveledPrometheusLogger()
111-
if err != nil {
112-
return fmt.Errorf("error creating leveled prometheus logger: %w", err)
113-
}
114-
115-
logLevelSetter := newMultiLogLevelSetter(newZapLogLevelSetter(cfg.AtomicLevel), newPromLogLevelSetter(promLogger))
110+
logLevelSetter := newMultiLogLevelSetter(newZapLogLevelSetter(cfg.AtomicLevel))
116111

117112
ctx := ctlr.SetupSignalHandler()
118113

tests/go.mod

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ require (
88
github.com/nginx/nginx-gateway-fabric v0.0.0
99
github.com/onsi/ginkgo/v2 v2.23.4
1010
github.com/onsi/gomega v1.37.0
11-
github.com/prometheus/client_golang v1.20.5
12-
github.com/prometheus/common v0.60.1
11+
github.com/prometheus/client_golang v1.22.0
12+
github.com/prometheus/common v0.62.0
1313
github.com/tsenart/vegeta/v12 v12.12.0
1414
k8s.io/api v0.32.3
1515
k8s.io/apiextensions-apiserver v0.32.3
@@ -26,7 +26,7 @@ require (
2626
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
2727
github.com/emicklei/go-restful/v3 v3.12.0 // indirect
2828
github.com/evanphx/json-patch/v5 v5.9.11 // indirect
29-
github.com/fsnotify/fsnotify v1.8.0 // indirect
29+
github.com/fsnotify/fsnotify v1.9.0 // indirect
3030
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
3131
github.com/go-logr/logr v1.4.2 // indirect
3232
github.com/go-openapi/jsonpointer v0.21.0 // indirect
@@ -45,7 +45,6 @@ require (
4545
github.com/influxdata/tdigest v0.0.1 // indirect
4646
github.com/josharian/intern v1.0.0 // indirect
4747
github.com/json-iterator/go v1.1.12 // indirect
48-
github.com/klauspost/compress v1.17.11 // indirect
4948
github.com/mailru/easyjson v0.7.7 // indirect
5049
github.com/miekg/dns v1.1.65 // indirect
5150
github.com/moby/spdystream v0.5.0 // indirect
@@ -56,7 +55,7 @@ require (
5655
github.com/pkg/errors v0.9.1 // indirect
5756
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
5857
github.com/prometheus/client_model v0.6.1 // indirect
59-
github.com/prometheus/procfs v0.15.1 // indirect
58+
github.com/prometheus/procfs v0.16.0 // indirect
6059
github.com/rs/dnscache v0.0.0-20230804202142-fc85eb664529 // indirect
6160
github.com/spf13/pflag v1.0.6 // indirect
6261
github.com/stretchr/testify v1.10.0 // indirect

tests/go.sum

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ github.com/evanphx/json-patch v0.5.2 h1:xVCHIVMUu1wtM/VkR9jVZ45N3FhZfYMMYGorLCR8
1818
github.com/evanphx/json-patch v0.5.2/go.mod h1:ZWS5hhDbVDyob71nXKNL0+PWn6ToqBHMikGIFbs31qQ=
1919
github.com/evanphx/json-patch/v5 v5.9.11 h1:/8HVnzMq13/3x9TPvjG08wUGqBTmZBsCWzjTM0wiaDU=
2020
github.com/evanphx/json-patch/v5 v5.9.11/go.mod h1:3j+LviiESTElxA4p3EMKAB9HXj3/XEtnUf6OZxqIQTM=
21-
github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M=
22-
github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
21+
github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
22+
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
2323
github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E=
2424
github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ=
2525
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
@@ -67,8 +67,8 @@ github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnr
6767
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
6868
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
6969
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
70-
github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc=
71-
github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0=
70+
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
71+
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
7272
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
7373
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
7474
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
@@ -103,14 +103,14 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRI
103103
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
104104
github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g=
105105
github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P1IAHhP5U=
106-
github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
107-
github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
106+
github.com/prometheus/client_golang v1.22.0 h1:rb93p9lokFEsctTys46VnV1kLCDpVZ0a/Y92Vm0Zc6Q=
107+
github.com/prometheus/client_golang v1.22.0/go.mod h1:R7ljNsLXhuQXYZYtw6GAE9AZg8Y7vEW5scdCXrWRXC0=
108108
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
109109
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
110-
github.com/prometheus/common v0.60.1 h1:FUas6GcOw66yB/73KC+BOZoFJmbo/1pojoILArPAaSc=
111-
github.com/prometheus/common v0.60.1/go.mod h1:h0LYf1R1deLSKtD4Vdg8gy4RuOvENW2J/h19V5NADQw=
112-
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
113-
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
110+
github.com/prometheus/common v0.62.0 h1:xasJaQlnWAeyHdUBeGjXmutelfJHWMRr+Fg4QszZ2Io=
111+
github.com/prometheus/common v0.62.0/go.mod h1:vyBcEuLSvWos9B1+CyL7JZ2up+uFzXhkqml0W5zIY1I=
112+
github.com/prometheus/procfs v0.16.0 h1:xh6oHhKwnOJKMYiYBDWmkHqQPyiY40sny36Cmx2bbsM=
113+
github.com/prometheus/procfs v0.16.0/go.mod h1:8veyXUu3nGP7oaCxhX6yeaM5u4stL2FeMXnCqhDthZg=
114114
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
115115
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
116116
github.com/rs/dnscache v0.0.0-20230804202142-fc85eb664529 h1:18kd+8ZUlt/ARXhljq+14TwAoKa61q6dX8jtwOf6DH8=

tests/suite/nginxgateway_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,7 @@ var _ = Describe("NginxGateway", Ordered, Label("functional", "nginxGateway"), f
243243
return false
244244
}
245245

246-
return strings.Contains(
247-
logs,
248-
"\"current\":\"debug\",\"msg\":\"Log level changed\",\"prev\":\"info\"",
249-
)
246+
return strings.Contains(logs, "\"level\":\"debug\"")
250247
}).WithTimeout(timeoutConfig.GetTimeout).
251248
WithPolling(500 * time.Millisecond).
252249
Should(BeTrue())

0 commit comments

Comments
 (0)