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

New metrics package #740

Merged
merged 25 commits into from
May 25, 2020
Merged

New metrics package #740

merged 25 commits into from
May 25, 2020

Conversation

redblom
Copy link
Contributor

@redblom redblom commented May 13, 2020

3 site metrics for now: number of users, number of groups, storage amount in use

@redblom redblom requested a review from labkode as a code owner May 13, 2020 11:45
@labkode
Copy link
Member

labkode commented May 15, 2020

@redblom can you confirm that you can obtain the metrics by doing GET /metrics?

@redblom
Copy link
Contributor Author

redblom commented May 15, 2020

@redblom can you confirm that you can obtain the metrics by doing GET /metrics?

Yes, but only if I let the prometheus service New() function return a promhttp.Handler() like so:
return &svc{prefix: conf.Prefix, h: promhttp.Handler()}, nil
Not with the existing code of the New() function. Then they don't show up between the displayed metrics.
See #727 (comment)

@labkode
Copy link
Member

labkode commented May 15, 2020

@redblom interesting, let me take a look

@@ -31,6 +33,7 @@ import (

func init() {
global.Register("prometheus", New)
fmt.Printf("metrics - %v \n", metrics.NumUsersMeasure.Description())
Copy link
Member

Choose a reason for hiding this comment

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

let's remove this debug line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, yes :)

@labkode
Copy link
Member

labkode commented May 25, 2020

@redblom thanks for the update, only one comment and I can merge

"net/http"
"reva/pkg/metrics"
Copy link
Contributor

Choose a reason for hiding this comment

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

Need to refer to the github repo path, I guess that's why the build isn't passing

Copy link
Member

Choose a reason for hiding this comment

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

Missed that, good catch-up @ishank011

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ishank011 How to resolve this? Exclude prometheus.go modifications from this pull request, and make that a separate pull request after this one is merged?

Copy link
Contributor

Choose a reason for hiding this comment

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

No, just change it to github.com/cs3org/reva/pkg/metrics. Since the remote origin points to the repo itself, it'll resolve it itself.

var (
NumUsersMeasure = stats.Int64("cs3_org_sciencemesh_site_total_num_users", "The total number of users within this site", stats.UnitDimensionless)
NumGroupsMeasure = stats.Int64("cs3_org_sciencemesh_site_total_num_groups", "The total number of groups within this site", stats.UnitDimensionless)
AmountStorageMeasure = stats.Int64("cs3_org_sciencemesh_site_total_amount_storage", "The total amount of storage used within this site", stats.UnitDimensionless)
Copy link
Contributor

Choose a reason for hiding this comment

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

Use stats.UnitBytes here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe only on storage amount ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, just on storage. Github shows the whole blob even if you comment on a single line.

// here we must request the actual number of site users
// for now this is a mockup: a number increasing over time
numUsersCounter += int64(rand.Intn(100))
fmt.Printf("nrUsers = %v \n", numUsersCounter)
Copy link
Contributor

Choose a reason for hiding this comment

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

Output to stdout isn't logged, so I guess we can remove these as well

@@ -53,6 +56,13 @@ func New(m map[string]interface{}, log *zerolog.Logger) (global.Service, error)

view.RegisterExporter(pe)

// register the desired measures' views
view.Register(
Copy link
Contributor

Choose a reason for hiding this comment

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

Check the result of Register as done here and return if there's an error.

@redblom
Copy link
Contributor Author

redblom commented May 25, 2020

@labkode @ishank011 all comments looked after. New commits pushed.

@ishank011
Copy link
Contributor

@redblom looks good! Just can you remove the debug log which @labkode pointed out? Thanks!

@redblom
Copy link
Contributor Author

redblom commented May 25, 2020

@redblom looks good! Just can you remove the debug log which @labkode pointed out? Thanks!

Addressed with a new commit.

@labkode labkode merged commit 1de4b1d into cs3org:master May 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants