-
Notifications
You must be signed in to change notification settings - Fork 262
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
Add metrics of gophercloud (POST,UPDATE and DELETE) actions #863
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jichenjc The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
974ab16
to
f306230
Compare
@seanschneeweiss @chrischdi Maybe one of you has some bandwitdh to review? :) |
I can't create a local env (because difference between 0.3.4 and master)
@sbueringer @hidekazuna please help review , thanks |
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.
ObserveRequest
always returns the same error which we give to it. So when using it there should be a separate if err != nil
part, instead we should use what we had before to not loose context :-)
I think there are lots of more places where we call gophercloud / the OpenStack API to observe metrics.
For example:
- https://github.com/kubernetes-sigs/cluster-api-provider-openstack/blob/master/pkg/cloud/services/compute/availabilityzone.go#L26
- https://github.com/kubernetes-sigs/cluster-api-provider-openstack/blob/master/pkg/cloud/services/compute/instance.go#L395
I think almost all occurencies can be found using, but ignore the highlighted Extract functions:
for l in $(grep . -r -e "github.com/gophercloud" | sed -E -e 's/:\t+/;/g' -e 's/"$//g' -e 's/;"/;/g' -e 's/ //g' | grep -v go.sum | grep -v go.mod | grep -v 'test/e2e'); do
FILE="$(cut -d ";" -f 1 <<< $l)"
PKG="$(cut -d ";" -f 2 <<< $l | cut -d '"' -f 1 | tr '/' ' ' | awk '{print $NF}')"
echo " # $FILE"
cat $FILE | grep -e "$PKG\.[A-Z][a-zA-Z]+\(" -E -A2 -B2
done
@@ -66,9 +67,14 @@ type OpenStackClusterReconciler struct { | |||
func (r *OpenStackClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ ctrl.Result, reterr error) { | |||
log := ctrl.LoggerFrom(ctx) | |||
|
|||
mc := metrics.NewMetricPrometheusContext("snapshot", "create") |
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.
I don't think we are doing a snapshot create
here :-) also the r.Client.Get is no openstack request?!
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.
it's my debug code ... sorry to forget remove them
if mc.ObserveRequest(err) != nil { | ||
return nil, err | ||
} | ||
|
||
if err != nil { |
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.
if mc.ObserveRequest(err) != nil { | |
return nil, err | |
} | |
if err != nil { | |
if mc.ObserveRequest(err) != nil { |
ObserveRequest just exposes a metric and does return the very same error.
if mc.ObserveRequest(err) != nil { | ||
return ports.Port{}, err | ||
} | ||
if err != nil { |
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.
if mc.ObserveRequest(err) != nil { | |
return ports.Port{}, err | |
} | |
if err != nil { | |
if mc.ObserveRequest(err) != nil { |
mc := metrics.NewMetricPrometheusContext("server", "create") | ||
|
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.
mc := metrics.NewMetricPrometheusContext("server", "create") | |
mc := metrics.NewMetricPrometheusContext("server", "create") |
if mc.ObserveRequest(err) != nil { | ||
return err | ||
} | ||
if err != nil { |
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.
if mc.ObserveRequest(err) != nil { | |
return err | |
} | |
if err != nil { | |
if mc.ObserveRequest(err) != nil { |
if mc.ObserveRequest(err) != nil { | ||
return nil, err | ||
} | ||
if err != nil { |
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.
if mc.ObserveRequest(err) != nil { | |
return nil, err | |
} | |
if err != nil { | |
if mc.ObserveRequest(err) != nil { |
if mc.ObserveRequest(err) != nil { | ||
return err | ||
} | ||
if err != nil { |
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.
if mc.ObserveRequest(err) != nil { | |
return err | |
} | |
if err != nil { | |
if mc.ObserveRequest(err) != nil { |
if mc.ObserveRequest(err) != nil { | ||
return nil, err | ||
} | ||
if err != nil { |
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.
if mc.ObserveRequest(err) != nil { | |
return nil, err | |
} | |
if err != nil { | |
if mc.ObserveRequest(err) != nil { |
if mc.ObserveRequest(err) != nil { | ||
return nil, err | ||
} | ||
if err != nil { |
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.
if mc.ObserveRequest(err) != nil { | |
return nil, err | |
} | |
if err != nil { | |
if mc.ObserveRequest(err) != nil { |
|
||
if mc.ObserveRequest(err) != nil { | ||
return err | ||
} | ||
if err != nil { |
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.
if mc.ObserveRequest(err) != nil { | |
return err | |
} | |
if err != nil { | |
if mc.ObserveRequest(err) != nil { |
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.
thanks for the comments, will check other possible metrics
d806f20
to
89836fe
Compare
/test pull-cluster-api-provider-openstack-e2e-test |
740f78d
to
516b4e1
Compare
@chrischdi I checked again the question you posted above for additional metrics .. |
I think it would be helpful to also have a metric for the get / list requests. It is also done like this in https://github.com/kubernetes/cloud-provider-openstack . These requests could also fail and another use-case for me would be checking how many requests are done to OpenStack to not overload it. |
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.
Thank you for adding all the metrics :) I would also suggest to add metrics for the get/list and delete requests.
@chrischdi @seanschneeweiss thanks for the review most comments addressed |
661a547
to
74fec38
Compare
@jichenjc I'll take another look. Let's please merge this ASAP afterwards. With every refactoring PR we merge in the meantime we could introduce new bugs here. So it's a lot of effort to review it all over again to make sure we're safe :/ |
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.
last round of nits
@@ -514,8 +520,9 @@ func (s *Service) createRule(r infrav1.SecurityGroupRule) (infrav1.SecurityGroup | |||
SecGroupID: r.SecurityGroupID, | |||
} | |||
s.logger.V(6).Info("Creating rule", "Description", r.Description, "Direction", dir, "PortRangeMin", r.PortRangeMin, "PortRangeMax", r.PortRangeMax, "Proto", proto, "etherType", etherType, "RemoteGroupID", r.RemoteGroupID, "RemoteIPPrefix", r.RemoteIPPrefix, "SecurityGroupID", r.SecurityGroupID) | |||
mc := metrics.NewMetricPrometheusContext("security_group_rules", "create") |
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.
mc := metrics.NewMetricPrometheusContext("security_group_rules", "create") | |
mc := metrics.NewMetricPrometheusContext("security_group_rule", "create") |
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.
searched and no other plural anymore ..
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.
Thx!
/lgtm |
/hold cancel |
/hold @jichenjc you have to squash locally + push -force before. Otherwise we will get 8 commits on master. |
my bad, another mistake ... not a lucky day for me |
Squashed :-) /lgtm |
@jichenjc No problem :). /lgtm |
/lgtm Thank you. |
/hold cancel |
What this PR does / why we need it:
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Part of #856
Special notes for your reviewer:
TODOs:
/hold