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/Telemetry] Include counts for each deprecated job type #108614

Merged

Conversation

tsullivan
Copy link
Member

@tsullivan tsullivan commented Aug 13, 2021

Closes #105868

Summary

This PR adds an explicit deprecated count to each export type, which makes deprecating code in Reporting more flexible for telemetry:

  • you don't have to know which export types are deprecated to find usage of deprecated reporting features
  • you can compare overall deprecated count with overall report count.

Telemetry data can show how often deprecated export types are used. Prior to this PR, the export type itself would have to be deprecated, and we would find the usage of deprecated export types by comparing the usage of each export type.

When is merged, the printable_pdf and PNG, report jobs will be conditionally marked as deprecated, based on whether the job parameters used the 6.2 savedObjectId style, or the later relativeUrls style. Since the job type can not be used to see if the job is deprecated, this PR adds extra logic to telemetry collection in Reporting and gives an explicit flag on if the job is deprecated.

Testing:

  1. In Kibana 7.12, import test data, create a saved search in Discover, and copy the POST URL for CSV export.
  2. Create a script that sends the POST URL to Kibana to request a CSV report. Example: https://gist.github.com/tsullivan/0b86d5e1165f6460a876b4f63012fdd0
  3. Create a few report jobs using the script
  4. Export the saved objects in Stack Management > Saved Objects
  5. Upgrade ES to 8.0, or import the test data and saved objects in ES 8.0 with running Kibana from source checked out to this PR.
  6. Create a few more report jobs using the script
  7. Run the script that uses the POST URL copied in 7.12.

With the reporting index set up with deprecated job types, you can then query the internal API for usage, and see that it contains info about the deprecated job types.

  1. Run a curl command on the usage endpoint and pipe the response data to jq:
 curl 'http://elastic:changeme@localhost:5601/api/telemetry/v2/clusters/_stats' --compressed \
  -H 'Content-Type: application/json' \
  -H 'kbn-version: 8.0.0' \
  --data-raw '{"unencrypted":true}' \
  | jq '.[0].stack_stats.kibana.plugins.reporting|{l7D:.last7Days|{csv,csv_searchsource},csv,csv_searchsource}'

Example output:

{
"l7D": {
  "csv": {
    "available": true,
    "total": 4,
    "deprecated": 4
  },
  "csv_searchsource": {
    "available": true,
    "total": 5,
    "deprecated": 0
  }
},
"csv": {
  "available": true,
  "total": 4,
  "deprecated": 4
},
"csv_searchsource": {
  "available": true,
  "total": 5,
  "deprecated": 0
}
}

TODO:

  • Mark all count of a job type as deprecated, if the job type itself is deprecated

Checklist

Delete any items that are not applicable to this PR.

@tsullivan tsullivan marked this pull request as draft August 13, 2021 23:01
};
doc_count: number;
}

Copy link
Member Author

Choose a reason for hiding this comment

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

These lines of code were mysteriously duplicated in the file

Copy link
Contributor

Choose a reason for hiding this comment

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

🧙🏻‍♂️

@tsullivan tsullivan changed the title [Reporting/Telemetry] Include counts for each job type on the number of deprecated exports found [Reporting/Telemetry] Include counts for each deprecated job type Aug 13, 2021
@tsullivan tsullivan added (Deprecated) Feature:Reporting Use Reporting:Screenshot, Reporting:CSV, or Reporting:Framework instead Feature:Telemetry Team:AppServices release_note:skip Skip the PR/issue when compiling release notes v7.15.0 v8.0.0 labels Aug 13, 2021
@tsullivan tsullivan force-pushed the reporting/telemetry-for-deprecated branch 2 times, most recently from 0325f4f to 813f3df Compare August 14, 2021 16:52
| 'failed'
| 'pending'
| 'processing';
type Statuses = 'completed' | 'completed_with_warnings' | 'failed' | 'pending' | 'processing';
Copy link
Member Author

Choose a reason for hiding this comment

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

Removed non-existent cancelled status

@tsullivan tsullivan force-pushed the reporting/telemetry-for-deprecated branch from b75313e to 1fe51ff Compare August 17, 2021 20:25
PDF_JOB_TYPE,
PNG_JOB_TYPE,
} from '../../common/constants';
import { AvailableTotal, ExportType, FeatureAvailabilityMap, RangeStats } from './types';

