Skip to content

[metering] move usage reporting service to the usage plugin#255063

Merged
pgayvallet merged 12 commits intoelastic:mainfrom
pgayvallet:ab-13010-metering
Feb 27, 2026
Merged

[metering] move usage reporting service to the usage plugin#255063
pgayvallet merged 12 commits intoelastic:mainfrom
pgayvallet:ab-13010-metering

Conversation

@pgayvallet
Copy link
Contributor

@pgayvallet pgayvallet commented Feb 26, 2026

Summary

Required for of https://github.com/elastic/search-team/issues/13010
Related to #252219 and #252434

Move the UsageReportingService and related stuff from the workflowsExecutionEngine plugin to the usage plugin, so that other consumers of the usage/metering API can re-use the type and logic

@pgayvallet pgayvallet added release_note:skip Skip the PR/issue when compiling release notes backport:skip This PR does not require backporting v9.4.0 labels Feb 26, 2026
@pgayvallet pgayvallet changed the title [metering] move metering reporting service to the usage plugin [metering] move usage reporting service to the usage plugin Feb 26, 2026
Copy link
Contributor Author

@pgayvallet pgayvallet left a comment

Choose a reason for hiding this comment

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

self-review

Comment on lines -159 to -162
private async sendWithRetry(record: UsageRecord): Promise<void> {
let lastError: Error | undefined;

for (let attempt = 0; attempt < METERING_RETRY_ATTEMPTS; attempt++) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

retry logic moved to the usageReportingService

Comment on lines +61 to +63
return {
usageReporting: this.usageReporting,
};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Returning the service from the start contract too (given it's arguably better than consuming it from the setup contract)

Comment on lines 39 to 43
export class UsageReportingService {
private agent: https.Agent | undefined;
private readonly config: UsageReportingConfig;
private readonly kibanaVersion: string;
private readonly logger: Logger;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a move from src/platform/plugins/shared/workflows_execution_engine/server/metering/usage_reporting_service.ts, not a delete, just too many changes because I moved the retry mechanism to the service.

@pgayvallet
Copy link
Contributor Author

/ci

@pgayvallet
Copy link
Contributor Author

/ci

@pgayvallet
Copy link
Contributor Author

/ci

@pgayvallet
Copy link
Contributor Author

/ci

@pgayvallet pgayvallet marked this pull request as ready for review February 26, 2026 14:15
@pgayvallet pgayvallet requested review from a team as code owners February 26, 2026 14:15
Copy link
Contributor

@talboren talboren left a comment

Choose a reason for hiding this comment

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

LGTM

@botelastic botelastic bot added the Team:One Workflow Team label for One Workflow (Workflow automation) label Feb 26, 2026
@elasticmachine
Copy link
Contributor

elasticmachine commented Feb 26, 2026

💔 Build Failed

Failed CI Steps

Test Failures

  • [job] [logs] Jest Tests #5 / Usage API Plugin #setup interface it should return enabled false when config is provided but url is not set
  • [job] [logs] Jest Tests #5 / Usage API Plugin #setup interface it should return enabled false when config is provided but url is not set
  • [job] [logs] Jest Tests #5 / Usage API Plugin #setup interface it should return enabled false when no config is provided
  • [job] [logs] Jest Tests #5 / Usage API Plugin #setup interface it should return enabled false when no config is provided
  • [job] [logs] Jest Tests #5 / Usage API Plugin #setup interface it should return enabled true when config is provided and url is set
  • [job] [logs] Jest Tests #5 / Usage API Plugin #setup interface it should return enabled true when config is provided and url is set
  • [job] [logs] Jest Tests #5 / Usage API Plugin #setup interface it should return tls when tls is provided
  • [job] [logs] Jest Tests #5 / Usage API Plugin #setup interface it should return tls when tls is provided
  • [job] [logs] Jest Tests #5 / Usage API Plugin #start interface snapshot
  • [job] [logs] Jest Tests #5 / Usage API Plugin #start interface snapshot

Metrics [docs]

‼️ ERROR: no builds found for mergeBase sha [8500782]

History

Copy link
Member

@afharo afharo left a comment

Choose a reason for hiding this comment

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

🚀

@pgayvallet pgayvallet enabled auto-merge (squash) February 27, 2026 06:26
@pgayvallet pgayvallet merged commit ad8d5b4 into elastic:main Feb 27, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:One Workflow Team label for One Workflow (Workflow automation) v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants