From 55b5b140e1118f205068a3cd4145b7d0b6403b7e Mon Sep 17 00:00:00 2001 From: Dominique Clarke Date: Thu, 8 Aug 2024 20:51:25 -0400 Subject: [PATCH] [Synthetics] remove full screenshots (#189911) ## Summary We have not used full screenshot image data since early alpha versions of Synthetics (pre 7.14.0), and there is no reason to _not_ use screenshot blocks instead as they make far more efficient storage performance. ### Release note Removes support for Heartbeat browser monitor screenshots for lower versions of Heartbeat. Please upgrade to Heartbeat 7.17.24 to continue using Heartbeat browser monitor screenshots. ### Testing Screenshots are just for browser monitors, and browser monitors are in Beta in 7.17.x and will never be moved to GA. I don't believe this ticket needs additional testing beyond passing integration tests. --- .../pings/journey_screenshots.test.ts | 67 ------------------- .../rest_api/pings/journey_screenshots.ts | 12 +--- 2 files changed, 2 insertions(+), 77 deletions(-) diff --git a/x-pack/plugins/uptime/server/rest_api/pings/journey_screenshots.test.ts b/x-pack/plugins/uptime/server/rest_api/pings/journey_screenshots.test.ts index 22aef54fa10bd..74eb98316602f 100644 --- a/x-pack/plugins/uptime/server/rest_api/pings/journey_screenshots.test.ts +++ b/x-pack/plugins/uptime/server/rest_api/pings/journey_screenshots.test.ts @@ -86,73 +86,6 @@ describe('journey screenshot route', () => { expect(response.body.screenshotRef).toEqual(mock); }); - it('returns full screenshot blob', async () => { - const mock = { - synthetics: { - blob: 'a blob', - blob_mime: 'image/jpeg', - step: { - name: 'a step name', - }, - type: 'step/screenshot', - }, - totalSteps: 3, - }; - const route = createJourneyScreenshotRoute({ - // @ts-expect-error incomplete implementation for testing - requests: { - getJourneyScreenshot: jest.fn().mockReturnValue(mock), - }, - }); - - // @ts-expect-error incomplete implementation for testing - expect(await route.handler(libs)).toMatchInlineSnapshot(` - Object { - "body": Object { - "data": Array [ - 105, - 185, - 104, - ], - "type": "Buffer", - }, - "headers": Object { - "cache-control": "max-age=600", - "caption-name": "a step name", - "content-type": "image/jpeg", - "max-steps": "3", - }, - "message": "Ok", - "status": 200, - } - `); - }); - - it('defaults to png when mime is undefined', async () => { - const mock = { - synthetics: { - blob: 'a blob', - step: { - name: 'a step name', - }, - type: 'step/screenshot', - }, - }; - const route = createJourneyScreenshotRoute({ - // @ts-expect-error incomplete implementation for testing - requests: { - getJourneyScreenshot: jest.fn().mockReturnValue(mock), - }, - }); - - // @ts-expect-error incomplete implementation for testing - const response = await route.handler(libs); - - expect(response.status).toBe(200); - // @ts-expect-error incomplete implementation for testing - expect(response.headers['content-type']).toBe('image/png'); - }); - it('returns 404 for screenshot missing blob', async () => { const route = createJourneyScreenshotRoute({ // @ts-expect-error incomplete implementation for testing diff --git a/x-pack/plugins/uptime/server/rest_api/pings/journey_screenshots.ts b/x-pack/plugins/uptime/server/rest_api/pings/journey_screenshots.ts index 3e71051816d30..7435d3f97a050 100644 --- a/x-pack/plugins/uptime/server/rest_api/pings/journey_screenshots.ts +++ b/x-pack/plugins/uptime/server/rest_api/pings/journey_screenshots.ts @@ -6,7 +6,7 @@ */ import { schema } from '@kbn/config-schema'; -import { isRefResult, isFullScreenshot } from '../../../common/runtime_types/ping/synthetics'; +import { isRefResult } from '../../../common/runtime_types/ping/synthetics'; import { UMServerLibs } from '../../lib/lib'; import { ScreenshotReturnTypesUnion } from '../../lib/requests/get_journey_screenshot'; import { UMRestApiRouteFactory } from '../types'; @@ -37,15 +37,7 @@ export const createJourneyScreenshotRoute: UMRestApiRouteFactory = (libs: UMServ stepIndex, }); - if (isFullScreenshot(result) && typeof result.synthetics?.blob !== 'undefined') { - return response.ok({ - body: Buffer.from(result.synthetics.blob, 'base64'), - headers: { - 'content-type': result.synthetics.blob_mime || 'image/png', // falls back to 'image/png' for earlier versions of synthetics - ...getSharedHeaders(result.synthetics.step.name, result.totalSteps), - }, - }); - } else if (isRefResult(result)) { + if (isRefResult(result)) { return response.ok({ body: { screenshotRef: result,