Combining other bucket groups scenarios into a single one (#149923)

No need to have `_other` bucket for services and transaction in separate
scenarios.
Additionally this scenario is prepared to receive number of services
and/or number of transaction groups through params:
```
e.g.
--scenarioOpts.services=10001 --scenarioOpts.txGroups=1001 
```

Relates to https://github.com/elastic/kibana/issues/146650 and
https://github.com/elastic/kibana/issues/146648.
This commit is contained in:
Yngrid Coello 2023-02-02 10:27:16 +01:00 committed by GitHub
parent e1afb6584d
commit 418cad17dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 74 deletions

View file

@ -24,9 +24,12 @@ const scenario: Scenario<ApmFields> = async ({ logger, scenarioOpts }) => {
const BUCKET_SIZE = (MAX_DURATION - MIN_DURATION) / MAX_BUCKETS;
const instances = lodashRange(0, numServices).flatMap((serviceId) => {
const serviceName = `service-${serviceId}`;
const serviceRange = [
...lodashRange(0, numServices).map((groupId) => `service-${groupId}`),
'_other',
];
const instances = serviceRange.flatMap((serviceName) => {
const services = ENVIRONMENTS.map((env) => apm.service(serviceName, env, 'go'));
return lodashRange(0, 2).flatMap((serviceNodeId) =>

View file

@ -1,72 +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 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 or the Server
* Side Public License, v 1.
*/
import { range as lodashRange } from 'lodash';
import { ApmFields, apm } from '@kbn/apm-synthtrace-client';
import { Scenario } from '../cli/scenario';
const scenario: Scenario<ApmFields> = async (runOptions) => {
const { logger } = runOptions;
const numServices = 10;
return {
generate: ({ range }) => {
const TRANSACTION_TYPES = ['request'];
const ENVIRONMENTS = ['production', 'development'];
const MIN_DURATION = 10;
const MAX_DURATION = 1000;
const MAX_BUCKETS = 50;
const BUCKET_SIZE = (MAX_DURATION - MIN_DURATION) / MAX_BUCKETS;
const serviceRange = [
...lodashRange(0, numServices).map((groupId) => `service-${groupId}`),
'_other',
];
const instances = serviceRange.flatMap((serviceName) => {
const services = ENVIRONMENTS.map((env) => apm.service(serviceName, env, 'go'));
return lodashRange(0, 2).flatMap((serviceNodeId) =>
services.map((service) => service.instance(`${serviceName}-${serviceNodeId}`))
);
});
const transactionGroupRange = [
...lodashRange(0, 10).map((groupId) => `transaction-${groupId}`),
'_other',
];
return range.ratePerMinute(60).generator((timestamp, timestampIndex) => {
return logger.perf(
'generate_events_for_timestamp ' + new Date(timestamp).toISOString(),
() => {
const events = instances.flatMap((instance) =>
transactionGroupRange.flatMap((groupId, groupIndex) => {
const duration = Math.round(
(timestampIndex % MAX_BUCKETS) * BUCKET_SIZE + MIN_DURATION
);
return instance
.transaction(groupId, TRANSACTION_TYPES[groupIndex % TRANSACTION_TYPES.length])
.timestamp(timestamp)
.duration(duration)
.outcome('success' as const);
})
);
return events;
}
);
});
},
};
};
export default scenario;