const jobTypeIsDeprecated = (jobType: string) => DEPRECATED_JOB_TYPES.includes(jobType);

function getForFeature(
range: Partial<RangeStats>,
typeKey: ExportType,
featureAvailability: FeatureAvailabilityMap,
additional?: any
Copy link
Member Author

Choose a reason for hiding this comment

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

I took a crack at fixing this any but was not able to see a clean fix for it yet

Copy link
Contributor

Choose a reason for hiding this comment

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

You can use generics as a clean fix.

Copy link
Member Author

Choose a reason for hiding this comment

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

@dokmic I merged your suggestion and there is still a lot of ambiguity in the body of this function. I reverted the commit for now, but let's keep track of this. It is a very nasty any and in a big way, it indicates the logic of the function could be improved.

@@ -559,9 +722,6 @@ describe('Ready for collection observable', () => {
},
},
"status": Object {
"cancelled": Object {
Copy link
Member Author

Choose a reason for hiding this comment

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

cancelled is not a valid status

@tsullivan tsullivan force-pushed the reporting/telemetry-for-deprecated branch 4 times, most recently from b9e1e74 to 74177a4 Compare August 17, 2021 21:22
@tsullivan tsullivan force-pushed the reporting/telemetry-for-deprecated branch from 74177a4 to 12ef82a Compare August 17, 2021 21:25
@tsullivan tsullivan marked this pull request as ready for review August 17, 2021 21:28
@tsullivan tsullivan requested review from a team as code owners August 17, 2021 21:28
@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 requested review from dokmic and jloleysens August 17, 2021 21:29
@tsullivan tsullivan requested review from a team August 17, 2021 21:29
@tsullivan
Copy link
Member Author

@elasticmachine merge upstream

@tsullivan tsullivan added v7.16.0 and removed v7.15.0 labels Aug 17, 2021
@@ -4105,9 +4117,6 @@
},
"status": {
"properties": {
"cancelled": {
Copy link
Contributor

Choose a reason for hiding this comment

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

Removing these from the telemetry indices will require a re-index operation. Please make sure that you follow up with infra to let them know.

Copy link
Contributor

@TinaHeiligers TinaHeiligers left a comment

Choose a reason for hiding this comment

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

Telemetry (and therefore core) changes LGTM. Please remember to follow up with Infra to get cancelled removed from the mappings.

Copy link
Contributor

@dokmic dokmic left a comment

Choose a reason for hiding this comment

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

Code changes LGTM 👍

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.

Code changes look great to me! Thanks for adding this @tsullivan

I tested this locally and report generation and telemetry collection worked as expected.

Screenshot 2021-08-19 at 11 58 44

I think the PR description needs to update isDeprectated -> deprecated as that what it looks like we are currently getting back from the Kibana stats API.

@tsullivan tsullivan enabled auto-merge (squash) August 19, 2021 16:17
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
reporting 67.2KB 67.4KB +155.0B

History

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

@tsullivan tsullivan merged commit 91630c6 into elastic:master Aug 20, 2021
@tsullivan tsullivan deleted the reporting/telemetry-for-deprecated branch August 20, 2021 05:50
tsullivan added a commit to tsullivan/kibana that referenced this pull request Aug 20, 2021
…astic#108614)

* add isDeprecated to report meta for telemetry

* test clean up

* update snapshots

* Update x-pack/plugins/reporting/server/usage/decorate_range_stats.ts

Co-authored-by: Michael Dokolin <[email protected]>

Co-authored-by: Kibana Machine <[email protected]>
Co-authored-by: Michael Dokolin <[email protected]>
tsullivan added a commit that referenced this pull request Aug 21, 2021
…08614) (#109366)

* add isDeprecated to report meta for telemetry

* test clean up

* update snapshots

* Update x-pack/plugins/reporting/server/usage/decorate_range_stats.ts

Co-authored-by: Michael Dokolin <[email protected]>

Co-authored-by: Kibana Machine <[email protected]>
Co-authored-by: Michael Dokolin <[email protected]>

Co-authored-by: Kibana Machine <[email protected]>
Co-authored-by: Michael Dokolin <[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 v7.16.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Reporting] Add telemetry for deprecated export type usage
6 participants