Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Prometheus stat reporter from queue-proxy #12961

Merged
merged 3 commits into from
Jul 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions cmd/queue/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,6 @@ func main() {
// Report stats on Go memory usage every 30 seconds.
metrics.MemStatsOrDie(ctx)

// Setup reporters and processes to handle stat reporting.
promStatReporter, err := queue.NewPrometheusStatsReporter(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can drop this reporter from the code base

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

env.ServingNamespace, env.ServingConfiguration, env.ServingRevision,
env.ServingPod, reportingPeriod)
if err != nil {
logger.Fatalw("Failed to create stats reporter", zap.Error(err))
}

protoStatReporter := queue.NewProtobufStatsReporter(env.ServingPod, reportingPeriod)

reportTicker := time.NewTicker(reportingPeriod)
Expand All @@ -157,7 +149,6 @@ func main() {
go func() {
for now := range reportTicker.C {
stat := stats.Report(now)
promStatReporter.Report(stat)
protoStatReporter.Report(stat)
}
}()
Expand All @@ -181,7 +172,7 @@ func main() {
mainServer, drain := buildServer(ctx, env, probe, stats, logger, concurrencyendpoint, false)
httpServers := map[string]*http.Server{
"main": mainServer,
"metrics": buildMetricsServer(promStatReporter, protoStatReporter),
"metrics": buildMetricsServer(protoStatReporter),
"admin": buildAdminServer(logger, drain),
}
if env.EnableProfiling {
Expand Down Expand Up @@ -418,9 +409,9 @@ func buildAdminServer(logger *zap.SugaredLogger, drain func()) *http.Server {
}
}

func buildMetricsServer(promStatReporter *queue.PrometheusStatsReporter, protobufStatReporter *queue.ProtobufStatsReporter) *http.Server {
func buildMetricsServer(protobufStatReporter *queue.ProtobufStatsReporter) *http.Server {
metricsMux := http.NewServeMux()
metricsMux.Handle("/metrics", queue.NewStatsHandler(promStatReporter, protobufStatReporter))
metricsMux.Handle("/metrics", queue.NewStatsHandler(protobufStatReporter))
return &http.Server{
Addr: ":" + strconv.Itoa(networking.AutoscalingQueueMetricsPort),
Handler: metricsMux,
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ require (
github.com/gorilla/websocket v1.4.2
github.com/hashicorp/golang-lru v0.5.4
github.com/kelseyhightower/envconfig v1.4.0
github.com/prometheus/client_golang v1.11.1
github.com/prometheus/client_model v0.2.0
github.com/tsenart/vegeta/v12 v12.8.4
go.opencensus.io v0.23.0
go.uber.org/atomic v1.9.0
Expand Down Expand Up @@ -121,6 +119,8 @@ require (
github.com/opencontainers/image-spec v1.0.3-0.20220114050600-8b9d41f48198 // indirect
github.com/openzipkin/zipkin-go v0.3.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.11.1 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.32.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/prometheus/statsd_exporter v0.21.0 // indirect
Expand Down
12 changes: 0 additions & 12 deletions pkg/queue/concurrency_state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,13 +352,6 @@ func BenchmarkConcurrencyStateProxyHandler(b *testing.B) {
baseHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})
stats := netstats.NewRequestStats(time.Now())

promStatReporter, err := NewPrometheusStatsReporter(
"ns", "testksvc", "testksvc",
"pod", reportingPeriod)
if err != nil {
b.Fatal("Failed to create stats reporter:", err)
}

req := httptest.NewRequest(http.MethodPost, "http:https://example.com", nil)
req.Header.Set(netheader.OriginalHostKey, wantHost)

Expand Down Expand Up @@ -387,11 +380,6 @@ func BenchmarkConcurrencyStateProxyHandler(b *testing.B) {
for _, tc := range tests {
reportTicker := time.NewTicker(tc.reportPeriod)

go func() {
for now := range reportTicker.C {
promStatReporter.Report(stats.Report(now))
}
}()
pause := func(*zap.SugaredLogger) {}
resume := func(*zap.SugaredLogger) {}

Expand Down
16 changes: 1 addition & 15 deletions pkg/queue/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ import (
)

const (
wantHost = "a-better-host.com"
reportingPeriod = time.Second
wantHost = "a-better-host.com"
)

func TestHandlerBreakerQueueFull(t *testing.T) {
Expand Down Expand Up @@ -235,13 +234,6 @@ func BenchmarkProxyHandler(b *testing.B) {
baseHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})
stats := netstats.NewRequestStats(time.Now())

promStatReporter, err := NewPrometheusStatsReporter(
"ns", "testksvc", "testksvc",
"pod", reportingPeriod)
if err != nil {
b.Fatal("Failed to create stats reporter:", err)
}

req := httptest.NewRequest(http.MethodPost, "http:https://example.com", nil)
req.Header.Set(netheader.OriginalHostKey, wantHost)

Expand Down Expand Up @@ -270,12 +262,6 @@ func BenchmarkProxyHandler(b *testing.B) {
for _, tc := range tests {
reportTicker := time.NewTicker(tc.reportPeriod)

go func() {
for now := range reportTicker.C {
promStatReporter.Report(stats.Report(now))
}
}()

h := ProxyHandler(tc.breaker, stats, true /*tracingEnabled*/, baseHandler)
b.Run("sequential-"+tc.label, func(b *testing.B) {
resp := httptest.NewRecorder()
Expand Down
145 changes: 0 additions & 145 deletions pkg/queue/prometheus_stats_reporter.go

This file was deleted.

Loading