Skip to content

[9.1] [Core] Expose isFeatureAvailable method from pricing API server setup (#223525)#225967

Merged
kibanamachine merged 1 commit intoelastic:9.1from
kibanamachine:backport/9.1/pr-223525
Jul 1, 2025
Merged

[9.1] [Core] Expose isFeatureAvailable method from pricing API server setup (#223525)#225967
kibanamachine merged 1 commit intoelastic:9.1from
kibanamachine:backport/9.1/pr-223525

Conversation

@kibanamachine
Copy link
Copy Markdown
Contributor

Backport

This will backport the following commits from main to 9.1:

Questions ?

Please refer to the Backport tool documentation

…elastic#223525)

## 📓 Summary

This work exposes an asynchronous
`coreSetup.pricing.isFeatureAvailable()` method to assert whether Kibana
is running on a given pricing product during a plugin server setup
lifecycle step.

##  Why do we need it?

Some feature registrations are synchronous in the plugin setup, and
until all the plugins have registered their features, knowing features
availability at the server setup step is not possible.

## How does this fix it?

To guarantee we have access to all the registered features during the
setup lifecycle, the process works so that:
1. All the plugins are set up and the product features are registered
synchronously.
2. Once all the plugins are set, the core pricing service emits a
signal.
3. The `isFeatureAvailable` method on setup, if invoked previously,
resolves asynchronously, reacting to the emitted signal.

This guarantees access to the product feature model anywhere in Kibana,
without having to rely on the raw tier configuration values.

```ts
public setup(core: CoreSetup) {
    core.pricing.registerProductFeatures([
      {
        id: 'my-plugin:feature1',
        description: 'A feature for observability products',
        products: [
          { name: 'observability', tier: 'complete' },
        ],
      }
    ]);

    core.pricing.isFeatureAvailable('my-plugin:feature1').then((isActiveObservabilityComplete) => {
      if (isActiveObservabilityComplete) {
        // Enable feature1
      }
    });
  }
```

(cherry picked from commit 44c11da)
@kibanamachine kibanamachine force-pushed the backport/9.1/pr-223525 branch from c0a1023 to c85c145 Compare July 1, 2025 09:47
@kibanamachine kibanamachine merged commit 84bc0a5 into elastic:9.1 Jul 1, 2025
10 checks passed
@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/core-pricing-server 2 3 +1

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
core 457.1KB 457.1KB +51.0B
Unknown metric groups

API count

id before after diff
@kbn/core-pricing-common 23 25 +2
@kbn/core-pricing-server 6 8 +2
total +4

cc @tonyghiani

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR is a backport of another PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants