-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prepares usage-collection plugin for versioned HTTP APIs #152770
Prepares usage-collection plugin for versioned HTTP APIs #152770
Conversation
…ants of reporting usage as empty object
2b04505
to
aae570b
Compare
@elasticmachine merge upstream |
💔 Build FailedFailed CI Steps
Metrics [docs]
History
To update your PR or re-run it, just comment with: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this is looking great @TinaHeiligers ! Happy with the direction to provide full typings for the response as that gives the strongest guarantees for adhering to versioning. I'll finish my review on another pass. Let me know what you think!
@@ -0,0 +1,207 @@ | |||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this makes sense, it is giving us the full types of the endpoint and we will be able to detect when our response changes👌🏻
Nit: I would name this file "core_metrics" then add a doc comment explaining this starts as a duplicate of the core ops metrics.
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const response = await fetch.post<any>('/api/ui_counters/_report', { | ||
body: JSON.stringify({ report }), | ||
asSystemRequest: true, | ||
}); | ||
|
||
if (response.status !== 'ok') { | ||
const okStatus: v1.UiCountersResponseOk = response.status; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌🏻
@@ -43,5 +43,6 @@ export const reportSchema = schema.object({ | |||
application_usage: schema.maybe(schema.recordOf(schema.string(), applicationUsageReportSchema)), | |||
}); | |||
|
|||
// should the schema types also be versioned explicitly? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question, for now I think it is OK not to. But it would be consistent with our types. I could go either way on this one 😁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or now I think it is OK not to
Cool! I'm going with that :-)
Closing in favor of #152875 |
WIP: for discussion only.
stats
The
stats
route reports metrics fromcore
'sMetrics
service. However, as-is, these metrics are assumed asunknowns
, meaning any subsequent change to what is reported is passed through.One of the requirements for versioned APIs is to explicitly declare (with appropriate types) the response.
As such, there are a few approaches we could take:
This draft PR creates a copy of the
OpsMetrics
and explicitly types the response using the copy.usage_counters
There isn't an explicit HTTP API for these, so I'm not sure if versioning the saved object is needed right now.
However, the usage_counters_service reports these metrics through a browser-side API.
Summary
Summarize your PR. If it involves visual changes include a screenshot or gif.
Checklist
Delete any items that are not applicable to this PR.
Risk Matrix
Delete this section if it is not applicable to this PR.
Before closing this PR, invite QA, stakeholders, and other developers to identify risks that should be tested prior to the change/feature release.
When forming the risk matrix, consider some of the following examples and how they may potentially impact the change:
For maintainers