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

Expose metrics to report time taken in fetch/template/deploy phase of app, pkgi, pkgr #1415

Merged
merged 9 commits into from
Jan 27, 2024

Conversation

sethiyash
Copy link
Contributor

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #

Does this PR introduce a user-facing change?


Additional Notes for your reviewer:

Review Checklist:
  • Follows the developer guidelines
  • Relevant tests are added or updated
  • Relevant docs in this repo added or updated
  • Relevant carvel.dev docs added or updated in a separate PR and there's
    a link to that PR
  • Code is at least as readable and maintainable as it was before this
    change

Additional documentation e.g., Proposal, usage docs, etc.:


Signed-off-by: sethiyash <yashsethiya97@gmail.com>
Signed-off-by: sethiyash <yashsethiya97@gmail.com>
pkg/app/app.go Outdated Show resolved Hide resolved
Copy link
Member

@prembhaskal prembhaskal left a comment

Choose a reason for hiding this comment

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

inline comments.

@sethiyash sethiyash force-pushed the expose-metrics branch 2 times, most recently from 00093da to 196bc45 Compare December 7, 2023 17:59
Signed-off-by: sethiyash <yashsethiya97@gmail.com>
pkg/app/app_factory.go Outdated Show resolved Hide resolved
pkg/app/app_fetch.go Outdated Show resolved Hide resolved
pkg/app/app_reconcile.go Outdated Show resolved Hide resolved
pkg/pkgrepository/crd_app.go Outdated Show resolved Hide resolved
pkg/pkgrepository/app_reconcile_test.go Outdated Show resolved Hide resolved
@rohitagg2020
Copy link
Contributor

Import statements in many files are not as per our convention. Please check them.

Signed-off-by: sethiyash <yashsethiya97@gmail.com>
Copy link
Member

@prembhaskal prembhaskal left a comment

Choose a reason for hiding this comment

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

LGTM

@kumaritanushree
Copy link
Contributor

LGTM

cmd/controller/run.go Outdated Show resolved Hide resolved
Signed-off-by: sethiyash <yashsethiya97@gmail.com>
cmd/controller/run.go Outdated Show resolved Hide resolved
pkg/app/app.go Outdated Show resolved Hide resolved
// Reconcile is not expected to be called concurrently
func (a *App) Reconcile(force bool) (reconcile.Result, error) {
defer a.flushUpdateStatus("app reconciled")

var err error

a.appMetrics.InitMetrics(a.Name(), a.Namespace())
a.appMetrics.ReconcileCountMetrics.InitMetrics(appResourceType, a.Name(), a.Namespace())
Copy link
Member

Choose a reason for hiding this comment

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

Why not use a.Name() itself? Or maybe Kind() if we don't want to use name.
Same for package install and package repo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is no a.Kind() available here

Copy link
Contributor

@neil-hickey neil-hickey Jan 9, 2024

Choose a reason for hiding this comment

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

The kind for an app shouldn't be a constant in a reconciler. It should live with the object model.

In this case, our app struct probably ought to have another function return the kind, rather than a constant.

I think @praveenrewar 's original comment is my thinking also. Just because the data we need isn't there - doesn't mean it can't be. We need it to be, so let's just make it available.

pkg/app/app_deploy.go Outdated Show resolved Hide resolved
pkg/app/app_fetch.go Outdated Show resolved Hide resolved
pkg/app/app_reconcile.go Outdated Show resolved Hide resolved
pkg/app/crd_app.go Outdated Show resolved Hide resolved
Signed-off-by: sethiyash <yashsethiya97@gmail.com>
config/config/deployment.yml Outdated Show resolved Hide resolved
pkg/app/app_reconcile_test.go Outdated Show resolved Hide resolved
Signed-off-by: sethiyash <yashsethiya97@gmail.com>
cmd/controller/run.go Show resolved Hide resolved
pkg/app/app_reconcile_test.go Show resolved Hide resolved
Copy link
Member

@praveenrewar praveenrewar left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@neil-hickey neil-hickey left a comment

Choose a reason for hiding this comment

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

Overall LGTM, I added a few nit things. And one suggestion: In our tests we do this pattern of metrics.New() everywhere, which is kinda silly because it's never used and we allocate all this memory to build the structures. It's just test code so it's not the end of the world, just something to consider / think about.

One concern is that we don't have any tests for this stuff at all (in this PR it seems). Given that the code is mostly registering metrics, it likely ought to be an e2e test. Even a simple one to just validate the a small sample of metrics is actually exposed / collected.

How do we know it works? :) And how do I as the reviewer?

pkg/app/app_reconcile.go Outdated Show resolved Hide resolved
pkg/app/app_reconcile.go Outdated Show resolved Hide resolved
pkg/pkgrepository/app_reconcile.go Show resolved Hide resolved
pkg/pkgrepository/app_reconcile.go Show resolved Hide resolved
pkg/pkgrepository/app_reconcile.go Outdated Show resolved Hide resolved
pkg/metrics/reconcile_count_metrics.go Outdated Show resolved Hide resolved
pkg/metrics/reconcile_count_metrics.go Outdated Show resolved Hide resolved
pkg/packageinstall/packageinstall.go Outdated Show resolved Hide resolved
@sethiyash sethiyash force-pushed the expose-metrics branch 8 times, most recently from a81a775 to 301d354 Compare January 17, 2024 05:25
Signed-off-by: sethiyash <yashsethiya97@gmail.com>
Signed-off-by: Yash Sethiya <ysethiya@ysethiya4MD6M.vmware.com>
Copy link
Member

@praveenrewar praveenrewar left a comment

Choose a reason for hiding this comment

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

LGTM (Apart from the 2 nits)

test/e2e/kappcontroller/metrics_test.go Show resolved Hide resolved
test/e2e/kappcontroller/metrics_test.go Outdated Show resolved Hide resolved
Signed-off-by: Yash Sethiya <ysethiya@ysethiya4MD6M.vmware.com>
@sethiyash sethiyash merged commit e82ab40 into develop Jan 27, 2024
10 checks passed
@praveenrewar praveenrewar deleted the expose-metrics branch February 5, 2024 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

6 participants