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

update registration of the metrics to work in techpreview too #808

Merged
merged 3 commits into from Jul 22, 2023

Conversation

tremes
Copy link
Contributor

@tremes tremes commented Jul 13, 2023

This PR updates the logic of Prometheus metrics registration to work in techpreview (when data gathering runs in a job) as well. The registration and incrementation of the insightsclient_request_send_total metric is moved from the uploader and the metric in the techpreview is updated based on the conditions of the latest datagather CR (which provides information including HTTP status code in its conditions).

This also removes the insightsclient_last_gather_time metric. This data is available in the Insights CRs.

This also removes

Categories

  • Bugfix
  • Data Enhancement
  • Feature
  • Backporting
  • Others (CI, Infrastructure, Documentation)

Sample Archive

no new data

Documentation

Unit Tests

Privacy

Yes. There are no sensitive data in the newly collected information.

Changelog

Breaking Changes

No

References

https://issues.redhat.com/browse/???
https://access.redhat.com/solutions/???

@openshift-ci
Copy link

openshift-ci bot commented Jul 13, 2023

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci openshift-ci bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jul 13, 2023
@tremes tremes force-pushed the gather-job-metrics branch 2 times, most recently from 0859f8e to 78396fc Compare July 14, 2023 08:21
@tremes tremes marked this pull request as ready for review July 14, 2023 09:31
@openshift-ci openshift-ci bot requested review from ncaak and rluders July 14, 2023 09:32
@tremes tremes changed the title WIP move metrics registration for techpreview update registration of the metrics to work in techpreview too Jul 17, 2023
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 17, 2023
@tremes
Copy link
Contributor Author

tremes commented Jul 17, 2023

/retest

@tremes
Copy link
Contributor Author

tremes commented Jul 17, 2023

/test e2e-gcp-ovn-techpreview

2 similar comments
@tremes
Copy link
Contributor Author

tremes commented Jul 18, 2023

/test e2e-gcp-ovn-techpreview

@tremes
Copy link
Contributor Author

tremes commented Jul 18, 2023

/test e2e-gcp-ovn-techpreview

apierrors "k8s.io/apimachinery/pkg/api/errors"
)

func (c *Client) SendAndGetID(ctx context.Context, endpoint string, source Source) (string, error) {
func (c *Client) SendAndGetID(ctx context.Context, endpoint string, source Source) (string, int, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm having some concerns about confusing use of second return parameter. This is part of the same nit with upcoming comments. I prefer to leave the comments inline to avoid more confusion :D

As a summary, I'd assign a variable to default returning code, to improve readability. Then later use the same codes as parameters for a control function, moving the transformation of the data to that function itself. That way code is more straightforward IMHO, and avoids confusion on why transforming the data, why sending a 0 as a string, 0 int returnings with no context, etc...

I think it's a simple change but that improves readability and avoids any confusion on why or what the data is used for.

Please, check upcoming messages 👇

cv, err := c.GetClusterVersion()
if apierrors.IsNotFound(err) {
return "", ErrWaitingForVersion
return "", 0, ErrWaitingForVersion
Copy link
Contributor

Choose a reason for hiding this comment

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

var or const 0 as defaultCode to guide about what the value will meant in advance

counterRequestSend.WithLabelValues(c.metricsName, "0").Inc()
return "", fmt.Errorf("unable to build request to connect to Insights server: %v", err)
// if the request is not build, for example because of invalid endpoint,(maybe some problem with DNS), we want to have record about it in metrics as well.
insights.IncrementCounterRequestSend("0")
Copy link
Contributor

Choose a reason for hiding this comment

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

Send defaultCode (variable or const for default 0 value) as it is, the data transformation should take place inside IncrementCounterRequestSend function

Copy link
Contributor

Choose a reason for hiding this comment

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

e.g. insights.IncrementCounterRequestSend(defaultCode)

I think it's more clear what the 0 means, without even reading the comment above.

@@ -58,36 +59,36 @@ func (c *Client) SendAndGetID(ctx context.Context, endpoint string, source Sourc
}
}()

counterRequestSend.WithLabelValues(c.metricsName, strconv.Itoa(resp.StatusCode)).Inc()
insights.IncrementCounterRequestSend(strconv.Itoa(resp.StatusCode))
Copy link
Contributor

Choose a reason for hiding this comment

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

Send directly status code, same as before the transformation will take place inside IncrementCounterRequestSend
e.g. insights.IncrementCounterRequestSend(resp.StatusCode)

MustRegisterMetrics(RecommendationCollector, counterRequestSend)
}

func IncrementCounterRequestSend(status string) {
Copy link
Contributor

Choose a reason for hiding this comment

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

change signature to accept int instead. Http codes type is int and we can play with a default value of the same type. Then before sending the data, transform it with strconv or fmt as string.

Copy link
Contributor

@ncaak ncaak left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jul 18, 2023
@openshift-ci
Copy link

openshift-ci bot commented Jul 18, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ncaak, tremes

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ncaak
Copy link
Contributor

ncaak commented Jul 18, 2023

/test e2e

@ncaak
Copy link
Contributor

ncaak commented Jul 19, 2023

/test e2e-agnostic-upgrade

@ncaak
Copy link
Contributor

ncaak commented Jul 19, 2023

/test e2e-gcp-ovn-techpreview

@openshift-ci
Copy link

openshift-ci bot commented Jul 19, 2023

@tremes: all tests passed!

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@tremes
Copy link
Contributor Author

tremes commented Jul 22, 2023

techpreview testsuite passed including the basic metrics test. I am adding the qe-approved label myself.
/label qe-approved

@openshift-ci openshift-ci bot added the qe-approved Signifies that QE has signed off on this PR label Jul 22, 2023
@openshift-merge-robot openshift-merge-robot merged commit 352c934 into openshift:master Jul 22, 2023
9 checks passed
@tremes tremes deleted the gather-job-metrics branch July 27, 2023 07:11
JoaoFula pushed a commit to JoaoFula/insights-operator that referenced this pull request Jan 23, 2024
…ift#808)

* update registration of the metrics to work in techpreview too

* updates after review

* forgotten zeroes...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. qe-approved Signifies that QE has signed off on this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants