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

PS: Improve segment registration metrics #3152

Merged
merged 4 commits into from
Sep 19, 2019

Conversation

lukedirtwalker
Copy link
Collaborator

@lukedirtwalker lukedirtwalker commented Sep 16, 2019

Also change pathdb interface to differentiate updates/inserts.
Also change seghandler to provide statistics.

Contributes #3106


This change is Reviewable

Copy link
Contributor

@oncilla oncilla left a comment

Choose a reason for hiding this comment

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

Reviewed 17 of 17 files at r1.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @karampok and @lukedirtwalker)


go/hidden_path_srv/internal/hiddenpathdb/adapter/pathdb_adapter.go, line 64 at r1 (raw file):

// Insert inserts a hidden path segment into the the underlying PathDB
func (rw *readWriter) Insert(ctx context.Context, seg *seg.Meta,

Is the caller not interested in the stats?


go/path_srv/internal/handlers/segreg.go, line 37 at r1 (raw file):

const (
	regLabelType   = "type"

I would prefer this to be in a sub-package handlers/metrics similar to the BS.


go/path_srv/internal/handlers/segreg.go, line 64 at r1 (raw file):

func NewSegRegHandler(args HandlerArgs) infra.Handler {
	regsTotal = prom.NewCounterVec(metrics.Namespace, "", "registrations_total",

This will blow up when we call NewSegRegHandler twice.
But we probably won't do that so 🤷‍♂️


go/path_srv/internal/handlers/segreg.go, line 94 at r1 (raw file):

		regLabelSrc:    "?",
		regLabelResult: regResultErrInt,
	}

you can do defer regsTotal.With(labels).Inc() instead of calling it everywhere.
This works because With just takes the reference of labels. You can still modify the entries afterwards.


go/path_srv/internal/handlers/segreg.go, line 166 at r1 (raw file):

// different types.
func classifySegs(segReg *path_mgmt.SegReg) string {
	segTypes := make(map[string]struct{}, 1)

use proto.PathSegType instead of string

@karampok
Copy link
Contributor


go/lib/infra/modules/seghandler/seghandler.go, line 93 at r1 (raw file):

			verifyErrs, err := h.storeResults(ctx, verifiedUnits, hpGroupID, &result.stats)
			allVerifyErrs = append(allVerifyErrs, verifyErrs...)
			result.early <- result.stats.SegDB.Total()

Who is reading from the the result.early

Copy link
Contributor

@karampok karampok left a comment

Choose a reason for hiding this comment

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

Reviewed 17 of 17 files at r1.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @lukedirtwalker)

Copy link
Collaborator Author

@lukedirtwalker lukedirtwalker left a comment

Choose a reason for hiding this comment

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

Reviewable status: 13 of 27 files reviewed, 6 unresolved discussions (waiting on @karampok and @oncilla)


go/hidden_path_srv/internal/hiddenpathdb/adapter/pathdb_adapter.go, line 64 at r1 (raw file):

Previously, Oncilla wrote…

Is the caller not interested in the stats?

Done.


go/lib/infra/modules/seghandler/seghandler.go, line 93 at r1 (raw file):

Previously, karampok (Konstantinos) wrote…

Who is reading from the the result.early

result.early is given out to users of the lib via result.EarlyTriggerProcessed() so whoever calls that.
Currently it's not used. Sciond used that once to be able to return results to clients earlier.


go/path_srv/internal/handlers/segreg.go, line 37 at r1 (raw file):

Previously, Oncilla wrote…

I would prefer this to be in a sub-package handlers/metrics similar to the BS.

Done.


go/path_srv/internal/handlers/segreg.go, line 64 at r1 (raw file):

Previously, Oncilla wrote…

This will blow up when we call NewSegRegHandler twice.
But we probably won't do that so 🤷‍♂️

Done.


go/path_srv/internal/handlers/segreg.go, line 94 at r1 (raw file):

Previously, Oncilla wrote…

you can do defer regsTotal.With(labels).Inc() instead of calling it everywhere.
This works because With just takes the reference of labels. You can still modify the entries afterwards.

no in the ok case we have to handle it differently because there could theoretically multiple segments.


go/path_srv/internal/handlers/segreg.go, line 166 at r1 (raw file):

Previously, Oncilla wrote…

use proto.PathSegType instead of string

Done.

Copy link
Contributor

@oncilla oncilla left a comment

Choose a reason for hiding this comment

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

Reviewed 13 of 13 files at r2.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @karampok and @lukedirtwalker)


go/lib/prom/promtest/promtest.go, line 28 at r2 (raw file):

// CheckLabelsStruct checks that labels has a Values and Labels method. It also
// checks that Labels returns the struct field names.

labels


go/path_srv/internal/metrics/BUILD.bazel.orig, line 1 at r2 (raw file):

load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

delete


go/path_srv/internal/metrics/metrics.go, line 35 at r2 (raw file):

	RegistrationNew       = "new"
	RegiststrationUpdated = "updated"
	ErrParse              = "err_parse"

this will be a common error


go/path_srv/internal/metrics/metrics.go, line 38 at r2 (raw file):

	ErrInternal           = prom.ErrInternal
	ErrCrypto             = "err_crypto"
	ErrDB                 = "err_db"

this probably too


go/path_srv/internal/metrics/registration.go, line 29 at r2 (raw file):

// regResults lists all possible results for registrations.
var regResults = []string{RegistrationNew, RegiststrationUpdated, ErrCrypto, ErrDB, ErrInternal}

what is this used for?
also it's lying

Copy link
Collaborator Author

@lukedirtwalker lukedirtwalker left a comment

Choose a reason for hiding this comment

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

Reviewable status: 22 of 26 files reviewed, 6 unresolved discussions (waiting on @karampok and @oncilla)


go/lib/prom/promtest/promtest.go, line 28 at r2 (raw file):

Previously, Oncilla wrote…

labels

Done.


go/path_srv/internal/metrics/BUILD.bazel.orig, line 1 at r2 (raw file):

Previously, Oncilla wrote…

delete

Done.


go/path_srv/internal/metrics/metrics.go, line 35 at r2 (raw file):

Previously, Oncilla wrote…

this will be a common error

Done.


go/path_srv/internal/metrics/metrics.go, line 38 at r2 (raw file):

Previously, Oncilla wrote…

this probably too

Done.


go/path_srv/internal/metrics/registration.go, line 29 at r2 (raw file):

Previously, Oncilla wrote…

what is this used for?
also it's lying

for the description below.

@karampok
Copy link
Contributor


go/path_srv/internal/metrics/registration.go, line 29 at r2 (raw file):

Previously, lukedirtwalker (Lukas Vogel) wrote…

for the description below.

I would avoid having that because once you put a new value (e.g. a const in metric.go), then you forget easily to add the on the documentation.
Is it important to be on the documentation?

Copy link
Contributor

@karampok karampok left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 13 files at r2, 4 of 5 files at r3.
Reviewable status: 25 of 26 files reviewed, 6 unresolved discussions (waiting on @lukedirtwalker and @oncilla)


go/lib/prom/promtest/promtest.go, line 29 at r3 (raw file):

// CheckLabelsStruct checks that labels has a Values and Labels method. It also
// checks that labels.Labels() returns the struct field names.
func CheckLabelsStruct(t *testing.T, labels interface{}) {

If we can test using the the reflect pkg then we might be able to have a fixed implementation of the methods. Does that make sense?

@karampok
Copy link
Contributor


go/lib/prom/promtest/promtest.go, line 29 at r3 (raw file):

Previously, karampok (Konstantinos) wrote…

If we can test using the the reflect pkg then we might be able to have a fixed implementation of the methods. Does that make sense?

something like that i have in mind https://github.com/fatih/structs

Copy link
Collaborator Author

@lukedirtwalker lukedirtwalker left a comment

Choose a reason for hiding this comment

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

Reviewable status: 25 of 26 files reviewed, 6 unresolved discussions (waiting on @karampok and @oncilla)


go/lib/prom/promtest/promtest.go, line 29 at r3 (raw file):

Previously, karampok (Konstantinos) wrote…

something like that i have in mind https://github.com/fatih/structs

Yeah, unfortunately we are not allowed to use reflect in non-testing code :sad-panda:

Copy link
Collaborator Author

@lukedirtwalker lukedirtwalker left a comment

Choose a reason for hiding this comment

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

Reviewable status: 25 of 26 files reviewed, 6 unresolved discussions (waiting on @karampok and @oncilla)


go/path_srv/internal/metrics/registration.go, line 29 at r2 (raw file):

Previously, karampok (Konstantinos) wrote…

I would avoid having that because once you put a new value (e.g. a const in metric.go), then you forget easily to add the on the documentation.
Is it important to be on the documentation?

I don't know. It was in the request: #3106 (comment)

Copy link
Contributor

@oncilla oncilla left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 5 files at r3.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @karampok)


go/path_srv/internal/metrics/registration.go, line 29 at r2 (raw file):

Previously, lukedirtwalker (Lukas Vogel) wrote…

I don't know. It was in the request: #3106 (comment)

🤷‍♂️

Copy link
Contributor

@karampok karampok left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved


go/path_srv/internal/metrics/registration.go, line 29 at r2 (raw file):

Previously, Oncilla wrote…

🤷‍♂️

if it is a requirement

Also change pathdb interface to differentiate updates/inserts.
Also change seghandler to provide statistics.

Contributes scionproto#3106
Copy link
Contributor

@oncilla oncilla left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 2 files at r4.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

Copy link
Contributor

@oncilla oncilla left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@lukedirtwalker lukedirtwalker merged commit 99f78f0 into scionproto:master Sep 19, 2019
@lukedirtwalker lukedirtwalker deleted the pubPSMetrics branch September 19, 2019 14:23
@kormat kormat mentioned this pull request Sep 20, 2019
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants