-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into 172506-obsux-add-feedback-form-to-apm
- Loading branch information
Showing
13 changed files
with
348 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
packages/kbn-apm-synthtrace/src/scenarios/service_many_dependencies.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* 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 { ApmFields, Instance } from '@kbn/apm-synthtrace-client'; | ||
import { service } from '@kbn/apm-synthtrace-client/src/lib/apm/service'; | ||
import { Scenario } from '../cli/scenario'; | ||
import { RunOptions } from '../cli/utils/parse_run_cli_flags'; | ||
import { getSynthtraceEnvironment } from '../lib/utils/get_synthtrace_environment'; | ||
import { withClient } from '../lib/utils/with_client'; | ||
|
||
const ENVIRONMENT = getSynthtraceEnvironment(__filename); | ||
const MAX_DEPENDENCIES = 10000; | ||
const MAX_DEPENDENCIES_PER_SERVICE = 500; | ||
const MAX_SERVICES = 20; | ||
|
||
const scenario: Scenario<ApmFields> = async (runOptions: RunOptions) => { | ||
return { | ||
generate: ({ range, clients: { apmEsClient } }) => { | ||
const javaInstances = Array.from({ length: MAX_SERVICES }).map((_, index) => | ||
service(`opbeans-java-${index}`, ENVIRONMENT, 'java').instance(`java-instance-${index}`) | ||
); | ||
|
||
const instanceDependencies = (instance: Instance, startIndex: number) => { | ||
const rate = range.ratePerMinute(60); | ||
|
||
return rate.generator((timestamp, index) => { | ||
const currentIndex = index % MAX_DEPENDENCIES_PER_SERVICE; | ||
const destination = (startIndex + currentIndex) % MAX_DEPENDENCIES; | ||
|
||
const span = instance | ||
.transaction({ transactionName: 'GET /java' }) | ||
.timestamp(timestamp) | ||
.duration(400) | ||
.success() | ||
.children( | ||
instance | ||
.span({ | ||
spanName: 'GET apm-*/_search', | ||
spanType: 'db', | ||
spanSubtype: 'elasticsearch', | ||
}) | ||
.destination(`elasticsearch/${destination}`) | ||
.timestamp(timestamp) | ||
.duration(200) | ||
.success() | ||
); | ||
|
||
return span; | ||
}); | ||
}; | ||
|
||
return withClient( | ||
apmEsClient, | ||
javaInstances.map((instance, index) => | ||
instanceDependencies(instance, (index * MAX_DEPENDENCIES_PER_SERVICE) % MAX_DEPENDENCIES) | ||
) | ||
); | ||
}, | ||
}; | ||
}; | ||
|
||
export default scenario; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
x-pack/plugins/apm/ftr_e2e/cypress/e2e/dependencies/generate_many_dependencies.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* 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; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { apm, Instance, timerange } from '@kbn/apm-synthtrace-client'; | ||
|
||
const MAX_DEPENDENCIES = 10000; | ||
const MAX_DEPENDENCIES_PER_SERVICE = 500; | ||
const MAX_SERVICES = 20; | ||
|
||
export function generateManyDependencies({ | ||
from, | ||
to, | ||
}: { | ||
from: number; | ||
to: number; | ||
}) { | ||
const instances = Array.from({ length: MAX_SERVICES }).map((_, index) => | ||
apm | ||
.service({ | ||
name: `synth-java-${index}`, | ||
environment: 'production', | ||
agentName: 'java', | ||
}) | ||
.instance(`java-instance-${index}`) | ||
); | ||
|
||
const instanceDependencies = (instance: Instance, startIndex: number) => { | ||
return Array.from( | ||
timerange(new Date(from), new Date(to)) | ||
.interval('1m') | ||
.rate(60) | ||
.generator((timestamp, index) => { | ||
const currentIndex = index % MAX_DEPENDENCIES_PER_SERVICE; | ||
const destination = (startIndex + currentIndex) % MAX_DEPENDENCIES; | ||
|
||
const span = instance | ||
.transaction({ transactionName: 'GET /java' }) | ||
.timestamp(timestamp) | ||
.duration(400) | ||
.success() | ||
.children( | ||
instance | ||
.span({ | ||
spanName: 'GET apm-*/_search', | ||
spanType: 'db', | ||
spanSubtype: 'elasticsearch', | ||
}) | ||
.destination(`elasticsearch/${destination}`) | ||
.timestamp(timestamp) | ||
.duration(200) | ||
.success() | ||
); | ||
|
||
return span; | ||
}) | ||
); | ||
}; | ||
|
||
return instances.flatMap((instance, index) => | ||
instanceDependencies( | ||
instance, | ||
(index * MAX_DEPENDENCIES_PER_SERVICE) % MAX_DEPENDENCIES | ||
) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.