Skip to content

[8.19] [Core] Expose isFeatureAvailable method from pricing API server setup (#223525)#225966

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

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

Conversation

@kibanamachine
Copy link
Copy Markdown
Contributor

Backport

This will backport the following commits from main to 8.19:

Questions ?

Please refer to the Backport tool documentation

@kibanamachine kibanamachine added the backport This PR is a backport of another PR label Jul 1, 2025
@kibanamachine kibanamachine enabled auto-merge (squash) July 1, 2025 09:47
…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/8.19/pr-223525 branch from 62923e3 to 0748453 Compare July 1, 2025 09:47
@kibanamachine kibanamachine merged commit 100c8e7 into elastic:8.19 Jul 1, 2025
8 checks passed
@elasticmachine
Copy link
Copy Markdown
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

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 452.0KB 452.0KB +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