mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[8.4] Add unique environment per scenario (#137282) | [APM] Improve synthtrace environment (#137697) (#137714)
* Add unique environment per scenario (#137282) (cherry picked from commit45de4de71d
) * [APM] Improve synthtrace environment (#137697) (cherry picked from commitdb882a06d6
)
This commit is contained in:
parent
1f07b80be2
commit
4b358c57d6
6 changed files with 37 additions and 7 deletions
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* 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 path from 'path';
|
||||
|
||||
export function getSynthtraceEnvironment(filename: string) {
|
||||
return `Synthtrace: ${path.parse(filename).name}`;
|
||||
}
|
|
@ -11,6 +11,9 @@ import { ApmFields } from '../lib/apm/apm_fields';
|
|||
import { Scenario } from '../cli/scenario';
|
||||
import { getLogger } from '../cli/utils/get_common_services';
|
||||
import { RunOptions } from '../cli/utils/parse_run_cli_flags';
|
||||
import { getSynthtraceEnvironment } from '../lib/utils/get_synthtrace_environment';
|
||||
|
||||
const ENVIRONMENT = getSynthtraceEnvironment(__filename);
|
||||
|
||||
const scenario: Scenario<ApmFields> = async (runOptions: RunOptions) => {
|
||||
const logger = getLogger(runOptions);
|
||||
|
@ -20,7 +23,7 @@ const scenario: Scenario<ApmFields> = async (runOptions: RunOptions) => {
|
|||
const range = timerange(from, to);
|
||||
const timestamps = range.interval('1s').rate(3);
|
||||
|
||||
const instance = apm.service('lambda-python', 'production', 'python').instance('instance');
|
||||
const instance = apm.service('lambda-python', ENVIRONMENT, 'python').instance('instance');
|
||||
|
||||
const traceEventsSetups = [
|
||||
{ functionName: 'lambda-python-1', coldStart: true },
|
||||
|
|
|
@ -13,6 +13,9 @@ import { Instance } from '../lib/apm/instance';
|
|||
import { Scenario } from '../cli/scenario';
|
||||
import { getLogger } from '../cli/utils/get_common_services';
|
||||
import { RunOptions } from '../cli/utils/parse_run_cli_flags';
|
||||
import { getSynthtraceEnvironment } from '../lib/utils/get_synthtrace_environment';
|
||||
|
||||
const ENVIRONMENT = getSynthtraceEnvironment(__filename);
|
||||
|
||||
const scenario: Scenario<ApmFields> = async (runOptions: RunOptions) => {
|
||||
const logger = getLogger(runOptions);
|
||||
|
@ -32,7 +35,7 @@ const scenario: Scenario<ApmFields> = async (runOptions: RunOptions) => {
|
|||
apm
|
||||
.service(
|
||||
`${services[index % services.length]}-${languages[index % languages.length]}-${index}`,
|
||||
'production',
|
||||
ENVIRONMENT,
|
||||
languages[index % languages.length]
|
||||
)
|
||||
.instance('instance')
|
||||
|
|
|
@ -7,12 +7,16 @@
|
|||
*/
|
||||
|
||||
import { random } from 'lodash';
|
||||
|
||||
import { apm, timerange } from '..';
|
||||
import { Instance } from '../lib/apm/instance';
|
||||
import { Scenario } from '../cli/scenario';
|
||||
import { getLogger } from '../cli/utils/get_common_services';
|
||||
import { RunOptions } from '../cli/utils/parse_run_cli_flags';
|
||||
import { ApmFields } from '../lib/apm/apm_fields';
|
||||
import { getSynthtraceEnvironment } from '../lib/utils/get_synthtrace_environment';
|
||||
|
||||
const ENVIRONMENT = getSynthtraceEnvironment(__filename);
|
||||
|
||||
const scenario: Scenario<ApmFields> = async (runOptions: RunOptions) => {
|
||||
const logger = getLogger(runOptions);
|
||||
|
@ -31,7 +35,7 @@ const scenario: Scenario<ApmFields> = async (runOptions: RunOptions) => {
|
|||
apm
|
||||
.service(
|
||||
`${services[index % services.length]}-${languages[index % languages.length]}-${index}`,
|
||||
'production',
|
||||
ENVIRONMENT,
|
||||
languages[index % languages.length]
|
||||
)
|
||||
.instance('instance')
|
||||
|
|
|
@ -12,6 +12,9 @@ import { Instance } from '../lib/apm/instance';
|
|||
import { Scenario } from '../cli/scenario';
|
||||
import { getLogger } from '../cli/utils/get_common_services';
|
||||
import { RunOptions } from '../cli/utils/parse_run_cli_flags';
|
||||
import { getSynthtraceEnvironment } from '../lib/utils/get_synthtrace_environment';
|
||||
|
||||
const ENVIRONMENT = getSynthtraceEnvironment(__filename);
|
||||
|
||||
const scenario: Scenario<ApmFields> = async (runOptions: RunOptions) => {
|
||||
const logger = getLogger(runOptions);
|
||||
|
@ -29,7 +32,7 @@ const scenario: Scenario<ApmFields> = async (runOptions: RunOptions) => {
|
|||
const failedTimestamps = range.interval('1s').rate(1);
|
||||
|
||||
const instances = [...Array(numServices).keys()].map((index) =>
|
||||
apm.service(`opbeans-go-${index}`, 'production', 'go').instance('instance')
|
||||
apm.service(`opbeans-go-${index}`, ENVIRONMENT, 'go').instance('instance')
|
||||
);
|
||||
const instanceSpans = (instance: Instance) => {
|
||||
const successfulTraceEvents = successfulTimestamps.generator((timestamp) =>
|
||||
|
|
|
@ -10,6 +10,9 @@ import { compact, shuffle } from 'lodash';
|
|||
import { apm, ApmFields, EntityArrayIterable, timerange } from '..';
|
||||
import { generateLongId, generateShortId } from '../lib/utils/generate_id';
|
||||
import { Scenario } from '../cli/scenario';
|
||||
import { getSynthtraceEnvironment } from '../lib/utils/get_synthtrace_environment';
|
||||
|
||||
const ENVIRONMENT = getSynthtraceEnvironment(__filename);
|
||||
|
||||
function generateExternalSpanLinks() {
|
||||
// randomly creates external span links 0 - 10
|
||||
|
@ -31,7 +34,8 @@ const scenario: Scenario<ApmFields> = async () => {
|
|||
return {
|
||||
generate: ({ from, to }) => {
|
||||
const producerInternalOnlyInstance = apm
|
||||
.service('producer-internal-only', 'production', 'go')
|
||||
|
||||
.service('producer-internal-only', ENVIRONMENT, 'go')
|
||||
.instance('instance-a');
|
||||
const producerInternalOnlyEvents = timerange(
|
||||
new Date('2022-04-25T19:00:00.000Z'),
|
||||
|
@ -58,7 +62,7 @@ const scenario: Scenario<ApmFields> = async () => {
|
|||
const spanASpanLink = getSpanLinksFromEvents(producerInternalOnlyApmFields);
|
||||
|
||||
const producerConsumerInstance = apm
|
||||
.service('producer-consumer', 'production', 'java')
|
||||
.service('producer-consumer', ENVIRONMENT, 'java')
|
||||
.instance('instance-b');
|
||||
const producerConsumerEvents = timerange(from, to)
|
||||
.interval('1m')
|
||||
|
@ -84,7 +88,7 @@ const scenario: Scenario<ApmFields> = async () => {
|
|||
const producerConsumerApmFields = producerConsumerEvents.toArray();
|
||||
const spanBSpanLink = getSpanLinksFromEvents(producerConsumerApmFields);
|
||||
|
||||
const consumerInstance = apm.service('consumer', 'production', 'ruby').instance('instance-c');
|
||||
const consumerInstance = apm.service('consumer', ENVIRONMENT, 'ruby').instance('instance-c');
|
||||
const consumerEvents = timerange(from, to)
|
||||
.interval('1m')
|
||||
.rate(1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue