Skip to content
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
31 changes: 31 additions & 0 deletions go/cmd/vtctld/plugin_prometheusbackend.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
Copyright 2018 Google Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package main

// This plugin imports Prometheus to allow for instrumentation
// with the Prometheus client library

import (
"vitess.io/vitess/go/stats/prometheusbackend"
"vitess.io/vitess/go/vt/servenv"
)

func init() {
servenv.OnRun(func() {
prometheusbackend.Init("vtctld")
})
}
31 changes: 31 additions & 0 deletions go/cmd/vtgate/plugin_prometheusbackend.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
Copyright 2018 Google Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package main

// This plugin imports Prometheus to allow for instrumentation
// with the Prometheus client library

import (
"vitess.io/vitess/go/stats/prometheusbackend"
"vitess.io/vitess/go/vt/servenv"
)

func init() {
servenv.OnRun(func() {
prometheusbackend.Init("vtgate")
})
}
31 changes: 31 additions & 0 deletions go/cmd/vttablet/plugin_prometheusbackend.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
Copyright 2018 Google Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package main

// This plugin imports Prometheus to allow for instrumentation
// with the Prometheus client library

import (
"vitess.io/vitess/go/stats/prometheusbackend"
"vitess.io/vitess/go/vt/servenv"
)

func init() {
servenv.OnRun(func() {
prometheusbackend.Init("vttablet")
})
}
31 changes: 31 additions & 0 deletions go/cmd/vtworker/plugin_prometheusbackend.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
Copyright 2018 Google Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package main

// This plugin imports Prometheus to allow for instrumentation
// with the Prometheus client library

import (
"vitess.io/vitess/go/stats/prometheusbackend"
"vitess.io/vitess/go/vt/servenv"
)

func init() {
servenv.OnRun(func() {
prometheusbackend.Init("vtworker")
})
}
8 changes: 4 additions & 4 deletions go/mysql/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ const (

var (
// Metrics
timings = stats.NewTimings("MysqlServerTimings")
connCount = stats.NewInt("MysqlServerConnCount")
connAccept = stats.NewInt("MysqlServerConnAccepted")
connSlow = stats.NewInt("MysqlServerConnSlow")
timings = stats.NewTimings("MysqlServerTimings", "MySQL server timings")
connCount = stats.NewGauge("MysqlServerConnCount", "Active MySQL server connections")
connAccept = stats.NewCounter("MysqlServerConnAccepted", "Connections accepted by MySQL server")
connSlow = stats.NewCounter("MysqlServerConnSlow", "Connections that took more than the configured mysql_slow_connect_warn_threshold to establish")
)

// A Handler is an interface used by Listener to send queries.
Expand Down
7 changes: 4 additions & 3 deletions go/proc/counting_listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ import (

type CountingListener struct {
net.Listener
ConnCount, ConnAccept *stats.Int
ConnCount *stats.Gauge
ConnAccept *stats.Counter
}

type countingConnection struct {
Expand All @@ -37,8 +38,8 @@ type countingConnection struct {
func Published(l net.Listener, countTag, acceptTag string) net.Listener {
return &CountingListener{
Listener: l,
ConnCount: stats.NewInt(countTag),
ConnAccept: stats.NewInt(acceptTag),
ConnCount: stats.NewGauge(countTag, "Active connections accepted by counting listener"),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It has always been confusing to me that ConnCount and ConnAccepted don't have more descriptive names, and these generic descriptions don't help either :)

While I'm happy to defer this to a subsequent improvement, IMO we should change the proc.Listen API to include a description string and pass that here as well along with the countTag.

Then these would be:

ConnCount: stats.NewGauge(countTag, fmt.Sprintf("Active %s connections", description)),
ConnAccept: stats.NewCounter(countTag, fmt.Sprintf("Accepted %s connections", description)),

Since these are only used for HTTP, we would then change servenv.Run to include "HTTP" as the description string.

I also think we would be well served to rename the generic metric names as well to be HTTPConnCount and HTTPConnAccepted but that would break backwards compatibility. @sougou / @michael-berlin thoughts on this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed, but let's do it in a follow-on?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yup. Would still like to hear from @sougou and @michael-berlin about the backwards-incompatibility of this proposed change.

ConnAccept: stats.NewCounter(acceptTag, "Count of connections accepted by the counting listener"),
}
}

Expand Down
Loading