Usage collection methods should be available during start and not just during setup #69835
Labels
Feature:Telemetry
Team:Core
Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc
Currently, the UsageCollection plugin makes some methods available on its plugin setup contract, but doesn't return anything from its start lifecycle method. For other plugins to use these methods on the client, they need to reference a setup dependency from within a mount callback, like so:
This is an anti-pattern because setup APIs should not be called after the setup lifecycle is complete, and the mount method is not called until after the setup method is complete. (@joshdover please make sure I'm not mis-representing this?)
Instead, a callback like mount should use the start contract via
core.getStartServices()
, like so:In order for plugins to correctly reference the usageCollection plugin inside mount (or other async callbacks), the setup contract must also be returned from the start lifecycle method inside the UsageCollection plugin.
The text was updated successfully, but these errors were encountered: