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

embed: enable extensive metrics if specified #9108

Merged
merged 1 commit into from
Jan 7, 2018
Merged

embed: enable extensive metrics if specified #9108

merged 1 commit into from
Jan 7, 2018

Conversation

Quentin-M
Copy link
Contributor

Following up on #7030.

The extensive metrics were only enabled for the binary form of etcd, and not when using the embed server. This PR alleviate exactly this.

@@ -523,6 +523,10 @@ func (e *Etcd) serveClients() (err error) {
}

func (e *Etcd) serveMetrics() (err error) {
if e.cfg.Metrics == "extensive" {
Copy link
Contributor

Choose a reason for hiding this comment

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

@Quentin-M can you define this as a const? now extensive string is used at two places.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Aren't those two independent mains / code paths? One for standalone etcd and one for embed. That was my understanding anyways. I noticed that the histograms were not available in the embed case, so made that PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ooooh I am blind as a monkey.. I should have used my brain for that PR.

@xiang90
Copy link
Contributor

xiang90 commented Jan 6, 2018

CI failed with

../vendor/github.com/coreos/etcd/embed/etcd.go:527:3: undefined: grpc_prometheus

@Quentin-M
Copy link
Contributor Author

Quentin-M commented Jan 6, 2018

Sorry about that, forgot to stage the import.

@xiang90
Copy link
Contributor

xiang90 commented Jan 7, 2018

@Quentin-M have you manually tested it again for both binary and embed case(we do not have test coverage on this one from automated test yet unfortunately)?

If yes, then LGTM.

@Quentin-M
Copy link
Contributor Author

Quentin-M commented Jan 7, 2018

Binary

$ git rev-parse --verify HEAD
a535c01050d9241f985ea1ffdba2b4a1fe25ce5
$ docker build -t etcd-ext-metrics .

$ docker run -it --rm -p 2381:2381 etcd-ext-metrics -metrics=extensive -listen-metrics-urls=http://0.0.0.0:2381
$ curl -sS localhost:2381/metrics | grep grpc_server_handling_seconds_bucket | wc -l
     468

$ docker run -it --rm -p 2381:238 etcd-ext-metrics -metrics=basic -listen-metrics-urls=http://0.0.0.0:2381
$ curl -sS localhost:2381/metrics | grep grpc_server_handling_seconds_bucket | wc -l
       0

Embed

// Terrible code, do not use for anything..
package main

import (
	"flag"
	"fmt"
        "net/url"
	"os"
	"os/signal"
	"syscall"

	"github.com/coreos/etcd/embed"
)

func main() {
	metricsURL, _ := url.Parse("http://127.0.0.1:2381")
	metrics := flag.String("metrics", "basic", "basic/extensive")
	flag.Parse()

	cfg := embed.NewConfig()
	cfg.Dir = "/tmp/etcd"
	cfg.ListenMetricsUrls = []url.URL{*metricsURL}
	cfg.Metrics = *metrics
	
	server, err := embed.StartEtcd(cfg)
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	go func() {
		for {
			select {
			case err := <-server.Err():
				fmt.Println(err)
			}
		}
	}()

	<-server.Server.ReadyNotify()
	fmt.Println("Server Ready")

	sigs := make(chan os.Signal, 1)
	signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
	<-sigs
	
	server.Server.Stop()
	server.Close()
}
$ go run embed.go -metrics=basic
$ curl -sS localhost:2381/metrics | grep grpc_server_handling_seconds_bucket | wc -l
     0

$ go run embed.go -metrics=extensive
$ curl -sS localhost:2381/metrics | grep grpc_server_handling_seconds_bucket | wc -l
     468

@xiang90
Copy link
Contributor

xiang90 commented Jan 7, 2018

@gyuho @jpbetz

this needs to be backported to 3.2, 3.3 if possible.

@xiang90 xiang90 merged commit 6f76e46 into etcd-io:master Jan 7, 2018
@Quentin-M Quentin-M deleted the embed_ext_metrics branch January 7, 2018 16:44
Quentin-M added a commit to Quentin-M/etcd-cloud-operator that referenced this pull request Jan 7, 2018
@gyuho
Copy link
Contributor

gyuho commented Jan 7, 2018

@xiang90 Sure, will backport/release next week.

@gyuho
Copy link
Contributor

gyuho commented Jan 8, 2018

fyi, only backport to 3.3, since 3.2 doesn't support metrics URLs

Quentin-M added a commit to Quentin-M/etcd-cloud-operator that referenced this pull request Feb 1, 2018
@marksugar
Copy link

marksugar commented Dec 27, 2018

hello @gyuho ,

I am using the 3.3.10 cluster, but I don't see the ‘grpc_server_handling_seconds_bucket’ indicator in https://etcd.readthedocs.io/en/latest/operate.html#v3-3
Is it replaced or deleted?
thanks

[root@Node ~]# curl -Lks --cert ./server.pem --key ./server-key.pem  https://localhost:2379/metrics|grep grpc_server_handling_seconds_bucket|wc -l
0

@wenjiaswe
Copy link
Contributor

@marksugar
Copy link

@wenjiaswe
ok
I will try。
thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

5 participants