Skip to content

Commit

Permalink
[Reporting] Correction to schema for jobType size metrics (#128205)
Browse files Browse the repository at this point in the history
* [Reporting] Correction to schema for jobType size metrics

* fixes

* fixes2

* fix snapshots
  • Loading branch information
tsullivan authored Mar 22, 2022
1 parent 7b545b0 commit a3020b4
Show file tree
Hide file tree
Showing 9 changed files with 402 additions and 403 deletions.

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions x-pack/plugins/reporting/server/usage/get_export_stats.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ test('Model of jobTypes', () => {
PNG: {
available: true,
total: 3,
sizes: sizesAggResponse,
output_size: sizesAggResponse,
app: { dashboard: 0, visualization: 3, 'canvas workpad': 0 },
metrics: { png_cpu: {}, png_memory: {} } as MetricsStats,
},
printable_pdf: {
available: true,
total: 3,
sizes: sizesAggResponse,
output_size: sizesAggResponse,
app: { dashboard: 0, visualization: 0, 'canvas workpad': 3 },
layout: { preserve_layout: 3, print: 0, canvas: 0 },
metrics: { pdf_cpu: {}, pdf_memory: {}, pdf_pages: {} } as MetricsStats,
Expand All @@ -95,7 +95,7 @@ test('Model of jobTypes', () => {
available: true,
total: 3,
app: { search: 3 },
sizes: sizesAggResponse,
output_size: sizesAggResponse,
metrics: { csv_rows: {} } as MetricsStats,
},
},
Expand All @@ -118,7 +118,7 @@ test('Model of jobTypes', () => {
"png_cpu": Object {},
"png_memory": Object {},
},
"sizes": Object {
"output_size": Object {
"1.0": 5093470,
"25.0": 5093470,
"5.0": 5093470,
Expand All @@ -144,7 +144,7 @@ test('Model of jobTypes', () => {
"metrics": Object {
"csv_rows": Object {},
},
"sizes": Object {
"output_size": Object {
"1.0": 5093470,
"25.0": 5093470,
"5.0": 5093470,
Expand Down Expand Up @@ -176,7 +176,7 @@ test('Model of jobTypes', () => {
"pdf_memory": Object {},
"pdf_pages": Object {},
},
"sizes": Object {
"output_size": Object {
"1.0": 5093470,
"25.0": 5093470,
"5.0": 5093470,
Expand All @@ -197,7 +197,7 @@ test('PNG counts, provided count of deprecated jobs explicitly', () => {
available: true,
total: 15,
deprecated: 5,
sizes: sizesAggResponse,
output_size: sizesAggResponse,
app: { dashboard: 0, visualization: 0, 'canvas workpad': 0 },
metrics: { png_cpu: {}, png_memory: {} } as MetricsStats,
},
Expand All @@ -220,7 +220,7 @@ test('PNG counts, provided count of deprecated jobs explicitly', () => {
"png_cpu": Object {},
"png_memory": Object {},
},
"sizes": Object {
"output_size": Object {
"1.0": 5093470,
"25.0": 5093470,
"5.0": 5093470,
Expand All @@ -240,7 +240,7 @@ test('Incorporate metric stats', () => {
PNGV2: {
available: true,
total: 3,
sizes: sizesAggResponse,
output_size: sizesAggResponse,
app: { dashboard: 0, visualization: 0, 'canvas workpad': 3 },
metrics: {
png_cpu: { '50.0': 0.01, '75.0': 0.01, '95.0': 0.01, '99.0': 0.01 },
Expand All @@ -250,7 +250,7 @@ test('Incorporate metric stats', () => {
printable_pdf_v2: {
available: true,
total: 3,
sizes: sizesAggResponse,
output_size: sizesAggResponse,
metrics: {
pdf_cpu: { '50.0': 0.01, '75.0': 0.01, '95.0': 0.01, '99.0': 0.01 },
pdf_memory: { '50.0': 3485, '75.0': 3496, '95.0': 3678, '99.0': 3782 },
Expand Down Expand Up @@ -288,7 +288,7 @@ test('Incorporate metric stats', () => {
"99.0": 3782,
},
},
"sizes": Object {
"output_size": Object {
"1.0": 5093470,
"25.0": 5093470,
"5.0": 5093470,
Expand Down Expand Up @@ -335,7 +335,7 @@ test('Incorporate metric stats', () => {
"99.0": 4,
},
},
"sizes": Object {
"output_size": Object {
"1.0": 5093470,
"25.0": 5093470,
"5.0": 5093470,
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/reporting/server/usage/get_export_stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const defaultTotalsForFeature: Omit<AvailableTotal, 'available'> & { layout: Lay
total: 0,
deprecated: 0,
app: { 'canvas workpad': 0, search: 0, visualization: 0, dashboard: 0 },
sizes: ['1.0', '5.0', '25.0', '50.0', '75.0', '95.0', '99.0'].reduce(
output_size: ['1.0', '5.0', '25.0', '50.0', '75.0', '95.0', '99.0'].reduce(
(sps, p) => ({ ...sps, [p]: null }),
{} as SizePercentiles
),
Expand Down Expand Up @@ -79,7 +79,7 @@ function getAvailableTotalForFeature(
available: isAvailable(featureAvailability, exportType),
total: jobType?.total || 0,
deprecated,
sizes: { ...defaultTotalsForFeature.sizes, ...jobType?.sizes },
output_size: { ...defaultTotalsForFeature.output_size, ...jobType?.output_size },
metrics: { ...metricsForFeature[exportType], ...jobType?.metrics },
app: { ...defaultTotalsForFeature.app, ...jobType?.app },
layout: jobTypeIsPdf(exportType)
Expand Down
13 changes: 10 additions & 3 deletions x-pack/plugins/reporting/server/usage/get_reporting_usage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ enum keys {
OBJECT_TYPE = 'objectTypes',
STATUS_BY_APP = 'statusByApp',
STATUS = 'statusTypes',
OUTPUT_SIZE = 'sizes',
OUTPUT_SIZE = 'output_size',
IS_DEPRECATED = 'meta.isDeprecated',
CSV_ROWS = 'csv_rows',
PDF_CPU = 'pdf_cpu',
Expand Down Expand Up @@ -96,7 +96,14 @@ function getAggStats(
): Partial<RangeStats> {
const { buckets: jobBuckets } = aggs[keys.JOB_TYPE] as AggregationBuckets;
const jobTypes = jobBuckets.reduce((accum: JobTypes, bucket) => {
const { key, doc_count: count, isDeprecated, sizes, layoutTypes, objectTypes } = bucket;
const {
key,
doc_count: count,
isDeprecated,
output_size: outputSizes,
layoutTypes,
objectTypes,
} = bucket;
const deprecatedCount = isDeprecated?.doc_count;

// format the search results into the telemetry schema
Expand All @@ -105,7 +112,7 @@ function getAggStats(
deprecated: deprecatedCount,
app: getKeyCount(get(objectTypes, 'buckets', [])),
metrics: (metrics && metrics[key]) || undefined,
sizes: get(sizes, 'values', {} as SizePercentiles),
output_size: get(outputSizes, 'values', {} as SizePercentiles),
layout: getKeyCount(get(layoutTypes, 'buckets', [])),
};
return { ...accum, [key]: jobType };
Expand Down
Loading

0 comments on commit a3020b4

Please sign in to comment.