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

[APM] Update Indices API to support sourcemap param #177847

Merged
merged 4 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions x-pack/plugins/observability_solution/apm/scripts/test/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ if (server) {
const cmd = [
'node',
...(inspect ? ['--inspect-brk'] : []),
`../../../../../scripts/${ftrScript}`,
`../../../../../../scripts/${ftrScript}`,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@CoenWarmer just a FYI. I fixed the static path on APM, but I think we must look at other solutions. Some scripts my be broken due to the folder migration.

Copy link
Contributor

Choose a reason for hiding this comment

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

@cauemarcondes & @CoenWarmer - I've found a spot that was probably missed during a folder migration.

node plugins/apm/scripts/test/e2e.js \

Sorry, that I commented it here, but I had a hard time finding the migration PR, this seems it's at least related to the owners :)

I'm assuming, if you would ask for full cypress testing on the PRs that includes APM, it would break like this: https://buildkite.com/elastic/kibana-kme-test/builds/319#018e0ee0-16ee-4224-902c-732706c3f857

...(grep ? [`--grep "${grep}"`] : []),
...(updateSnapshots ? [`--updateSnapshots`] : []),
...(bail ? [`--bail`] : []),
`--config ../../../../test/apm_api_integration/${license}/config.ts`,
`--config ../../../../../test/apm_api_integration/${license}/config.ts`,
].join(' ');

console.log(`Running: "${cmd}"`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ if (cypressCliArgs.grep) {
}

const spawnArgs = [
`../../../../scripts/${ftrScript}`,
`../../../../../scripts/${ftrScript}`,
`--config=./ftr_config.ts`,
`--kibana-install-dir=${argv.kibanaInstallDir}`,
...(argv.bail ? [`--bail`] : []),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,21 @@ const saveApmIndicesRoute = createApmServerRoute({
span: t.string,
transaction: t.string,
metric: t.string,
// Keeping this one here for backward compatibility
sourcemap: t.string,
} as SaveApmIndicesBodySchema),
}),
handler: async (resources): Promise<SavedObject<{}>> => {
const { params, context } = resources;
const { body } = params;
const savedObjectsClient = (await context.core).savedObjects.client;
return await saveApmIndices(savedObjectsClient, body);
const indices = { ...body };
if (indices.sourcemap) {
// Delete this as we stopped supporting it from 8.7.
delete indices.sourcemap;
}

return await saveApmIndices(savedObjectsClient, indices);
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

import {
APMIndicesSavedObjectBody,
APM_INDEX_SETTINGS_SAVED_OBJECT_ID,
APM_INDEX_SETTINGS_SAVED_OBJECT_TYPE,
} from '@kbn/apm-data-access-plugin/server/saved_objects/apm_indices';
Expand Down Expand Up @@ -71,5 +72,27 @@ export default function apmIndicesTests({ getService }: FtrProviderContext) {
expect(readResponse.status).to.be(200);
expect(readResponse.body.transaction).to.eql(INDEX_VALUE);
});

it('updates apm indices removing legacy sourcemap', async () => {
const INDEX_VALUE = 'foo-*';

const writeResponse = await apmApiClient.writeUser({
endpoint: 'POST /internal/apm/settings/apm-indices/save',
params: {
body: { sourcemap: 'bar-*', transaction: INDEX_VALUE },
},
});
expect(writeResponse.status).to.be(200);
const savedAPMSavedObject = writeResponse.body
.attributes as Partial<APMIndicesSavedObjectBody>;
expect(savedAPMSavedObject.apmIndices?.transaction).to.eql(INDEX_VALUE);
expect(savedAPMSavedObject.apmIndices?.sourcemap).to.eql(undefined);

const readResponse = await apmApiClient.readUser({
endpoint: 'GET /internal/apm/settings/apm-indices',
});
expect(readResponse.body.transaction).to.eql(INDEX_VALUE);
expect(readResponse.body.sourcemap).to.eql('apm-*');
});
});
}