Skip to content
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

[Telemetry] Prepare for versioned HTTP APIs #152111

Merged

Conversation

jloleysens
Copy link
Contributor

@jloleysens jloleysens commented Feb 24, 2023

Summary

In this PR we ensure that we are adhering to the goals of versioned HTTP APIs to:

  1. Not send SO attributes directly over the wire
  2. Have a separate set of interfaces that can be referenced by public and maintained by server

@jloleysens jloleysens added Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc Feature:Telemetry release_note:skip Skip the PR/issue when compiling release notes v8.8.0 labels Feb 24, 2023
@jloleysens jloleysens self-assigned this Feb 24, 2023
@jloleysens jloleysens changed the title [Telemetry] Do not use SO attributes in endpoints [Telemetry] Prepare for versioned HTTP APIs Feb 27, 2023
@jloleysens jloleysens marked this pull request as ready for review February 27, 2023 12:47
@jloleysens jloleysens requested a review from a team as a code owner February 27, 2023 12:47
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-core (Team:Core)

@@ -33,7 +34,17 @@ export function registerTelemetryUserHasSeenNotice(router: IRouter) {
};
await updateTelemetrySavedObject(soClient, updatedAttributes);

return res.ok({ body: updatedAttributes });
const body: v2.Telemetry = {
allowChangingOptInStatus: updatedAttributes.allowChangingOptInStatus,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Explicitly map our SO attributes to the response

@@ -10,9 +10,3 @@
* Fetch Telemetry Config
*/
export const FetchTelemetryConfigRoute = '/api/telemetry/v2/config';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is kind of an interesting one... I am deferring changing this path as I am not familiar with the original context for introducing v2 in it, but I am guessing once an actual versioning mechanism is available we can come back to it? Let me know what y'all think.

Copy link
Member

Choose a reason for hiding this comment

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

That is a very good question!! I need to rely on @Bamieh because the /v2/ part of the telemetry APIs predates me 🤷

FWIW, our telemetry APIs should be considered internal (we probably should name them as such, TBH)... Having said that, we are aware that some external products already use them, so I don't think we can introduce a breaking change without notifying them (or providing a sensible deprecation period).

Copy link
Contributor

Choose a reason for hiding this comment

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

the /v2/ part of the telemetry APIs

From what I can recall, 'v2' deals with encryption

Copy link
Member

Choose a reason for hiding this comment

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

The versioning is introduced for external consumers to check for and detect how to handle incoming requests (our telemetry endpoint for example).

v1 -> v2 was for encryption. This way the telemetry cluster endpoint will check the request URL and will handle the request differently based on the version.

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.

Thank you for adapting these APIs to the versioned router approach 🧡

@@ -10,9 +10,3 @@
* Fetch Telemetry Config
*/
export const FetchTelemetryConfigRoute = '/api/telemetry/v2/config';
Copy link
Member

Choose a reason for hiding this comment

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

That is a very good question!! I need to rely on @Bamieh because the /v2/ part of the telemetry APIs predates me 🤷

FWIW, our telemetry APIs should be considered internal (we probably should name them as such, TBH)... Having said that, we are aware that some external products already use them, so I don't think we can introduce a breaking change without notifying them (or providing a sensible deprecation period).

@afharo afharo requested a review from Bamieh February 27, 2023 13:03
@jloleysens jloleysens enabled auto-merge (squash) March 1, 2023 12:37
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Unknown metric groups

ESLint disabled line counts

id before after diff
securitySolution 428 430 +2

Total ESLint disabled count

id before after diff
securitySolution 506 508 +2

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @jloleysens

@jloleysens jloleysens merged commit a5b2db4 into elastic:main Mar 1, 2023
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Mar 1, 2023
@jloleysens jloleysens deleted the telemetry-remove-so-attribs-from-endpoints branch March 2, 2023 14:32
bmorelli25 pushed a commit to bmorelli25/kibana that referenced this pull request Mar 10, 2023
## Summary

In this PR we ensure that we are adhering to the goals of versioned HTTP
APIs to:

1. Not send SO attributes directly over the wire
2. Have a separate set of interfaces that can be referenced by public
and maintained by server
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Feature:Telemetry release_note:skip Skip the PR/issue when compiling release notes Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v8.8.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants