Skip to content

[Telemetry] move x-pack/monitoring collector classes to src/server/usage#20248

Merged
tsullivan merged 10 commits intoelastic:masterfrom
tsullivan:usage/collector-set-to-core
Jul 9, 2018
Merged

[Telemetry] move x-pack/monitoring collector classes to src/server/usage#20248
tsullivan merged 10 commits intoelastic:masterfrom
tsullivan:usage/collector-set-to-core

Conversation

@tsullivan
Copy link
Copy Markdown
Member

@tsullivan tsullivan commented Jun 26, 2018

Part of Meta issue #20393
Closes #19534
Following along on #19691

Most of these code changes have already been reviewed. This PR moves the CollectorSet classes to src/server/usage and registers the service differently. The service is longer dependent on the Monitoring plugin, so consumers should have it easier since they don't have to watch any plugin status before registering their collectors.

Comments about needing to use the saved object client are partially dependent on #19662

@tsullivan tsullivan self-assigned this Jun 26, 2018
@tsullivan tsullivan force-pushed the usage/collector-set-to-core branch 3 times, most recently from 276fafa to d095edc Compare June 27, 2018 19:39
@elastic elastic deleted a comment from elasticmachine Jun 27, 2018
@tsullivan tsullivan force-pushed the usage/collector-set-to-core branch 2 times, most recently from 3265c73 to 510f63d Compare June 27, 2018 19:45
@tsullivan tsullivan changed the title WIP - [Telemetry] move x-pack/monitoring collector classes to src/server/usage [Telemetry] move x-pack/monitoring collector classes to src/server/usage Jun 27, 2018
@tsullivan tsullivan added review Team:Core Platform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t// enhancement New value added to drive a business result labels Jun 27, 2018
Copy link
Copy Markdown
Member

@pickypg pickypg left a comment

Choose a reason for hiding this comment

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

The current test failure is unrelated (PhantomJS / Reporting error), but I do have one question that might need someone else's feedback on the platform team. Otherwise LGTM.


export function getSettingsCollector(server) {
const config = server.config();
const { Collector } = server.usage;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is creative. I wonder if this approach will work with the future plugin system / TypeScript?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Earlier ago, I talked with @epixa about these changes and he let me know that if we're registering server methods as per the conventions from the Hapi ecosystem, we should be OK for at least the foreseeable future.

I mentioned Court on this so he can correct me if I misunderstood.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yep, this should be fine.

}
});
// Register a function with server to manage the collection of usage stats
const { collectorSet } = server.usage;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is a nitpick, but why not just do

// Register a function with server to manage the collection of usage stats
server.usage.collectorSet.register(getReportingUsageCollector(server));

Bringing the variable into scope seems unnecessary.

@tsullivan
Copy link
Copy Markdown
Member Author

I'm taking the review label off this for now. After a chat with @ycombinator, I want to change some assumptions I was going with on this. This will get the changes documented in #20393

@tsullivan tsullivan requested a review from ycombinator July 5, 2018 22:34
@tsullivan tsullivan requested a review from chrisronline July 5, 2018 22:46
@elastic elastic deleted a comment from elasticmachine Jul 5, 2018
@elastic elastic deleted a comment from elasticmachine Jul 5, 2018
@elastic elastic deleted a comment from elasticmachine Jul 5, 2018
@elastic elastic deleted a comment from elasticmachine Jul 5, 2018
@tsullivan
Copy link
Copy Markdown
Member Author

Once this is green, it will be ready again for review.

I made some experimental changes that have been rolled back, which I did through rebase. The changes to do next are part of a Meta issue: #20393

@elasticmachine
Copy link
Copy Markdown
Contributor

💔 Build Failed

export class UsageCollector extends Collector {
constructor(server, properties) {
super(server, properties);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do you even need the constructor here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

a37d659

collectorSet, // consumer code calls collectorSet.register(collector) to define their own collector objects
Collector, // helper class for consumer code implementing ops/stats collection
UsageCollector, // helper class for consumer codea implementing usage collection
});
Copy link
Copy Markdown
Contributor

@ycombinator ycombinator Jul 6, 2018

Choose a reason for hiding this comment

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

You could potentially avoid exposing the helper classes themselves by providing factory methods on CollectorSet like makeCollector(server, properties) and makeUsageCollector(server, properties). Internally these methods would new up and return Collector and UsageCollector instances, respectively.

Another argument for this pattern is that there is no use case for creating Collector or UsageCollector instances without having to use them with a collectorSet anyway. By requiring their creation via a collectorSet instance, you are at least hinting at this coupling a bit more strongly.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I love it, stay tuned

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

Copy link
Copy Markdown
Contributor

@ycombinator ycombinator left a comment

Choose a reason for hiding this comment

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

LGTM pending green CI

@elastic elastic deleted a comment from elasticmachine Jul 6, 2018
@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

Copy link
Copy Markdown
Member

@pickypg pickypg left a comment

Choose a reason for hiding this comment

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

LGTM

@tsullivan tsullivan merged commit c043788 into elastic:master Jul 9, 2018
@tsullivan tsullivan deleted the usage/collector-set-to-core branch July 9, 2018 16:32
tsullivan added a commit to tsullivan/kibana that referenced this pull request Jul 18, 2018
…age (elastic#20248)

* [Monitoring/Telemetry] Move Usage service from Monitoring to Kibana core

* fix tests

* fix reporting integration

* roll back more diffs

* roll logger into bulk uploader to remove file duplication

* fix xpack usage api

* subclass constructor is not needed

* collectorSet has factory methods for collector object creation

* fix reporting usage jest test
@tsullivan
Copy link
Copy Markdown
Member Author

6.x/6.4.0: #20955

tsullivan added a commit that referenced this pull request Jul 19, 2018
…age (#20248) (#20955)

* [Monitoring/Telemetry] Move Usage service from Monitoring to Kibana core

* fix tests

* fix reporting integration

* roll back more diffs

* roll logger into bulk uploader to remove file duplication

* fix xpack usage api

* subclass constructor is not needed

* collectorSet has factory methods for collector object creation

* fix reporting usage jest test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New value added to drive a business result Feature:Telemetry review Team:Core Platform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t// v6.4.0 v7.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants