-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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 some collector classes for objects that get registered in a CollectorSet #19098
Add some collector classes for objects that get registered in a CollectorSet #19098
Conversation
@@ -139,6 +137,19 @@ export class CollectorSet { | |||
}); | |||
} | |||
|
|||
async bulkFetchUsage() { |
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.
setLogger, | ||
fetch | ||
}; | ||
async fetch() { |
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.
had to move this function into the object literal for context to work
💚 Build Succeeded |
cc @stacey-gammon, since you chimed in about requested that the collector objects be class instances |
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.
What do you think about moving the logger?
|
||
export class Collector { | ||
/* | ||
* @param {String} type.type - property name as the key for the data |
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.
Nitpick: all of these have an extraneous type.
prefix now.
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.
we're adding a server
param before this object in the args, so I'm keeping the prefix but calling it properties
which matches what it's called in UsageCollector
this.init = init; | ||
this.fetch = fetch; | ||
this.cleanup = cleanup; | ||
|
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.
Weird blank line makes this extra field seem special.
* Allows using `server.log('debug', message)` as `this.log.debug(message)`. | ||
* Works for info and warn logs as well. | ||
*/ | ||
setLogger(logger) { |
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.
You could get this without making the Collector
mutable by passing in the server
object to the constructor, then avoid having a custom logger altogether. It would also avoid the implicit requirement that it gets defined after construction.
0ca11a2
to
0aca12d
Compare
++ on it. It wasn't great before because the logger that CollectorSet got was an inline-defined function passed to the constructor.
|
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.
LGTM!
💚 Build Succeeded |
…ctorSet (elastic#19098) * Add some collector classes for objects that get registered in a CollectorSet * comment cleanup * don't pass an inline-defined logger to collectorSet * add a helper logger function so collector has access to logger at construction
Pulled out from #18894
./classes
inplugins/monitoring/server/kibana_monitoring
Collector
, a base class for collection objects, andUsageCollector
, a collector specific to collecting usage statsplugins/monitoring/server/kibana_monitoring/collectors
to use the new Collector class.