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

[Reporting] Remove any, improve telemetry schema for completeness #111212

Merged
merged 12 commits into from
Sep 8, 2021

Conversation

tsullivan
Copy link
Member

@tsullivan tsullivan commented Sep 3, 2021

Summary

Removes type ambiguity when the Reporting usage collector crafts the data for counting by exportType-per-app and layout-per-app.

  • Makes app and layout fields of the usage data applicable to all the export types, not just PDF
  • Theoretically, CSV could be created in different apps, not just search. Or, CSV/PNG could have different layouts. Those use cases aren't supported in Kibana today but there's nothing blocking anyone from working on them.
  • Adds canvas workpad and search to the set of app names used as indexes in the of per-app usage data.
  • Adds canvas to the set of layout names used as indexes in the per-layout usage data. (This should have been done in #84959(
  • Renamed decorateRangeStats to getExportStats to use a better name

Previously, only the PDF export type was the only one to count the app and layout fields in the usage data. This is hard to maintain from a types point of view. Also, CSV exports could theoretically have been created from different apps, not just Discover.

Notes

  • the Discover app is referred to as search in fields that count the number of CSV reports created.
  • the terms "exportType" and "jobType" are interchangeable in this part of the code. A "jobType" comes from a registered export type's jobType field and is used to uniquely identify the export type for telemetry.
  • the mappings in the telemetry cluster do not need to be updated as a result of this cleanup.

Checklist

@tsullivan tsullivan requested review from a team as code owners September 3, 2021 20:11
@tsullivan tsullivan added (Deprecated) Feature:Reporting Use Reporting:Screenshot, Reporting:CSV, or Reporting:Framework instead Feature:Telemetry release_note:skip Skip the PR/issue when compiling release notes Team:AppServices technical debt Improvement of the software architecture and operational architecture v7.16.0 v8.0.0 labels Sep 3, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app-services (Team:AppServices)

@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-reporting-services (Team:Reporting Services)

@tsullivan tsullivan force-pushed the reporting/fix-telemetry-types branch from 17ac8ca to 4fea726 Compare September 3, 2021 20:16
* 2.0.
*/

import { DEPRECATED_JOB_TYPES } from '../../common/constants';
Copy link
Member Author

@tsullivan tsullivan Sep 3, 2021

Choose a reason for hiding this comment

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

This file was rewritten and renamed: decorate_range_stats.ts → get_export_stats.ts

Previously, this code had a tangle of type ambiguity in the getAvailableTotalForFeature function

@@ -117,8 +119,7 @@ export type ReportingUsageType = RangeStats & {
last7Days: RangeStats;
};

export type ExportType = 'csv' | 'csv_searchsource' | 'printable_pdf' | 'PNG';
export type FeatureAvailabilityMap = { [F in ExportType]: boolean };
export type FeatureAvailabilityMap = Record<string, boolean>;
Copy link
Member Author

Choose a reason for hiding this comment

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

Changed this to be indexed by string instead ExportType for easier maintenance.

Instead of keeping a hardcoded list of all the known export types, we can use exportTypesHandler.getJobTypes(): it returns the jobTypes of all registered export types.

} = rangeStatsInput;

// combine the known types with any unknown type found in reporting data
const statsForExportType = exportTypesHandler.getJobTypes().reduce((accum, exportType) => {
Copy link
Member Author

Choose a reason for hiding this comment

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

exportTypesHandler.getJobTypes() replaces the need for a hardcoded list of all the job types. See https://github.com/elastic/kibana/pull/111212/files#r702149771

@tsullivan tsullivan requested review from a team as code owners September 3, 2021 20:40
@elastic elastic deleted a comment from kibanamachine Sep 3, 2021
Copy link
Contributor

@jloleysens jloleysens left a comment

Choose a reason for hiding this comment

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

Thanks for cleaning up the types and clearly structured commits and comments 👍🏻

It looks like we need to add csv_searchsource_immediate as another export type to the telemetry schema. I'll approve because everything else looks good.

}

// FIXME: find a way to get this from exportTypesHandler or common/constants
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@jloleysens
Copy link
Contributor

@elasticmachine merge upstream

Comment on lines +4053 to +4058
},
"app": {
"properties": {
"search": {
"type": "long"
},
Copy link
Contributor

Choose a reason for hiding this comment

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

@Bamieh that's a lot of additions, is that fine with you?

Copy link
Member Author

@tsullivan tsullivan Sep 7, 2021

Choose a reason for hiding this comment

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

Thanks for raising this @pgayvallet . The main reason why there are so many additions is that adding new export types multiplies what we track with telemetry:

  • PDF
  • PNG
  • CSV
  • PDFv2
  • PNGv2
  • CSVv2
  • CSV Immediate Download

For every export type, there is telemetry tracking for which apps were used, and what the layout options were.

This PR adds all of the V2 types to the schema

Copy link
Member

Choose a reason for hiding this comment

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

I was on holidays this week. It is fine. better than the alternatives!

@tsullivan
Copy link
Member Author

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

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

@tsullivan tsullivan merged commit c4c6536 into elastic:master Sep 8, 2021
tsullivan added a commit to tsullivan/kibana that referenced this pull request Sep 8, 2021
…lastic#111212)

* [Reporting] Remove `any`, improve telemetry schema for completeness

* remove another any

* rename file per exported function

* test variable name

* use variable for DRY

* update reporting telemetry contract

* added csv_searchsource_immediate to telemetry

* fix types

* update jest snapshots

* remove tests on large literal objects

Co-authored-by: Jean-Louis Leysens <[email protected]>
Co-authored-by: Kibana Machine <[email protected]>
@tsullivan tsullivan deleted the reporting/fix-telemetry-types branch September 9, 2021 00:03
tsullivan added a commit that referenced this pull request Sep 9, 2021
…111212) (#111665)

* [Reporting] Remove `any`, improve telemetry schema for completeness

* remove another any

* rename file per exported function

* test variable name

* use variable for DRY

* update reporting telemetry contract

* added csv_searchsource_immediate to telemetry

* fix types

* update jest snapshots

* remove tests on large literal objects

Co-authored-by: Jean-Louis Leysens <[email protected]>
Co-authored-by: Kibana Machine <[email protected]>

Co-authored-by: Jean-Louis Leysens <[email protected]>
Co-authored-by: Kibana Machine <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
(Deprecated) Feature:Reporting Use Reporting:Screenshot, Reporting:CSV, or Reporting:Framework instead Feature:Telemetry release_note:skip Skip the PR/issue when compiling release notes technical debt Improvement of the software architecture and operational architecture v7.16.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants