Skip to content

Conversation

oncilla
Copy link
Contributor

@oncilla oncilla commented Sep 18, 2019

Add a metrics doc that outlines the way we instrument the code.


This change is Reviewable

@oncilla oncilla added the c/observability Metrics, logging, tracing label Sep 18, 2019
Copy link
Contributor

@kormat kormat 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 1 files at r2.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @lukedirtwalker and @oncilla)


doc/Metrics.md, line 104 at r1 (raw file):

strucst

s/to/the/


doc/Metrics.md, line 136 at r1 (raw file):

        beacons: prom.NewCounterVec(Namespace, sub, "beacons_total",
            "Total number of beacons originated.", OriginatorLabels.Labels()),
        time: prom.NewCounter(Namespace, sub, "time_seconds_total",

I think "duration" is a better name here (following the example of http_request_duration_seconds in https://prometheus.io/docs/practices/naming/).


doc/Metrics.md, line 184 at r1 (raw file):

func (in *input) BytesWith(l SocketLabels) prometheus.Counter {

This should be PktSize


doc/Metrics.md, line 202 at r1 (raw file):

func (s *Sender) Run(ctx context.Context) {
    l := metrics.KeepaliveLabel{IfID: ifid, Result: metrics.ErrNotClassified}

You need to drop ifid from here, and instead set l.Ifid at the top of the loop.


doc/Metrics.md, line 247 at r1 (raw file):

1. Namespace should be one word
1. Subsystem should be one word (if present)
1. Use values that can be search with regex. E.g. prepend `err_` for every error result.

searched

Copy link
Contributor

@kormat kormat 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: all files reviewed, 5 unresolved discussions (waiting on @lukedirtwalker and @oncilla)


doc/Metrics.md, line 202 at r1 (raw file):

Previously, kormat (Stephen Shirley) wrote…

You need to drop ifid from here, and instead set l.Ifid at the top of the loop.

Actually i think you want to move this entire line to the top of the loop.

Copy link
Contributor Author

@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.

Reviewable status: 0 of 1 files reviewed, 5 unresolved discussions (waiting on @kormat and @lukedirtwalker)


doc/Metrics.md, line 104 at r1 (raw file):

Previously, kormat (Stephen Shirley) wrote…
strucst

s/to/the/

Done.


doc/Metrics.md, line 136 at r1 (raw file):

Previously, kormat (Stephen Shirley) wrote…

I think "duration" is a better name here (following the example of http_request_duration_seconds in https://prometheus.io/docs/practices/naming/).

Done.


doc/Metrics.md, line 184 at r1 (raw file):

Previously, kormat (Stephen Shirley) wrote…

This should be PktSize

Done.


doc/Metrics.md, line 202 at r1 (raw file):

Previously, kormat (Stephen Shirley) wrote…

Actually i think you want to move this entire line to the top of the loop.

yes, you're right.
Done.


doc/Metrics.md, line 247 at r1 (raw file):

Previously, kormat (Stephen Shirley) wrote…

searched

Done.

@karampok
Copy link
Contributor


doc/Metrics.md, line 119 at r3 (raw file):

}

func (l *OrigniatorLabels) Labels() []string{

If we export that, then we need a comment so everyone to follow that

@karampok
Copy link
Contributor


doc/Metrics.md, line 114 at r3 (raw file):

// beacon_srv/internal/metrics/originator.go

type OriginatorLabels struct {

Comment for the linter?
Suggestiong
// KeepaliveLabels is used by clients to pass in a safe way labels
// values to prometheus metric types (e.g. counter).

@karampok
Copy link
Contributor


doc/Metrics.md, line 213 at r3 (raw file):

        sentIfids = append(sentIfids, ifid)
        l.Result = metrics.Success
        metrics.Keepalive.Transmit(l).Inc()

Ideally the usage example should be mapped to the example definition. For example what is Transmit? expecting to find somewhere above

@karampok
Copy link
Contributor


doc/Metrics.md, line 80 at r3 (raw file):

import "github.com/scionproto/scion/go/lib/prom"

const Namespace = "bs"

Is there a reason why we need to export it? Then let's agree on a comment

@karampok
Copy link
Contributor


doc/Metrics.md, line 123 at r3 (raw file):

}

func (l *OrigniatorLabels) Values() []string {

there a typo (it was why i could search where is being used :) )

@karampok
Copy link
Contributor


doc/Metrics.md, line 26 at r3 (raw file):

│       │    ├── originator.go
│       │    ├── propagator.go
│       │    └── registrar.go

For completeness, the metric/keepalive should be there also

Copy link
Contributor

@kormat kormat 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 1 files at r3.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @lukedirtwalker and @oncilla)

Copy link
Contributor Author

@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.

Reviewable status: 0 of 1 files reviewed, 6 unresolved discussions (waiting on @karampok, @kormat, @lukedirtwalker, and @oncilla)


doc/Metrics.md, line 80 at r3 (raw file):

Previously, karampok (Konstantinos) wrote…

Is there a reason why we need to export it? Then let's agree on a comment

Done.


doc/Metrics.md, line 114 at r3 (raw file):

Previously, karampok (Konstantinos) wrote…

Comment for the linter?
Suggestiong
// KeepaliveLabels is used by clients to pass in a safe way labels
// values to prometheus metric types (e.g. counter).

Added more generic string.


doc/Metrics.md, line 119 at r3 (raw file):

Previously, karampok (Konstantinos) wrote…

If we export that, then we need a comment so everyone to follow that

This is a trade-off between testability and minimal API design.
see: https://github.com/scionproto/scion/blob/043fdd7da50d946d65d43278979c6955c1f66ae7/go/lib/prom/promtest/promtest.go


doc/Metrics.md, line 123 at r3 (raw file):

Previously, karampok (Konstantinos) wrote…

there a typo (it was why i could search where is being used :) )

Done.


doc/Metrics.md, line 213 at r3 (raw file):

Previously, karampok (Konstantinos) wrote…

Ideally the usage example should be mapped to the example definition. For example what is Transmit? expecting to find somewhere above

Done.

Copy link
Contributor Author

@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.

Reviewable status: 0 of 1 files reviewed, 6 unresolved discussions (waiting on @karampok, @kormat, and @lukedirtwalker)


doc/Metrics.md, line 26 at r3 (raw file):

Previously, karampok (Konstantinos) wrote…

For completeness, the metric/keepalive should be there also

Done.

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 1 files at r4.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @lukedirtwalker)

Copy link
Contributor

@kormat kormat 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 1 files at r4.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @lukedirtwalker)

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: all files reviewed, 2 unresolved discussions (waiting on @lukedirtwalker and @oncilla)


doc/Metrics.md, line 31 at r4 (raw file):

│       │    └── sender.go
│       └── beaconing
│            ├── keepalive.go

this is under metrics, no?


doc/Metrics.md, line 124 at r4 (raw file):

// Labels returns the list of labels.
func (l *OriginatorLabels) Labels() []string{

do we need the *pointer?

@lukedirtwalker lukedirtwalker removed their request for review September 19, 2019 14:37
Copy link
Contributor Author

@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.

Reviewable status: 0 of 1 files reviewed, 2 unresolved discussions (waiting on @karampok and @kormat)


doc/Metrics.md, line 31 at r4 (raw file):

Previously, karampok (Konstantinos) wrote…

this is under metrics, no?

ah, yes.
Done.


doc/Metrics.md, line 124 at r4 (raw file):

Previously, karampok (Konstantinos) wrote…

do we need the *pointer?

we don't have to, but it's best practice to keep the receiver types consistent.
https://golang.org/doc/faq#methods_on_values_or_pointers

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: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @karampok, @kormat, and @oncilla)


doc/Metrics.md, line 124 at r4 (raw file):

Previously, Oncilla wrote…

we don't have to, but it's best practice to keep the receiver types consistent.
https://golang.org/doc/faq#methods_on_values_or_pointers

I would keep both without

Copy link
Contributor Author

@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.

Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @karampok and @kormat)


doc/Metrics.md, line 124 at r4 (raw file):

Previously, karampok (Konstantinos) wrote…

I would keep both without

Done.

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 1 files at r5.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

Add a metrics doc that outlines the way we instrument the code.
@oncilla oncilla merged commit 7c7df84 into scionproto:master Sep 23, 2019
@oncilla oncilla deleted the pub-metrics-gist branch September 23, 2019 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c/observability Metrics, logging, tracing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants