-
Notifications
You must be signed in to change notification settings - Fork 173
bs: refactor propagator/registrar/originator metrics #3207
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
bs: refactor propagator/registrar/originator metrics #3207
Conversation
cbd5071
to
3cb3e3b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 6 of 6 files at r1.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @karampok and @kormat)
go/beacon_srv/internal/beaconing/propagator.go, line 261 at r1 (raw file):
} defer func() { metrics.Beaconing.PropagatorIntfTime(labels).Add(time.Since(time.Now()).Seconds())
that does not work
before it worked because the arguments are evaluated here and the counter was increased after the method has finished.
go/beacon_srv/internal/beaconing/propagator.go, line 290 at r1 (raw file):
p.logger.Error("[beaconing.Propagator] Unable to send packet", "egIfid", egIfid, "err", err) metrics.Beaconing.PropagatorTotalBeacons(labels).Inc()
this should be ErrSend
go/beacon_srv/internal/metrics/beaconing.go, line 97 at r1 (raw file):
} func (e *beaconing) PropagatorTotalRunTime() prometheus.Counter {
hmm, having a lot of Propagator*
smells like you want to split that one out into a new struct.
soon you will have {Propagator,Originator,Registrar}*
for a most of the counters.
ebc550d
to
e2e49b2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 3 of 8 files reviewed, 3 unresolved discussions (waiting on @kormat and @oncilla)
go/beacon_srv/internal/beaconing/propagator.go, line 261 at r1 (raw file):
Previously, Oncilla wrote…
that does not work
before it worked because the arguments are evaluated here and the counter was increased after the method has finished.
Done.
go/beacon_srv/internal/beaconing/propagator.go, line 290 at r1 (raw file):
Previously, Oncilla wrote…
this should be
ErrSend
Done.
go/beacon_srv/internal/metrics/beaconing.go, line 97 at r1 (raw file):
Previously, Oncilla wrote…
hmm, having a lot of
Propagator*
smells like you want to split that one out into a new struct.soon you will have
{Propagator,Originator,Registrar}*
for a most of the counters.
I was not able to find a common name pattern, so split files is done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 5 of 5 files at r2.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @kormat)
d589ceb
to
9683d06
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 10 of 11 files at r3.
Reviewable status: 13 of 14 files reviewed, 10 unresolved discussions (waiting on @karampok and @kormat)
go/beacon_srv/internal/beaconing/originator.go, line 161 at r3 (raw file):
intf := o.cfg.Intfs.Get(o.ifID) if intf == nil { l := metrics.OriginatorLabels{EgIfID: 0, Result: metrics.ErrCreate}
This should probably be it's own error result
Here you can use EgIfID
because it comes from the BS configuration, and not some outside input.
go/beacon_srv/internal/beaconing/originator.go, line 162 at r3 (raw file):
if intf == nil { l := metrics.OriginatorLabels{EgIfID: 0, Result: metrics.ErrCreate} metrics.Originator.Beacons(l)
.Inc()
?
go/beacon_srv/internal/beaconing/originator.go, line 171 at r3 (raw file):
if err != nil { l := metrics.OriginatorLabels{EgIfID: o.ifID, Result: metrics.ErrCreate} metrics.Originator.Beacons(l)
ditto
go/beacon_srv/internal/beaconing/originator.go, line 185 at r3 (raw file):
if err != nil { l := metrics.OriginatorLabels{EgIfID: o.ifID, Result: metrics.ErrSend} metrics.Originator.Beacons(l)
ditto
go/beacon_srv/internal/beaconing/originator.go, line 190 at r3 (raw file):
o.onSuccess(intf) l := metrics.OriginatorLabels{EgIfID: o.ifID, Result: metrics.Success} metrics.Originator.Beacons(l)
ditto
go/beacon_srv/internal/metrics/originator.go, line 41 at r3 (raw file):
type originator struct { originatedBeacons prometheus.CounterVec
should be *prometheus.CounterVec
go/beacon_srv/internal/metrics/originator.go, line 48 at r3 (raw file):
ns, sub := Namespace, "beaconing" return originator{ originatedBeacons: *prom.NewCounterVec(ns, sub, "originated_beacons_total",
do not dereference pointer here
go/beacon_srv/internal/metrics/originator.go, line 50 at r3 (raw file):
originatedBeacons: *prom.NewCounterVec(ns, sub, "originated_beacons_total", "Number of beacons originated", OriginatorLabels{}.Labels()), runtime: prom.NewCounter(ns, sub, "originator_run_durations_seconds_total",
s/durations/duration
go/beacon_srv/internal/metrics/registrar.go, line 77 at r3 (raw file):
func (e *registrar) Beacons(l RegistrarLabels) prometheus.Counter { return e.registeredBeacons.WithLabelValues(l.Values()...) }
missing newline
go/beacon_srv/internal/metrics/registrar.go, line 81 at r3 (raw file):
l := TypeOnlyLabel{SegType: s} return e.runtime.WithLabelValues(l.Values()...) }
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 11 files at r3.
Reviewable status: all files reviewed, 11 unresolved discussions (waiting on @karampok and @kormat)
go/beacon_srv/internal/metrics/originator.go, line 57 at r3 (raw file):
func (e *originator) Runtime() prometheus.Counter { return e.runtime }
missing new line
9683d06
to
30df274
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 11 of 14 files reviewed, 11 unresolved discussions (waiting on @kormat and @oncilla)
go/beacon_srv/internal/beaconing/originator.go, line 161 at r3 (raw file):
Previously, Oncilla wrote…
This should probably be it's own error result
Here you can use
EgIfID
because it comes from the BS configuration, and not some outside input.
Done.
go/beacon_srv/internal/beaconing/originator.go, line 162 at r3 (raw file):
Previously, Oncilla wrote…
.Inc()
?
Done.
go/beacon_srv/internal/beaconing/originator.go, line 171 at r3 (raw file):
Previously, Oncilla wrote…
ditto
Done.
go/beacon_srv/internal/beaconing/originator.go, line 185 at r3 (raw file):
Previously, Oncilla wrote…
ditto
Done.
go/beacon_srv/internal/beaconing/originator.go, line 190 at r3 (raw file):
Previously, Oncilla wrote…
ditto
Done.
go/beacon_srv/internal/metrics/originator.go, line 41 at r3 (raw file):
Previously, Oncilla wrote…
should be
*prometheus.CounterVec
why, is not everything the same?
https://github.com/scionproto/scion/blob/master/go/beacon_srv/internal/beaconing/metrics/metrics.go#L178
or
https://github.com/scionproto/scion/blob/master/go/beacon_srv/internal/metrics/revocation.go#L38
go/beacon_srv/internal/metrics/originator.go, line 48 at r3 (raw file):
Previously, Oncilla wrote…
do not dereference pointer here
same as above
go/beacon_srv/internal/metrics/originator.go, line 50 at r3 (raw file):
Previously, Oncilla wrote…
s/durations/duration
Done.
go/beacon_srv/internal/metrics/originator.go, line 57 at r3 (raw file):
Previously, Oncilla wrote…
missing new line
Done.
go/beacon_srv/internal/metrics/registrar.go, line 77 at r3 (raw file):
Previously, Oncilla wrote…
missing newline
Done.
go/beacon_srv/internal/metrics/registrar.go, line 81 at r3 (raw file):
Previously, Oncilla wrote…
ditto
Done.
086b916
to
34d2e28
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 9 of 14 files reviewed, 11 unresolved discussions (waiting on @kormat and @oncilla)
go/beacon_srv/internal/metrics/originator.go, line 41 at r3 (raw file):
Previously, karampok (Konstantinos) wrote…
why, is not everything the same?
https://github.com/scionproto/scion/blob/master/go/beacon_srv/internal/beaconing/metrics/metrics.go#L178or
https://github.com/scionproto/scion/blob/master/go/beacon_srv/internal/metrics/revocation.go#L38
Done.
go/beacon_srv/internal/metrics/originator.go, line 48 at r3 (raw file):
Previously, karampok (Konstantinos) wrote…
same as above
Done.
64d52c5
to
7263a78
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 6 of 6 files at r4.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @karampok and @kormat)
go/beacon_srv/internal/beaconing/originator.go, line 159 at r4 (raw file):
// originateBeacon originates a beacon on the given ifid. func (o *beaconOriginator) originateBeacon(ctx context.Context) error { labels := metrics.OriginatorLabels{EgIfID: o.ifID, Result: metrics.ErrVerify}
should be metrics.Success
, no?
go/beacon_srv/internal/beaconing/propagator.go, line 268 at r4 (raw file):
"beacon", bseg, "err", err) labels.Result = metrics.ErrCreate metrics.Propagator.Beacons(labels).Inc()
I like WithResults
more, but this is fine too.
go/beacon_srv/internal/metrics/originator.go, line 41 at r3 (raw file):
Previously, karampok (Konstantinos) wrote…
Done.
because of past mistakes :sad:
7263a78
to
df2ef68
Compare
There was a problem hiding this 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 14 files reviewed, 1 unresolved discussion (waiting on @kormat and @oncilla)
go/beacon_srv/internal/beaconing/originator.go, line 159 at r4 (raw file):
Previously, Oncilla wrote…
should be
metrics.Success
, no?
Done.
go/beacon_srv/internal/beaconing/propagator.go, line 268 at r4 (raw file):
Previously, Oncilla wrote…
I like
WithResults
more, but this is fine too.
The label is being used in the defer. So I need to modify that field.
go/beacon_srv/internal/metrics/originator.go, line 41 at r3 (raw file):
Previously, Oncilla wrote…
because of past mistakes :sad:
it's okay, you have saved many mistakes of me ;)
There was a problem hiding this 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: all files reviewed, 1 unresolved discussion (waiting on @karampok and @kormat)
go/beacon_srv/internal/beaconing/propagator.go, line 268 at r4 (raw file):
Previously, karampok (Konstantinos) wrote…
The label is being used in the defer. So I need to modify that field.
ah, I didn't realize.
Maybe add a comment inside the deferred function:
// This captures the labels variable such that it can be modified in the code below
.
dd673a5
to
36823b9
Compare
There was a problem hiding this 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 14 files reviewed, 1 unresolved discussion (waiting on @karampok, @kormat, and @oncilla)
go/beacon_srv/internal/beaconing/propagator.go, line 268 at r4 (raw file):
Previously, Oncilla wrote…
ah, I didn't realize.
Maybe add a comment inside the deferred function:
// This captures the labels variable such that it can be modified in the code below
.
roar as loud as you can 🦁
s/bellow/below , also add period at the end.
36823b9
to
d15c196
Compare
There was a problem hiding this 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 r6.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @kormat)
This commit brings the propagator metrics under the standard metric pattern. The following metrics should be seen at prometheus ``` bs_beaconing_propagated_beacons_total{eg_if_id="1",in_if_id="2",result="ok_success",start_ia="1-ff00:0:130"} 3 bs_beaconing_propagator_errors_total 0 bs_beaconing_propagator_interface_duration_seconds_total{eg_if_id="1",in_if_id="2",result="ok_success",start_ia="1-ff00:0:130"} 0.234 bs_beaconing_propagator_run_duration_seconds_total 0.30425184999999993 ``` Because the code is inside the `internal/beaconing`, the subsystem of the metrics changed to `beaconing`. Also, metrics are not optional anymore. Contributes scionproto#3104
This commit refactors the registrar metrics to fit the standard pattern. ``` bs_beaconing_registered_beacons_total{in_if_id="2",result="ok_success",seg_type="down",start_ia="1-ff00:0:130"} 8 bs_beaconing_registered_beacons_total{in_if_id="2",result="ok_success",seg_type="up",start_ia="1-ff00:0:130"} 7 bs_beaconing_registrar_run_durations_seconds_total{seg_type="down"} 0.381366876 bs_beaconing_registrar_run_durations_seconds_total{seg_type="up"} 0.663474004 ``` Contributes scionproto#3104
This commit refactors the originator metrics to fit the standard pattern. These are the metrics ``` bs_beaconing_originated_beacons_total{eg_if_id="1",result="ok_success"} 3 bs_beaconing_originated_beacons_total{eg_if_id="2",result="ok_success"} 3 bs_beaconing_originated_beacons_total{eg_if_id="3",result="ok_success"} 3 bs_beaconing_originator_run_durations_seconds_total 2.6630264029999995 ``` * Internal error counter was merged with the result within beacon Contributes scionproto#3104
d15c196
to
a543e32
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 3 of 3 files at r7.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @kormat)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status:
complete! all files reviewed, all discussions resolved (waiting on @kormat)
This PR brings the propagator/registrar/originator metrics under the standard metric pattern.
All metrics are under
bs_beaconing
prefix (namespace=bs
, subsystem=beaconing
)Prometheus metrics can be observed by
curling
the metrics endpoint of a BS$ curl -sS 127.0.0.179:30452/metrics |grep bs_beaconing
Contributes #3104
This change is