[8.x] [Inventory v2][APM] Remove redundant synthtrace scenario (#207716) (#207742)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Inventory v2][APM] Remove redundant synthtrace scenario
(#207716)](https://github.com/elastic/kibana/pull/207716)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT
[{"author":{"name":"jennypavlova","email":"dzheni.pavlova@elastic.co"},"sourceCommit":{"committedDate":"2025-01-22T11:38:15Z","message":"[Inventory
v2][APM] Remove redundant synthtrace scenario (#207716)\n\n##
Summary\r\n\r\nAs discussed
in\r\nhttps://github.com/elastic/kibana/pull/207305#discussion_r1924280917
we\r\ncan use `simple_logs` scenario for the same case instead of the
new\r\n`logs_only` so this PR removes
it.","sha":"10519c2d4a62a113bd1edbdf3f6079fd9e8bbc58","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","backport:prev-minor","ci:project-deploy-observability","Team:obs-ux-infra_services"],"title":"[Inventory
v2][APM] Remove redundant synthtrace
scenario","number":207716,"url":"https://github.com/elastic/kibana/pull/207716","mergeCommit":{"message":"[Inventory
v2][APM] Remove redundant synthtrace scenario (#207716)\n\n##
Summary\r\n\r\nAs discussed
in\r\nhttps://github.com/elastic/kibana/pull/207305#discussion_r1924280917
we\r\ncan use `simple_logs` scenario for the same case instead of the
new\r\n`logs_only` so this PR removes
it.","sha":"10519c2d4a62a113bd1edbdf3f6079fd9e8bbc58"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/207716","number":207716,"mergeCommit":{"message":"[Inventory
v2][APM] Remove redundant synthtrace scenario (#207716)\n\n##
Summary\r\n\r\nAs discussed
in\r\nhttps://github.com/elastic/kibana/pull/207305#discussion_r1924280917
we\r\ncan use `simple_logs` scenario for the same case instead of the
new\r\n`logs_only` so this PR removes
it.","sha":"10519c2d4a62a113bd1edbdf3f6079fd9e8bbc58"}}]}] BACKPORT-->

Co-authored-by: jennypavlova <dzheni.pavlova@elastic.co>
This commit is contained in:
Kibana Machine 2025-01-23 00:14:24 +11:00 committed by GitHub
parent cebdb9b2ce
commit 656bf4afce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,79 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import { LogDocument, log, generateShortId, generateLongId } from '@kbn/apm-synthtrace-client';
import { Scenario } from '../cli/scenario';
import { withClient } from '../lib/utils/with_client';
import { parseLogsScenarioOpts } from './helpers/logs_scenario_opts_parser';
import { IndexTemplateName } from '../lib/logs/custom_logsdb_index_templates';
import { getCluster, getCloudRegion, getCloudProvider } from './helpers/logs_mock_data';
const MESSAGE_LOG_LEVELS = [
{ message: 'A simple log', level: 'info' },
{ message: 'Yet another debug log', level: 'debug' },
{ message: 'Error with certificate: "ca_trusted_fingerprint"', level: 'error' },
];
const scenario: Scenario<LogDocument> = async (runOptions) => {
const { isLogsDb } = parseLogsScenarioOpts(runOptions.scenarioOpts);
return {
bootstrap: async ({ logsEsClient }) => {
if (isLogsDb) await logsEsClient.createIndexTemplate(IndexTemplateName.LogsDb);
},
generate: ({ range, clients: { logsEsClient } }) => {
const { logger } = runOptions;
const SERVICE_NAMES = Array(3)
.fill(null)
.map((_, idx) => `synth-service-logs-${idx}`);
const logs = range
.interval('1m')
.rate(1)
.generator((timestamp) => {
return Array(20)
.fill(0)
.map(() => {
const index = Math.floor(Math.random() * 3);
const { clusterId, clusterName } = getCluster(index);
const cloudRegion = getCloudRegion(index);
return log
.create({ isLogsDb })
.message(MESSAGE_LOG_LEVELS[index].message)
.logLevel(MESSAGE_LOG_LEVELS[index].level)
.service(SERVICE_NAMES[index])
.defaults({
'trace.id': generateShortId(),
'agent.name': 'synth-agent',
'orchestrator.cluster.name': clusterName,
'orchestrator.cluster.id': clusterId,
'orchestrator.resource.id': generateShortId(),
'cloud.provider': getCloudProvider(),
'cloud.region': cloudRegion,
'cloud.availability_zone': `${cloudRegion}a`,
'cloud.project.id': generateShortId(),
'cloud.instance.id': generateShortId(),
'log.file.path': `/logs/${generateLongId()}/error.txt`,
})
.timestamp(timestamp);
});
});
return [
withClient(
logsEsClient,
logger.perf('generating_logs', () => logs)
),
];
},
};
};
export default scenario;