From fc88f4fa374f37e38649b951929226706dd2fb8e Mon Sep 17 00:00:00 2001 From: Oliver Tan Date: Wed, 18 Mar 2020 14:05:14 -0700 Subject: [PATCH] sql: fix metric logging for temporary objects cleaner Was benchmarking temporary tables and found we didn't actually log these metrics properly. There was a bit of plumbing that I missed doing. This has been resolved and verified in this PR. Release justification: bug fixes and low-risk updates to new functionality Release note: None --- pkg/server/server.go | 1 + pkg/sql/temporary_schema.go | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/server/server.go b/pkg/server/server.go index 532f457ffdb7..ac881f76f108 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -905,6 +905,7 @@ func NewServer(cfg Config, stopper *stop.Stopper) (*Server, error) { s.temporaryObjectCleaner = sql.NewTemporaryObjectCleaner( s.st, s.db, + s.registry, s.distSQLServer.ServerConfig.SessionBoundInternalExecutorFactory, s.status, s.node.stores.IsMeta1Leaseholder, diff --git a/pkg/sql/temporary_schema.go b/pkg/sql/temporary_schema.go index 4645dfb20ee3..3bc5de7f0254 100644 --- a/pkg/sql/temporary_schema.go +++ b/pkg/sql/temporary_schema.go @@ -387,11 +387,14 @@ func (m *temporaryObjectCleanerMetrics) MetricStruct() {} func NewTemporaryObjectCleaner( settings *cluster.Settings, db *kv.DB, + registry *metric.Registry, makeSessionBoundInternalExecutor sqlutil.SessionBoundInternalExecutorFactory, statusServer serverpb.StatusServer, isMeta1LeaseholderFunc isMeta1LeaseholderFunc, testingKnobs ExecutorTestingKnobs, ) *TemporaryObjectCleaner { + metrics := makeTemporaryObjectCleanerMetrics() + registry.AddMetricStruct(metrics) return &TemporaryObjectCleaner{ settings: settings, db: db, @@ -399,7 +402,7 @@ func NewTemporaryObjectCleaner( statusServer: statusServer, isMeta1LeaseholderFunc: isMeta1LeaseholderFunc, testingKnobs: testingKnobs, - metrics: makeTemporaryObjectCleanerMetrics(), + metrics: metrics, } }