Skip to content

Commit

Permalink
[APM] Add scenario options for synthtrace (elastic#121034)
Browse files Browse the repository at this point in the history
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
dgieselaar and kibanamachine authored Jan 17, 2022
1 parent fc6b969 commit 75cf64d
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import { getApmWriteTargets } from '../../lib/apm/utils/get_apm_write_targets';
import { Scenario } from '../scenario';
import { getCommonServices } from '../utils/get_common_services';

const scenario: Scenario = async ({ target, logLevel }) => {
const scenario: Scenario = async ({ target, logLevel, scenarioOpts }) => {
const { client, logger } = getCommonServices({ target, logLevel });
const writeTargets = await getApmWriteTargets({ client });

const { numServices = 3 } = scenarioOpts || {};

return {
generate: ({ from, to }) => {
const numServices = 3;

const range = timerange(from, to);

const transactionName = '240rpm/75% 1000ms';
Expand Down
6 changes: 6 additions & 0 deletions packages/elastic-apm-synthtrace/src/scripts/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ function options(y: Argv) {
describe: 'Target to index',
string: true,
})
.option('scenarioOpts', {
describe: 'Options specific to the scenario',
coerce: (arg) => {
return arg as Record<string, any> | undefined;
},
})
.conflicts('to', 'live');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,15 @@ export function parseRunCliFlags(flags: RunCliFlags) {
}

return {
...pick(flags, 'target', 'workers', 'clientWorkers', 'batchSize', 'writeTarget'),
...pick(
flags,
'target',
'workers',
'clientWorkers',
'batchSize',
'writeTarget',
'scenarioOpts'
),
intervalInMs,
bucketSizeInMs,
logLevel: parsedLogLevel,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export async function startHistoricalDataUpload({
target,
file,
writeTarget,
scenarioOpts,
}: RunOptions & { from: number; to: number }) {
let requestedUntil: number = from;

Expand Down Expand Up @@ -57,6 +58,7 @@ export async function startHistoricalDataUpload({
target,
workers,
writeTarget,
scenarioOpts,
};

const worker = new Worker(Path.join(__dirname, './upload_next_batch.js'), {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export async function startLiveDataUpload({
logLevel,
workers,
writeTarget,
scenarioOpts,
}: RunOptions & { start: number }) {
let queuedEvents: ElasticsearchOutput[] = [];
let requestedUntil: number = start;
Expand All @@ -41,6 +42,7 @@ export async function startLiveDataUpload({
target,
workers,
writeTarget,
scenarioOpts,
});

function uploadNextBatch() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface WorkerData {
bucketFrom: number;
bucketTo: number;
file: string;
scenarioOpts: Record<string, any> | undefined;
logLevel: LogLevel;
clientWorkers: number;
batchSize: number;
Expand All @@ -39,6 +40,7 @@ const {
workers,
target,
writeTarget,
scenarioOpts,
} = workerData as WorkerData;

async function uploadNextBatch() {
Expand All @@ -63,6 +65,7 @@ async function uploadNextBatch() {
target,
workers,
writeTarget,
scenarioOpts,
});

const events = logger.perf('execute_scenario', () =>
Expand Down

0 comments on commit 75cf64d

Please sign in to comment.