Skip to content

Commit

Permalink
[Synthetics] remove full screenshots (elastic#189911)
Browse files Browse the repository at this point in the history
## 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.
  • Loading branch information
dominiqueclarke authored Aug 9, 2024
1 parent c119b87 commit 55b5b14
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 2 additions & 10 deletions x-pack/plugins/uptime/server/rest_api/pings/journey_screenshots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 55b5b14

Please sign in to comment.