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

Read metrics from file (v2) #1118

Merged
merged 43 commits into from
Sep 14, 2020
Merged

Conversation

redblom
Copy link
Contributor

@redblom redblom commented Aug 25, 2020

@ishank011 : Metrics initializes itself, performs periodic data recording, uses sharedconfig only.
Example json metrics data file for the currently expected metrics:
{ "cs3_org_sciencemesh_site_total_num_users": 7000, "cs3_org_sciencemesh_site_total_num_groups": 550, "cs3_org_sciencemesh_site_total_amount_storage": 1080001003 }

@redblom redblom requested a review from labkode as a code owner August 25, 2020 08:02
@redblom redblom mentioned this pull request Aug 25, 2020
Copy link
Contributor

@ishank011 ishank011 left a comment

Choose a reason for hiding this comment

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

Hi @redblom. Thanks for the change. A few comments:

  • The initDataDriver method is called for each metrics refresh. Let's refactor it so that it's called only when initializing.
  • For logging please initialize the logger like this.
  • The if else construct for choosing the driver won't scale. Can you follow the registry system we follow for other packages?
  • The file needs to be re-read on each refresh.

@redblom
Copy link
Contributor Author

redblom commented Aug 31, 2020

. The initDataDriver method is called for each metrics refresh. Let's refactor it so that it's called only when initializing.
Actually I wanted to do that but the shared config is not there yet when no specific config has been initialized. Only then the shared config gets decoded. I don't know how to solve this in another way.

@@ -1,7 +1,12 @@
[shared]
jwt_secret = "Pive-Fumkiu4"
# one of dummy, json.
Copy link
Contributor

Choose a reason for hiding this comment

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

These need to be defined for the service, not shared conf.


// Unprotected returns all endpoints that can be queried without prior authorization.
func (s *svc) Unprotected() []string {
return []string{"/"}
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove the "/"

// Init sets sane defaults
func (c *Config) Init() {
if c.Prefix == "" {
c.Prefix = "metrics"
Copy link
Contributor

Choose a reason for hiding this comment

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

metrics is supposed to be the prefix for the prometheus service. This would cause conflicts.


// Prefix returns the main endpoint of this service.
func (s *svc) Prefix() string {
return s.prefix
Copy link
Contributor

Choose a reason for hiding this comment

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

Return an empty string


var drivers map[string]reader.Reader // map key is driver type name

func init() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

@redblom redblom Sep 9, 2020

Choose a reason for hiding this comment

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

@ishank011 Ok, I do the loading like in that registry as well. That is better.
Do you agree with the GetDriver() method or do you want me to 'copy' https://github.com/cs3org/reva/blob/master/pkg/ocm/invite/manager/registry/registry.go ? Like exactly like that?


// Config holds the config options that need to be passed down to the metrics reader(driver)
type Config struct {
Prefix string `mapstructure:"prefix"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove Prefix


// GetNumUsers returns the number of site users
func (d *MetricsJSONDriver) GetNumUsers() int64 {
return readJSON(d).NumUsers
Copy link
Contributor

Choose a reason for hiding this comment

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

We're reading the file each time for all the three metrics, but they would be accessed simultaneously. Can you see if we can prevent reading the file three times?

Copy link
Contributor Author

@redblom redblom Sep 9, 2020

Choose a reason for hiding this comment

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

@ishank011 Hmm, that's like the initial implementation where the whole pkg got initialized on each metrics server call and all methods where read in one go. It is my recollection that it was decided to changed it to be like this.
I have to think about this.
Maybe we can leave it for now?

@ishank011 ishank011 merged commit 0f4b2cf into cs3org:master Sep 14, 2020
SamuAlfageme pushed a commit to SamuAlfageme/reva that referenced this pull request Sep 15, 2020
SamuAlfageme pushed a commit to SamuAlfageme/reva that referenced this pull request Sep 23, 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.

2 participants