Skip to content

Commit

Permalink
Merge pull request #3784 from tinyspeck/prom-metrics
Browse files Browse the repository at this point in the history
Add support for exporting metrics to Prometheus.
  • Loading branch information
michael-berlin committed Apr 21, 2018
2 parents 5805555 + 9a1fc3f commit 2abc74a
Show file tree
Hide file tree
Showing 71 changed files with 1,795 additions and 861 deletions.
31 changes: 31 additions & 0 deletions go/cmd/vtctld/plugin_prometheusbackend.go
@@ -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
@@ -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
@@ -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
@@ -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
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
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"),
ConnAccept: stats.NewCounter(acceptTag, "Count of connections accepted by the counting listener"),
}
}

Expand Down

0 comments on commit 2abc74a

Please sign in to comment.