mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
APM: converting params to destructured obj (#140450)
* service: converting params to destructured obj * transaction: convert params to destructuring obj * span/error: convert to destructure obj * error * browser * fixing span
This commit is contained in:
parent
acac4ca970
commit
4255bac100
63 changed files with 700 additions and 344 deletions
|
@ -27,7 +27,7 @@ This library can currently be used in two ways:
|
|||
```ts
|
||||
import { service, timerange, toElasticsearchOutput } from '@kbn/apm-synthtrace';
|
||||
|
||||
const instance = service('synth-go', 'production', 'go').instance('instance-a');
|
||||
const instance = service({name: 'synth-go', environment: 'production', agentName: 'go'}).instance('instance-a');
|
||||
|
||||
const from = new Date('2021-01-01T12:00:00.000Z').getTime();
|
||||
const to = new Date('2021-01-01T12:00:00.000Z').getTime();
|
||||
|
@ -37,7 +37,7 @@ const traceEvents = timerange(from, to)
|
|||
.rate(10)
|
||||
.flatMap((timestamp) =>
|
||||
instance
|
||||
.transaction('GET /api/product/list')
|
||||
.transaction({transactionName: 'GET /api/product/list'})
|
||||
.timestamp(timestamp)
|
||||
.duration(1000)
|
||||
.success()
|
||||
|
|
|
@ -12,7 +12,13 @@ import { RumSpan } from './rum_span';
|
|||
import { RumTransaction } from './rum_transaction';
|
||||
|
||||
export class Browser extends Entity<ApmFields> {
|
||||
transaction(transactionName: string, transactionType: string = 'page-load') {
|
||||
transaction({
|
||||
transactionName,
|
||||
transactionType = 'page-load',
|
||||
}: {
|
||||
transactionName: string;
|
||||
transactionType?: string;
|
||||
}) {
|
||||
return new RumTransaction({
|
||||
...this.fields,
|
||||
'transaction.name': transactionName,
|
||||
|
@ -20,7 +26,15 @@ export class Browser extends Entity<ApmFields> {
|
|||
});
|
||||
}
|
||||
|
||||
span(spanName: string, spanType: string, spanSubtype: string) {
|
||||
span({
|
||||
spanName,
|
||||
spanType,
|
||||
spanSubtype,
|
||||
}: {
|
||||
spanName: string;
|
||||
spanType: string;
|
||||
spanSubtype: string;
|
||||
}) {
|
||||
return new RumSpan({
|
||||
...this.fields,
|
||||
'span.name': spanName,
|
||||
|
@ -30,11 +44,19 @@ export class Browser extends Entity<ApmFields> {
|
|||
}
|
||||
}
|
||||
|
||||
export function browser(serviceName: string, production: string, userAgent: ApmUserAgentFields) {
|
||||
export function browser({
|
||||
serviceName,
|
||||
environment,
|
||||
userAgent,
|
||||
}: {
|
||||
serviceName: string;
|
||||
environment: string;
|
||||
userAgent: ApmUserAgentFields;
|
||||
}) {
|
||||
return new Browser({
|
||||
'agent.name': 'rum-js',
|
||||
'service.name': serviceName,
|
||||
'service.environment': production,
|
||||
'service.environment': environment,
|
||||
...userAgent,
|
||||
});
|
||||
}
|
||||
|
|
|
@ -14,7 +14,13 @@ import { Transaction } from './transaction';
|
|||
import { ApmApplicationMetricFields, ApmFields } from './apm_fields';
|
||||
|
||||
export class Instance extends Entity<ApmFields> {
|
||||
transaction(transactionName: string, transactionType = 'request') {
|
||||
transaction({
|
||||
transactionName,
|
||||
transactionType = 'request',
|
||||
}: {
|
||||
transactionName: string;
|
||||
transactionType?: string;
|
||||
}) {
|
||||
return new Transaction({
|
||||
...this.fields,
|
||||
'transaction.name': transactionName,
|
||||
|
@ -22,7 +28,16 @@ export class Instance extends Entity<ApmFields> {
|
|||
});
|
||||
}
|
||||
|
||||
span(spanName: string, spanType: string, spanSubtype?: string, apmFields?: ApmFields) {
|
||||
span({
|
||||
spanName,
|
||||
spanType,
|
||||
spanSubtype,
|
||||
...apmFields
|
||||
}: {
|
||||
spanName: string;
|
||||
spanType: string;
|
||||
spanSubtype?: string;
|
||||
} & ApmFields) {
|
||||
return new Span({
|
||||
...this.fields,
|
||||
...apmFields,
|
||||
|
@ -32,7 +47,15 @@ export class Instance extends Entity<ApmFields> {
|
|||
});
|
||||
}
|
||||
|
||||
error(message: string, type?: string, groupingName?: string) {
|
||||
error({
|
||||
message,
|
||||
type,
|
||||
groupingName,
|
||||
}: {
|
||||
message: string;
|
||||
type?: string;
|
||||
groupingName?: string;
|
||||
}) {
|
||||
return new ApmError({
|
||||
...this.fields,
|
||||
'error.exception': [{ message, ...(type ? { type } : {}) }],
|
||||
|
|
|
@ -20,7 +20,15 @@ export class Service extends Entity<ApmFields> {
|
|||
}
|
||||
}
|
||||
|
||||
export function service(name: string, environment: string, agentName: string) {
|
||||
export function service({
|
||||
name,
|
||||
environment,
|
||||
agentName,
|
||||
}: {
|
||||
name: string;
|
||||
environment: string;
|
||||
agentName: string;
|
||||
}) {
|
||||
return new Service({
|
||||
'service.name': name,
|
||||
'service.environment': environment,
|
||||
|
|
|
@ -47,7 +47,7 @@ export function httpExitSpan({
|
|||
}: {
|
||||
spanName: string;
|
||||
destinationUrl: string;
|
||||
}): [string, string, string, ApmFields] {
|
||||
}) {
|
||||
// origin: 'http://opbeans-go:3000',
|
||||
// host: 'opbeans-go:3000',
|
||||
// hostname: 'opbeans-go',
|
||||
|
@ -57,39 +57,29 @@ export function httpExitSpan({
|
|||
const spanType = 'external';
|
||||
const spanSubType = 'http';
|
||||
|
||||
return [
|
||||
return {
|
||||
spanName,
|
||||
spanType,
|
||||
spanSubType,
|
||||
{
|
||||
'destination.address': destination.hostname,
|
||||
'destination.port': parseInt(destination.port, 10),
|
||||
'service.target.name': destination.host,
|
||||
'span.destination.service.name': destination.origin,
|
||||
'span.destination.service.resource': destination.host,
|
||||
'span.destination.service.type': 'external',
|
||||
},
|
||||
];
|
||||
'destination.address': destination.hostname,
|
||||
'destination.port': parseInt(destination.port, 10),
|
||||
'service.target.name': destination.host,
|
||||
'span.destination.service.name': destination.origin,
|
||||
'span.destination.service.resource': destination.host,
|
||||
'span.destination.service.type': 'external',
|
||||
};
|
||||
}
|
||||
|
||||
export function dbExitSpan({
|
||||
spanName,
|
||||
spanSubType,
|
||||
}: {
|
||||
spanName: string;
|
||||
spanSubType?: string;
|
||||
}): [string, string, string | undefined, ApmFields] {
|
||||
export function dbExitSpan({ spanName, spanSubType }: { spanName: string; spanSubType?: string }) {
|
||||
const spanType = 'db';
|
||||
|
||||
return [
|
||||
return {
|
||||
spanName,
|
||||
spanType,
|
||||
spanSubType,
|
||||
{
|
||||
'service.target.type': spanSubType,
|
||||
'span.destination.service.name': spanSubType,
|
||||
'span.destination.service.resource': spanSubType,
|
||||
'span.destination.service.type': spanType,
|
||||
},
|
||||
];
|
||||
'service.target.type': spanSubType,
|
||||
'span.destination.service.name': spanSubType,
|
||||
'span.destination.service.resource': spanSubType,
|
||||
'span.destination.service.type': spanType,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -23,7 +23,9 @@ const scenario: Scenario<ApmFields> = async (runOptions: RunOptions) => {
|
|||
const range = timerange(from, to);
|
||||
const timestamps = range.ratePerMinute(180);
|
||||
|
||||
const instance = apm.service('lambda-python', ENVIRONMENT, 'python').instance('instance');
|
||||
const instance = apm
|
||||
.service({ name: 'lambda-python', environment: ENVIRONMENT, agentName: 'python' })
|
||||
.instance('instance');
|
||||
|
||||
const traceEventsSetups = [
|
||||
{ functionName: 'lambda-python-1', coldStart: true },
|
||||
|
@ -33,7 +35,7 @@ const scenario: Scenario<ApmFields> = async (runOptions: RunOptions) => {
|
|||
const traceEvents = ({ functionName, coldStart }: typeof traceEventsSetups[0]) => {
|
||||
return timestamps.generator((timestamp) =>
|
||||
instance
|
||||
.transaction('GET /order/{id}')
|
||||
.transaction({ transactionName: 'GET /order/{id}' })
|
||||
.defaults({
|
||||
'service.runtime.name': 'AWS_Lambda_python3.8',
|
||||
'cloud.provider': 'aws',
|
||||
|
|
|
@ -23,23 +23,27 @@ const scenario: Scenario<ApmFields> = async (runOptions: RunOptions) => {
|
|||
const transactionName = '240rpm/75% 1000ms';
|
||||
const successfulTimestamps = range.interval('1s').rate(3);
|
||||
|
||||
const opbeansRum = apm.service('opbeans-rum', ENVIRONMENT, 'rum-js').instance('my-instance');
|
||||
const opbeansNode = apm
|
||||
.service('opbeans-node', ENVIRONMENT, 'nodejs')
|
||||
const opbeansRum = apm
|
||||
.service({ name: 'opbeans-rum', environment: ENVIRONMENT, agentName: 'rum-js' })
|
||||
.instance('my-instance');
|
||||
const opbeansNode = apm
|
||||
.service({ name: 'opbeans-node', environment: ENVIRONMENT, agentName: 'nodejs' })
|
||||
.instance('my-instance');
|
||||
const opbeansGo = apm
|
||||
.service({ name: 'opbeans-go', environment: ENVIRONMENT, agentName: 'go' })
|
||||
.instance('my-instance');
|
||||
const opbeansGo = apm.service('opbeans-go', ENVIRONMENT, 'go').instance('my-instance');
|
||||
|
||||
const traces = successfulTimestamps.generator((timestamp) => {
|
||||
// opbeans-rum
|
||||
return opbeansRum
|
||||
.transaction(transactionName)
|
||||
.transaction({ transactionName })
|
||||
.duration(400)
|
||||
.timestamp(timestamp)
|
||||
.children(
|
||||
// opbeans-rum -> opbeans-node
|
||||
opbeansRum
|
||||
.span(
|
||||
...httpExitSpan({
|
||||
httpExitSpan({
|
||||
spanName: 'GET /api/products/top',
|
||||
destinationUrl: 'http://opbeans-node:3000',
|
||||
})
|
||||
|
@ -50,14 +54,14 @@ const scenario: Scenario<ApmFields> = async (runOptions: RunOptions) => {
|
|||
.children(
|
||||
// opbeans-node
|
||||
opbeansNode
|
||||
.transaction('Initial transaction in opbeans-node')
|
||||
.transaction({ transactionName: 'Initial transaction in opbeans-node' })
|
||||
.duration(300)
|
||||
.timestamp(timestamp)
|
||||
.children(
|
||||
opbeansNode
|
||||
// opbeans-node -> opbeans-go
|
||||
.span(
|
||||
...httpExitSpan({
|
||||
httpExitSpan({
|
||||
spanName: 'GET opbeans-go:3000',
|
||||
destinationUrl: 'http://opbeans-go:3000',
|
||||
})
|
||||
|
@ -69,12 +73,12 @@ const scenario: Scenario<ApmFields> = async (runOptions: RunOptions) => {
|
|||
// opbeans-go
|
||||
opbeansGo
|
||||
|
||||
.transaction('Initial transaction in opbeans-go')
|
||||
.transaction({ transactionName: 'Initial transaction in opbeans-go' })
|
||||
.timestamp(timestamp)
|
||||
.duration(200)
|
||||
.children(
|
||||
opbeansGo
|
||||
.span('custom_operation', 'custom')
|
||||
.span({ spanName: 'custom_operation', spanType: 'custom' })
|
||||
.timestamp(timestamp)
|
||||
.duration(100)
|
||||
.success()
|
||||
|
|
|
@ -28,11 +28,11 @@ const scenario: Scenario<ApmFields> = async (runOptions: RunOptions) => {
|
|||
|
||||
const instances = services.map((service, index) =>
|
||||
apm
|
||||
.service(
|
||||
`${service}-${languages[index % languages.length]}`,
|
||||
'production',
|
||||
languages[index % languages.length]
|
||||
)
|
||||
.service({
|
||||
name: `${service}-${languages[index % languages.length]}`,
|
||||
environment: 'production',
|
||||
agentName: languages[index % languages.length],
|
||||
})
|
||||
.instance(`instance-${index}`)
|
||||
);
|
||||
const entities = [
|
||||
|
@ -68,18 +68,22 @@ const scenario: Scenario<ApmFields> = async (runOptions: RunOptions) => {
|
|||
const generateError = index % random(mod, 9) === 0;
|
||||
const generateChildError = index % random(mod, 9) === 0;
|
||||
const span = instance
|
||||
.transaction(url)
|
||||
.transaction({ transactionName: url })
|
||||
.timestamp(timestamp)
|
||||
.duration(duration)
|
||||
.children(
|
||||
instance
|
||||
.span('GET apm-*/_search', 'db', 'elasticsearch')
|
||||
.span({
|
||||
spanName: 'GET apm-*/_search',
|
||||
spanType: 'db',
|
||||
spanSubtype: 'elasticsearch',
|
||||
})
|
||||
.duration(childDuration)
|
||||
.destination('elasticsearch')
|
||||
.timestamp(timestamp)
|
||||
.outcome(generateError && generateChildError ? 'failure' : 'success'),
|
||||
instance
|
||||
.span('custom_operation', 'custom')
|
||||
.span({ spanName: 'custom_operation', spanType: 'custom' })
|
||||
.duration(remainderDuration)
|
||||
.success()
|
||||
.timestamp(timestamp + childDuration)
|
||||
|
@ -88,7 +92,9 @@ const scenario: Scenario<ApmFields> = async (runOptions: RunOptions) => {
|
|||
? span.success()
|
||||
: span
|
||||
.failure()
|
||||
.errors(instance.error(`No handler for ${url}`).timestamp(timestamp + 50));
|
||||
.errors(
|
||||
instance.error({ message: `No handler for ${url}` }).timestamp(timestamp + 50)
|
||||
);
|
||||
});
|
||||
|
||||
return successfulTraceEvents;
|
||||
|
|
|
@ -32,11 +32,13 @@ const scenario: Scenario<ApmFields> = async (runOptions: RunOptions) => {
|
|||
|
||||
const instances = services.map((service, index) =>
|
||||
apm
|
||||
.service(
|
||||
`${services[index % services.length]}-${languages[index % languages.length]}-${index}`,
|
||||
ENVIRONMENT,
|
||||
languages[index % languages.length]
|
||||
)
|
||||
.service({
|
||||
name: `${services[index % services.length]}-${
|
||||
languages[index % languages.length]
|
||||
}-${index}`,
|
||||
environment: ENVIRONMENT,
|
||||
agentName: languages[index % languages.length],
|
||||
})
|
||||
.instance(`instance-${index}`)
|
||||
);
|
||||
|
||||
|
@ -53,18 +55,22 @@ const scenario: Scenario<ApmFields> = async (runOptions: RunOptions) => {
|
|||
const generateError = index % random(mod, 9) === 0;
|
||||
const generateChildError = index % random(mod, 9) === 0;
|
||||
const span = instance
|
||||
.transaction(url)
|
||||
.transaction({ transactionName: url })
|
||||
.timestamp(timestamp)
|
||||
.duration(duration)
|
||||
.children(
|
||||
instance
|
||||
.span('GET apm-*/_search', 'db', 'elasticsearch')
|
||||
.span({
|
||||
spanName: 'GET apm-*/_search',
|
||||
spanType: 'db',
|
||||
spanSubtype: 'elasticsearch',
|
||||
})
|
||||
.duration(childDuration)
|
||||
.destination('elasticsearch')
|
||||
.timestamp(timestamp)
|
||||
.outcome(generateError && generateChildError ? 'failure' : 'success'),
|
||||
instance
|
||||
.span('custom_operation', 'custom')
|
||||
.span({ spanName: 'custom_operation', spanType: 'custom' })
|
||||
.duration(remainderDuration)
|
||||
.success()
|
||||
.timestamp(timestamp + childDuration)
|
||||
|
@ -73,7 +79,9 @@ const scenario: Scenario<ApmFields> = async (runOptions: RunOptions) => {
|
|||
? span.success()
|
||||
: span
|
||||
.failure()
|
||||
.errors(instance.error(`No handler for ${url}`).timestamp(timestamp + 50));
|
||||
.errors(
|
||||
instance.error({ message: `No handler for ${url}` }).timestamp(timestamp + 50)
|
||||
);
|
||||
});
|
||||
|
||||
return successfulTraceEvents;
|
||||
|
|
|
@ -33,11 +33,13 @@ const scenario: Scenario<ApmFields> = async (runOptions: RunOptions) => {
|
|||
|
||||
const instances = [...Array(numServices).keys()].map((index) =>
|
||||
apm
|
||||
.service(
|
||||
`${services[index % services.length]}-${languages[index % languages.length]}-${index}`,
|
||||
ENVIRONMENT,
|
||||
languages[index % languages.length]
|
||||
)
|
||||
.service({
|
||||
name: `${services[index % services.length]}-${
|
||||
languages[index % languages.length]
|
||||
}-${index}`,
|
||||
environment: ENVIRONMENT,
|
||||
agentName: languages[index % languages.length],
|
||||
})
|
||||
.instance(`instance-${index}`)
|
||||
);
|
||||
|
||||
|
@ -53,18 +55,22 @@ const scenario: Scenario<ApmFields> = async (runOptions: RunOptions) => {
|
|||
const generateError = random(1, 4) % 3 === 0;
|
||||
const generateChildError = random(0, 5) % 2 === 0;
|
||||
const span = instance
|
||||
.transaction(url)
|
||||
.transaction({ transactionName: url })
|
||||
.timestamp(timestamp)
|
||||
.duration(duration)
|
||||
.children(
|
||||
instance
|
||||
.span('GET apm-*/_search', 'db', 'elasticsearch')
|
||||
.span({
|
||||
spanName: 'GET apm-*/_search',
|
||||
spanType: 'db',
|
||||
spanSubtype: 'elasticsearch',
|
||||
})
|
||||
.duration(childDuration)
|
||||
.destination('elasticsearch')
|
||||
.timestamp(timestamp)
|
||||
.outcome(generateError && generateChildError ? 'failure' : 'success'),
|
||||
instance
|
||||
.span('custom_operation', 'custom')
|
||||
.span({ spanName: 'custom_operation', spanType: 'custom' })
|
||||
.duration(remainderDuration)
|
||||
.success()
|
||||
.timestamp(timestamp + childDuration)
|
||||
|
@ -73,7 +79,9 @@ const scenario: Scenario<ApmFields> = async (runOptions: RunOptions) => {
|
|||
? span.success()
|
||||
: span
|
||||
.failure()
|
||||
.errors(instance.error(`No handler for ${url}`).timestamp(timestamp + 50));
|
||||
.errors(
|
||||
instance.error({ message: `No handler for ${url}` }).timestamp(timestamp + 50)
|
||||
);
|
||||
});
|
||||
|
||||
return successfulTraceEvents;
|
||||
|
|
|
@ -31,24 +31,30 @@ const scenario: Scenario<ApmFields> = async (runOptions: RunOptions) => {
|
|||
const failedTimestamps = range.ratePerMinute(180);
|
||||
|
||||
const instances = [...Array(numServices).keys()].map((index) =>
|
||||
apm.service(`opbeans-go-${index}`, ENVIRONMENT, 'go').instance('instance')
|
||||
apm
|
||||
.service({ name: `opbeans-go-${index}`, environment: ENVIRONMENT, agentName: 'go' })
|
||||
.instance('instance')
|
||||
);
|
||||
const instanceSpans = (instance: Instance) => {
|
||||
const successfulTraceEvents = successfulTimestamps.generator((timestamp) =>
|
||||
instance
|
||||
.transaction(transactionName)
|
||||
.transaction({ transactionName })
|
||||
.timestamp(timestamp)
|
||||
.duration(1000)
|
||||
.success()
|
||||
.children(
|
||||
instance
|
||||
.span('GET apm-*/_search', 'db', 'elasticsearch')
|
||||
.span({
|
||||
spanName: 'GET apm-*/_search',
|
||||
spanType: 'db',
|
||||
spanSubtype: 'elasticsearch',
|
||||
})
|
||||
.duration(1000)
|
||||
.success()
|
||||
.destination('elasticsearch')
|
||||
.timestamp(timestamp),
|
||||
instance
|
||||
.span('custom_operation', 'custom')
|
||||
.span({ spanName: 'custom_operation', spanType: 'custom' })
|
||||
.duration(100)
|
||||
.success()
|
||||
.timestamp(timestamp)
|
||||
|
@ -57,12 +63,14 @@ const scenario: Scenario<ApmFields> = async (runOptions: RunOptions) => {
|
|||
|
||||
const failedTraceEvents = failedTimestamps.generator((timestamp) =>
|
||||
instance
|
||||
.transaction(transactionName)
|
||||
.transaction({ transactionName })
|
||||
.timestamp(timestamp)
|
||||
.duration(1000)
|
||||
.failure()
|
||||
.errors(
|
||||
instance.error('[ResponseError] index_not_found_exception').timestamp(timestamp + 50)
|
||||
instance
|
||||
.error({ message: '[ResponseError] index_not_found_exception' })
|
||||
.timestamp(timestamp + 50)
|
||||
)
|
||||
);
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ const scenario: Scenario<ApmFields> = async () => {
|
|||
generate: ({ from, to }) => {
|
||||
const producerInternalOnlyInstance = apm
|
||||
|
||||
.service('producer-internal-only', ENVIRONMENT, 'go')
|
||||
.service({ name: 'producer-internal-only', environment: ENVIRONMENT, agentName: 'go' })
|
||||
.instance('instance-a');
|
||||
const producerInternalOnlyEvents = timerange(
|
||||
new Date('2022-04-25T19:00:00.000Z'),
|
||||
|
@ -45,13 +45,13 @@ const scenario: Scenario<ApmFields> = async () => {
|
|||
.rate(1)
|
||||
.generator((timestamp) => {
|
||||
return producerInternalOnlyInstance
|
||||
.transaction('Transaction A')
|
||||
.transaction({ transactionName: 'Transaction A' })
|
||||
.timestamp(timestamp)
|
||||
.duration(1000)
|
||||
.success()
|
||||
.children(
|
||||
producerInternalOnlyInstance
|
||||
.span('Span A', 'custom')
|
||||
.span({ spanName: 'Span A', spanType: 'custom' })
|
||||
.timestamp(timestamp + 50)
|
||||
.duration(100)
|
||||
.success()
|
||||
|
@ -62,20 +62,20 @@ const scenario: Scenario<ApmFields> = async () => {
|
|||
const spanASpanLink = getSpanLinksFromEvents(producerInternalOnlyApmFields);
|
||||
|
||||
const producerConsumerInstance = apm
|
||||
.service('producer-consumer', ENVIRONMENT, 'java')
|
||||
.service({ name: 'producer-consumer', environment: ENVIRONMENT, agentName: 'java' })
|
||||
.instance('instance-b');
|
||||
const producerConsumerEvents = timerange(from, to)
|
||||
.interval('1m')
|
||||
.rate(1)
|
||||
.generator((timestamp) => {
|
||||
return producerConsumerInstance
|
||||
.transaction('Transaction B')
|
||||
.transaction({ transactionName: 'Transaction B' })
|
||||
.timestamp(timestamp)
|
||||
.duration(1000)
|
||||
.success()
|
||||
.children(
|
||||
producerConsumerInstance
|
||||
.span('Span B', 'external')
|
||||
.span({ spanName: 'Span B', spanType: 'external' })
|
||||
.defaults({
|
||||
'span.links': shuffle([...generateExternalSpanLinks(), ...spanASpanLink]),
|
||||
})
|
||||
|
@ -88,19 +88,21 @@ const scenario: Scenario<ApmFields> = async () => {
|
|||
const producerConsumerApmFields = producerConsumerEvents.toArray();
|
||||
const spanBSpanLink = getSpanLinksFromEvents(producerConsumerApmFields);
|
||||
|
||||
const consumerInstance = apm.service('consumer', ENVIRONMENT, 'ruby').instance('instance-c');
|
||||
const consumerInstance = apm
|
||||
.service({ name: 'consumer', environment: ENVIRONMENT, agentName: 'ruby' })
|
||||
.instance('instance-c');
|
||||
const consumerEvents = timerange(from, to)
|
||||
.interval('1m')
|
||||
.rate(1)
|
||||
.generator((timestamp) => {
|
||||
return consumerInstance
|
||||
.transaction('Transaction C')
|
||||
.transaction({ transactionName: 'Transaction C' })
|
||||
.timestamp(timestamp)
|
||||
.duration(1000)
|
||||
.success()
|
||||
.children(
|
||||
consumerInstance
|
||||
.span('Span C', 'external')
|
||||
.span({ spanName: 'Span C', spanType: 'external' })
|
||||
.defaults({ 'span.links': spanBSpanLink })
|
||||
.timestamp(timestamp + 50)
|
||||
.duration(900)
|
||||
|
|
|
@ -19,7 +19,11 @@ describe('DSL invocations', () => {
|
|||
new Date('2021-01-01T00:00:00.000Z'),
|
||||
new Date('2021-01-01T00:15:00.000Z')
|
||||
);
|
||||
const javaService = apm.service('opbeans-java', 'production', 'java');
|
||||
const javaService = apm.service({
|
||||
name: 'opbeans-java',
|
||||
environment: 'production',
|
||||
agentName: 'java',
|
||||
});
|
||||
const javaInstance = javaService.instance('instance-1');
|
||||
let globalSeq = 0;
|
||||
|
||||
|
@ -28,13 +32,13 @@ describe('DSL invocations', () => {
|
|||
.rate(1)
|
||||
.generator((timestamp, index) =>
|
||||
javaInstance
|
||||
.transaction(`GET /api/product/${index}/${globalSeq++}`)
|
||||
.transaction({ transactionName: `GET /api/product/${index}/${globalSeq++}` })
|
||||
.duration(1000)
|
||||
.success()
|
||||
.timestamp(timestamp)
|
||||
.children(
|
||||
javaInstance
|
||||
.span('GET apm-*/_search', 'db', 'elasticsearch')
|
||||
.span({ spanName: 'GET apm-*/_search', spanType: 'db', spanSubtype: 'elasticsearch' })
|
||||
.success()
|
||||
.duration(900)
|
||||
.timestamp(timestamp + 50)
|
||||
|
|
|
@ -19,7 +19,11 @@ describe('rate per minute calculations', () => {
|
|||
let events: Array<Record<string, any>>;
|
||||
|
||||
beforeEach(() => {
|
||||
const javaService = apm.service('opbeans-java', 'production', 'java');
|
||||
const javaService = apm.service({
|
||||
name: 'opbeans-java',
|
||||
environment: 'production',
|
||||
agentName: 'java',
|
||||
});
|
||||
const javaInstance = javaService.instance('instance-1');
|
||||
|
||||
iterable = range
|
||||
|
@ -27,13 +31,13 @@ describe('rate per minute calculations', () => {
|
|||
.rate(1)
|
||||
.generator((timestamp) =>
|
||||
javaInstance
|
||||
.transaction('GET /api/product/list')
|
||||
.transaction({ transactionName: 'GET /api/product/list' })
|
||||
.duration(1000)
|
||||
.success()
|
||||
.timestamp(timestamp)
|
||||
.children(
|
||||
javaInstance
|
||||
.span('GET apm-*/_search', 'db', 'elasticsearch')
|
||||
.span({ spanName: 'GET apm-*/_search', spanType: 'db', spanSubtype: 'elasticsearch' })
|
||||
.success()
|
||||
.duration(900)
|
||||
.timestamp(timestamp + 50)
|
||||
|
|
|
@ -16,7 +16,11 @@ describe('simple trace', () => {
|
|||
let events: Array<Record<string, any>>;
|
||||
|
||||
beforeEach(() => {
|
||||
const javaService = apm.service('opbeans-java', 'production', 'java');
|
||||
const javaService = apm.service({
|
||||
name: 'opbeans-java',
|
||||
environment: 'production',
|
||||
agentName: 'java',
|
||||
});
|
||||
const javaInstance = javaService.instance('instance-1').containerId('instance-1');
|
||||
|
||||
const range = timerange(
|
||||
|
@ -29,13 +33,13 @@ describe('simple trace', () => {
|
|||
.rate(1)
|
||||
.generator((timestamp) =>
|
||||
javaInstance
|
||||
.transaction('GET /api/product/list')
|
||||
.transaction({ transactionName: 'GET /api/product/list' })
|
||||
.duration(1000)
|
||||
.success()
|
||||
.timestamp(timestamp)
|
||||
.children(
|
||||
javaInstance
|
||||
.span('GET apm-*/_search', 'db', 'elasticsearch')
|
||||
.span({ spanName: 'GET apm-*/_search', spanType: 'db', spanSubtype: 'elasticsearch' })
|
||||
.success()
|
||||
.duration(900)
|
||||
.timestamp(timestamp + 50)
|
||||
|
|
|
@ -16,7 +16,11 @@ describe('transaction metrics', () => {
|
|||
let events: Array<Record<string, any>>;
|
||||
|
||||
beforeEach(() => {
|
||||
const javaService = apm.service('opbeans-java', 'production', 'java');
|
||||
const javaService = apm.service({
|
||||
name: 'opbeans-java',
|
||||
environment: 'production',
|
||||
agentName: 'java',
|
||||
});
|
||||
const javaInstance = javaService.instance('instance-1');
|
||||
|
||||
const range = timerange(
|
||||
|
@ -25,7 +29,10 @@ describe('transaction metrics', () => {
|
|||
);
|
||||
|
||||
const span = (timestamp: number) =>
|
||||
javaInstance.transaction('GET /api/product/list').duration(1000).timestamp(timestamp);
|
||||
javaInstance
|
||||
.transaction({ transactionName: 'GET /api/product/list' })
|
||||
.duration(1000)
|
||||
.timestamp(timestamp);
|
||||
|
||||
const processor = new StreamProcessor<ApmFields>({
|
||||
processors: [getTransactionMetrics],
|
||||
|
|
|
@ -16,7 +16,11 @@ describe('span destination metrics', () => {
|
|||
let events: Array<Record<string, any>>;
|
||||
|
||||
beforeEach(() => {
|
||||
const javaService = apm.service('opbeans-java', 'production', 'java');
|
||||
const javaService = apm.service({
|
||||
name: 'opbeans-java',
|
||||
environment: 'production',
|
||||
agentName: 'java',
|
||||
});
|
||||
const javaInstance = javaService.instance('instance-1');
|
||||
|
||||
const range = timerange(
|
||||
|
@ -31,13 +35,17 @@ describe('span destination metrics', () => {
|
|||
.rate(25)
|
||||
.generator((timestamp) =>
|
||||
javaInstance
|
||||
.transaction('GET /api/product/list')
|
||||
.transaction({ transactionName: 'GET /api/product/list' })
|
||||
.duration(1000)
|
||||
.success()
|
||||
.timestamp(timestamp)
|
||||
.children(
|
||||
javaInstance
|
||||
.span('GET apm-*/_search', 'db', 'elasticsearch')
|
||||
.span({
|
||||
spanName: 'GET apm-*/_search',
|
||||
spanType: 'db',
|
||||
spanSubtype: 'elasticsearch',
|
||||
})
|
||||
.timestamp(timestamp)
|
||||
.duration(1000)
|
||||
.destination('elasticsearch')
|
||||
|
@ -49,19 +57,23 @@ describe('span destination metrics', () => {
|
|||
.rate(50)
|
||||
.generator((timestamp) =>
|
||||
javaInstance
|
||||
.transaction('GET /api/product/list')
|
||||
.transaction({ transactionName: 'GET /api/product/list' })
|
||||
.duration(1000)
|
||||
.failure()
|
||||
.timestamp(timestamp)
|
||||
.children(
|
||||
javaInstance
|
||||
.span('GET apm-*/_search', 'db', 'elasticsearch')
|
||||
.span({
|
||||
spanName: 'GET apm-*/_search',
|
||||
spanType: 'db',
|
||||
spanSubtype: 'elasticsearch',
|
||||
})
|
||||
.timestamp(timestamp)
|
||||
.duration(1000)
|
||||
.destination('elasticsearch')
|
||||
.failure(),
|
||||
javaInstance
|
||||
.span('custom_operation', 'app')
|
||||
.span({ spanName: 'custom_operation', spanType: 'app' })
|
||||
.timestamp(timestamp)
|
||||
.duration(500)
|
||||
.success()
|
||||
|
|
|
@ -22,7 +22,11 @@ describe('breakdown metrics', () => {
|
|||
const INTERVALS = 6;
|
||||
|
||||
beforeEach(() => {
|
||||
const javaService = apm.service('opbeans-java', 'production', 'java');
|
||||
const javaService = apm.service({
|
||||
name: 'opbeans-java',
|
||||
environment: 'production',
|
||||
agentName: 'java',
|
||||
});
|
||||
const javaInstance = javaService.instance('instance-1');
|
||||
|
||||
const start = new Date('2021-01-01T00:00:00.000Z');
|
||||
|
@ -34,15 +38,18 @@ describe('breakdown metrics', () => {
|
|||
.rate(LIST_RATE)
|
||||
.generator((timestamp) =>
|
||||
javaInstance
|
||||
.transaction('GET /api/product/list')
|
||||
.transaction({ transactionName: 'GET /api/product/list' })
|
||||
.timestamp(timestamp)
|
||||
.duration(1000)
|
||||
.children(
|
||||
javaInstance
|
||||
.span('GET apm-*/_search', 'db', 'elasticsearch')
|
||||
.span({ spanName: 'GET apm-*/_search', spanType: 'db', spanSubtype: 'elasticsearch' })
|
||||
.timestamp(timestamp + 150)
|
||||
.duration(500),
|
||||
javaInstance.span('GET foo', 'db', 'redis').timestamp(timestamp).duration(100)
|
||||
javaInstance
|
||||
.span({ spanName: 'GET foo', spanType: 'db', spanSubtype: 'redis' })
|
||||
.timestamp(timestamp)
|
||||
.duration(100)
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -51,17 +58,17 @@ describe('breakdown metrics', () => {
|
|||
.rate(ID_RATE)
|
||||
.generator((timestamp) =>
|
||||
javaInstance
|
||||
.transaction('GET /api/product/:id')
|
||||
.transaction({ transactionName: 'GET /api/product/:id' })
|
||||
.timestamp(timestamp)
|
||||
.duration(1000)
|
||||
.children(
|
||||
javaInstance
|
||||
.span('GET apm-*/_search', 'db', 'elasticsearch')
|
||||
.span({ spanName: 'GET apm-*/_search', spanType: 'db', spanSubtype: 'elasticsearch' })
|
||||
.duration(500)
|
||||
.timestamp(timestamp + 100)
|
||||
.children(
|
||||
javaInstance
|
||||
.span('bar', 'external', 'http')
|
||||
.span({ spanName: 'bar', spanType: 'external', spanSubtype: 'http' })
|
||||
.timestamp(timestamp + 200)
|
||||
.duration(100)
|
||||
)
|
||||
|
|
|
@ -14,13 +14,15 @@ describe('transactions with errors', () => {
|
|||
const timestamp = new Date('2021-01-01T00:00:00.000Z').getTime();
|
||||
|
||||
beforeEach(() => {
|
||||
instance = apm.service('opbeans-java', 'production', 'java').instance('instance');
|
||||
instance = apm
|
||||
.service({ name: 'opbeans-java', environment: 'production', agentName: 'java' })
|
||||
.instance('instance');
|
||||
});
|
||||
it('generates error events', () => {
|
||||
const events = instance
|
||||
.transaction('GET /api')
|
||||
.transaction({ transactionName: 'GET /api' })
|
||||
.timestamp(timestamp)
|
||||
.errors(instance.error('test error').timestamp(timestamp))
|
||||
.errors(instance.error({ message: 'test error' }).timestamp(timestamp))
|
||||
.serialize();
|
||||
|
||||
const errorEvents = events.filter((event) => event['processor.event'] === 'error');
|
||||
|
@ -39,9 +41,9 @@ describe('transactions with errors', () => {
|
|||
|
||||
it('sets the transaction and trace id', () => {
|
||||
const [transaction, error] = instance
|
||||
.transaction('GET /api')
|
||||
.transaction({ transactionName: 'GET /api' })
|
||||
.timestamp(timestamp)
|
||||
.errors(instance.error('test error').timestamp(timestamp))
|
||||
.errors(instance.error({ message: 'test error' }).timestamp(timestamp))
|
||||
.serialize();
|
||||
|
||||
const keys = ['transaction.id', 'trace.id', 'transaction.type'];
|
||||
|
@ -55,9 +57,9 @@ describe('transactions with errors', () => {
|
|||
|
||||
it('sets the error grouping key', () => {
|
||||
const [, error] = instance
|
||||
.transaction('GET /api')
|
||||
.transaction({ transactionName: 'GET /api' })
|
||||
.timestamp(timestamp)
|
||||
.errors(instance.error('test error').timestamp(timestamp))
|
||||
.errors(instance.error({ message: 'test error' }).timestamp(timestamp))
|
||||
.serialize();
|
||||
|
||||
expect(error['error.grouping_name']).toEqual('test error');
|
||||
|
|
|
@ -14,7 +14,9 @@ describe('application metrics', () => {
|
|||
const timestamp = new Date('2021-01-01T00:00:00.000Z').getTime();
|
||||
|
||||
beforeEach(() => {
|
||||
instance = apm.service('opbeans-java', 'production', 'java').instance('instance');
|
||||
instance = apm
|
||||
.service({ name: 'opbeans-java', environment: 'production', agentName: 'java' })
|
||||
.instance('instance');
|
||||
});
|
||||
it('generates application metricsets', () => {
|
||||
const events = instance
|
||||
|
|
|
@ -10,50 +10,70 @@ export function opbeans({ from, to }: { from: number; to: number }) {
|
|||
const range = timerange(from, to);
|
||||
|
||||
const opbeansJava = apm
|
||||
.service('opbeans-java', 'production', 'java')
|
||||
.service({
|
||||
name: 'opbeans-java',
|
||||
environment: 'production',
|
||||
agentName: 'java',
|
||||
})
|
||||
.instance('opbeans-java-prod-1')
|
||||
.podId('opbeans-java-prod-1-pod');
|
||||
|
||||
const opbeansNode = apm
|
||||
.service('opbeans-node', 'production', 'nodejs')
|
||||
.service({
|
||||
name: 'opbeans-node',
|
||||
environment: 'production',
|
||||
agentName: 'nodejs',
|
||||
})
|
||||
.instance('opbeans-node-prod-1');
|
||||
|
||||
const opbeansRum = apm.browser(
|
||||
'opbeans-rum',
|
||||
'production',
|
||||
apm.getChromeUserAgentDefaults()
|
||||
);
|
||||
const opbeansRum = apm.browser({
|
||||
serviceName: 'opbeans-rum',
|
||||
environment: 'production',
|
||||
userAgent: apm.getChromeUserAgentDefaults(),
|
||||
});
|
||||
|
||||
return range
|
||||
.interval('1s')
|
||||
.rate(1)
|
||||
.generator((timestamp) => [
|
||||
opbeansJava
|
||||
.transaction('GET /api/product')
|
||||
.transaction({ transactionName: 'GET /api/product' })
|
||||
.timestamp(timestamp)
|
||||
.duration(1000)
|
||||
.success()
|
||||
.errors(
|
||||
opbeansJava.error('[MockError] Foo', `Exception`).timestamp(timestamp)
|
||||
opbeansJava
|
||||
.error({ message: '[MockError] Foo', type: `Exception` })
|
||||
.timestamp(timestamp)
|
||||
)
|
||||
.children(
|
||||
opbeansJava
|
||||
.span('SELECT * FROM product', 'db', 'postgresql')
|
||||
.span({
|
||||
spanName: 'SELECT * FROM product',
|
||||
spanType: 'db',
|
||||
spanSubtype: 'postgresql',
|
||||
})
|
||||
.timestamp(timestamp)
|
||||
.duration(50)
|
||||
.success()
|
||||
.destination('postgresql')
|
||||
),
|
||||
opbeansNode
|
||||
.transaction('GET /api/product/:id')
|
||||
.transaction({ transactionName: 'GET /api/product/:id' })
|
||||
.timestamp(timestamp)
|
||||
.duration(500)
|
||||
.success(),
|
||||
opbeansNode
|
||||
.transaction('Worker job', 'Worker')
|
||||
.transaction({
|
||||
transactionName: 'Worker job',
|
||||
transactionType: 'Worker',
|
||||
})
|
||||
.timestamp(timestamp)
|
||||
.duration(1000)
|
||||
.success(),
|
||||
opbeansRum.transaction('/').timestamp(timestamp).duration(1000),
|
||||
opbeansRum
|
||||
.transaction({ transactionName: '/' })
|
||||
.timestamp(timestamp)
|
||||
.duration(1000),
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -9,21 +9,29 @@ import { apm, timerange } from '@kbn/apm-synthtrace';
|
|||
export function generateData({ from, to }: { from: number; to: number }) {
|
||||
const range = timerange(from, to);
|
||||
const serviceRunsInContainerInstance = apm
|
||||
.service('synth-go', 'production', 'go')
|
||||
.service({ name: 'synth-go', environment: 'production', agentName: 'go' })
|
||||
.instance('instance-a');
|
||||
|
||||
const serviceInstance = apm
|
||||
.service('synth-java', 'production', 'java')
|
||||
.service({
|
||||
name: 'synth-java',
|
||||
environment: 'production',
|
||||
agentName: 'java',
|
||||
})
|
||||
.instance('instance-b');
|
||||
|
||||
const serviceNoInfraDataInstance = apm
|
||||
.service('synth-node', 'production', 'node')
|
||||
.service({
|
||||
name: 'synth-node',
|
||||
environment: 'production',
|
||||
agentName: 'node',
|
||||
})
|
||||
.instance('instance-b');
|
||||
|
||||
return range.interval('1m').generator((timestamp) => {
|
||||
return [
|
||||
serviceRunsInContainerInstance
|
||||
.transaction('GET /apple 🍎')
|
||||
.transaction({ transactionName: 'GET /apple 🍎' })
|
||||
.defaults({
|
||||
'container.id': 'foo',
|
||||
'host.hostname': 'bar',
|
||||
|
@ -33,7 +41,7 @@ export function generateData({ from, to }: { from: number; to: number }) {
|
|||
.duration(1000)
|
||||
.success(),
|
||||
serviceInstance
|
||||
.transaction('GET /banana 🍌')
|
||||
.transaction({ transactionName: 'GET /banana 🍌' })
|
||||
.defaults({
|
||||
'host.hostname': 'bar',
|
||||
})
|
||||
|
@ -41,7 +49,7 @@ export function generateData({ from, to }: { from: number; to: number }) {
|
|||
.duration(1000)
|
||||
.success(),
|
||||
serviceNoInfraDataInstance
|
||||
.transaction('GET /banana 🍌')
|
||||
.transaction({ transactionName: 'GET /banana 🍌' })
|
||||
.timestamp(timestamp)
|
||||
.duration(1000)
|
||||
.success(),
|
||||
|
|
|
@ -29,12 +29,20 @@ function generateData({
|
|||
const range = timerange(from, to);
|
||||
|
||||
const service1 = apm
|
||||
.service(serviceName, 'production', 'java')
|
||||
.service({
|
||||
name: serviceName,
|
||||
environment: 'production',
|
||||
agentName: 'java',
|
||||
})
|
||||
.instance('service-1-prod-1')
|
||||
.podId('service-1-prod-1-pod');
|
||||
|
||||
const service2 = apm
|
||||
.service(serviceName, 'development', 'nodejs')
|
||||
.service({
|
||||
name: serviceName,
|
||||
environment: 'development',
|
||||
agentName: 'nodejs',
|
||||
})
|
||||
.instance('opbeans-node-prod-1');
|
||||
|
||||
return range
|
||||
|
@ -42,12 +50,12 @@ function generateData({
|
|||
.rate(1)
|
||||
.generator((timestamp, index) => [
|
||||
service1
|
||||
.transaction('GET /apple 🍎 ')
|
||||
.transaction({ transactionName: 'GET /apple 🍎 ' })
|
||||
.timestamp(timestamp)
|
||||
.duration(1000)
|
||||
.success(),
|
||||
service2
|
||||
.transaction('GET /banana 🍌')
|
||||
.transaction({ transactionName: 'GET /banana 🍌' })
|
||||
.timestamp(timestamp)
|
||||
.duration(500)
|
||||
.success(),
|
||||
|
|
|
@ -10,12 +10,20 @@ export function generateData({ from, to }: { from: number; to: number }) {
|
|||
const range = timerange(from, to);
|
||||
|
||||
const opbeansJava = apm
|
||||
.service('opbeans-java', 'production', 'java')
|
||||
.service({
|
||||
name: 'opbeans-java',
|
||||
environment: 'production',
|
||||
agentName: 'java',
|
||||
})
|
||||
.instance('opbeans-java-prod-1')
|
||||
.podId('opbeans-java-prod-1-pod');
|
||||
|
||||
const opbeansNode = apm
|
||||
.service('opbeans-node', 'production', 'nodejs')
|
||||
.service({
|
||||
name: 'opbeans-node',
|
||||
environment: 'production',
|
||||
agentName: 'nodejs',
|
||||
})
|
||||
.instance('opbeans-node-prod-1');
|
||||
|
||||
return range
|
||||
|
@ -23,17 +31,17 @@ export function generateData({ from, to }: { from: number; to: number }) {
|
|||
.rate(1)
|
||||
.generator((timestamp, index) => [
|
||||
opbeansJava
|
||||
.transaction('GET /apple 🍎 ')
|
||||
.transaction({ transactionName: 'GET /apple 🍎 ' })
|
||||
.timestamp(timestamp)
|
||||
.duration(1000)
|
||||
.success()
|
||||
.errors(
|
||||
opbeansJava
|
||||
.error(`Error ${index}`, `exception ${index}`)
|
||||
.error({ message: `Error ${index}`, type: `exception ${index}` })
|
||||
.timestamp(timestamp)
|
||||
),
|
||||
opbeansNode
|
||||
.transaction('GET /banana 🍌')
|
||||
.transaction({ transactionName: 'GET /banana 🍌' })
|
||||
.timestamp(timestamp)
|
||||
.duration(500)
|
||||
.success(),
|
||||
|
@ -52,7 +60,11 @@ export function generateErrors({
|
|||
const range = timerange(from, to);
|
||||
|
||||
const opbeansJava = apm
|
||||
.service('opbeans-java', 'production', 'java')
|
||||
.service({
|
||||
name: 'opbeans-java',
|
||||
environment: 'production',
|
||||
agentName: 'java',
|
||||
})
|
||||
.instance('opbeans-java-prod-1')
|
||||
.podId('opbeans-java-prod-1-pod');
|
||||
|
||||
|
@ -61,7 +73,7 @@ export function generateErrors({
|
|||
.rate(1)
|
||||
.generator((timestamp, index) => [
|
||||
opbeansJava
|
||||
.transaction('GET /apple 🍎 ')
|
||||
.transaction({ transactionName: 'GET /apple 🍎 ' })
|
||||
.timestamp(timestamp)
|
||||
.duration(1000)
|
||||
.success()
|
||||
|
@ -70,7 +82,7 @@ export function generateErrors({
|
|||
.fill(0)
|
||||
.map((_, idx) => {
|
||||
return opbeansJava
|
||||
.error(`Error ${idx}`, `exception ${idx}`)
|
||||
.error({ message: `Error ${idx}`, type: `exception ${idx}` })
|
||||
.timestamp(timestamp);
|
||||
})
|
||||
),
|
||||
|
|
|
@ -19,7 +19,11 @@ export function generateMultipleServicesData({
|
|||
.fill(0)
|
||||
.map((_, idx) =>
|
||||
apm
|
||||
.service(`${idx}`, 'production', 'nodejs')
|
||||
.service({
|
||||
name: `${idx}`,
|
||||
environment: 'production',
|
||||
agentName: 'nodejs',
|
||||
})
|
||||
.instance('opbeans-node-prod-1')
|
||||
);
|
||||
|
||||
|
@ -29,7 +33,7 @@ export function generateMultipleServicesData({
|
|||
.generator((timestamp, index) =>
|
||||
services.map((service) =>
|
||||
service
|
||||
.transaction('GET /foo')
|
||||
.transaction({ transactionName: 'GET /foo' })
|
||||
.timestamp(timestamp)
|
||||
.duration(500)
|
||||
.success()
|
||||
|
|
|
@ -18,12 +18,20 @@ export function generateData({
|
|||
const range = timerange(from, to);
|
||||
|
||||
const service1 = apm
|
||||
.service(specialServiceName, 'production', 'java')
|
||||
.service({
|
||||
name: specialServiceName,
|
||||
environment: 'production',
|
||||
agentName: 'java',
|
||||
})
|
||||
.instance('service-1-prod-1')
|
||||
.podId('service-1-prod-1-pod');
|
||||
|
||||
const opbeansNode = apm
|
||||
.service('opbeans-node', 'production', 'nodejs')
|
||||
.service({
|
||||
name: 'opbeans-node',
|
||||
environment: 'production',
|
||||
agentName: 'nodejs',
|
||||
})
|
||||
.instance('opbeans-node-prod-1');
|
||||
|
||||
return range
|
||||
|
@ -31,12 +39,12 @@ export function generateData({
|
|||
.rate(1)
|
||||
.generator((timestamp) => [
|
||||
service1
|
||||
.transaction('GET /apple 🍎 ')
|
||||
.transaction({ transactionName: 'GET /apple 🍎 ' })
|
||||
.timestamp(timestamp)
|
||||
.duration(1000)
|
||||
.success(),
|
||||
opbeansNode
|
||||
.transaction('GET /banana 🍌')
|
||||
.transaction({ transactionName: 'GET /banana 🍌' })
|
||||
.timestamp(timestamp)
|
||||
.duration(500)
|
||||
.success(),
|
||||
|
|
|
@ -18,7 +18,11 @@ const dataConfig = {
|
|||
export function generateData({ start, end }: { start: number; end: number }) {
|
||||
const { rate, transaction, serviceName } = dataConfig;
|
||||
const instance = apm
|
||||
.service(serviceName, 'production', 'python')
|
||||
.service({
|
||||
name: serviceName,
|
||||
environment: 'production',
|
||||
agentName: 'python',
|
||||
})
|
||||
.instance('instance-a');
|
||||
|
||||
const traceEvents = timerange(start, end)
|
||||
|
@ -26,7 +30,7 @@ export function generateData({ start, end }: { start: number; end: number }) {
|
|||
.rate(rate)
|
||||
.generator((timestamp) =>
|
||||
instance
|
||||
.transaction(transaction.name)
|
||||
.transaction({ transactionName: transaction.name })
|
||||
.defaults({
|
||||
'service.runtime.name': 'AWS_Lambda_python3.8',
|
||||
'faas.coldstart': true,
|
||||
|
|
|
@ -10,7 +10,11 @@ import { SpanLink } from '../../../../../typings/es_schemas/raw/fields/span_link
|
|||
|
||||
function getProducerInternalOnly() {
|
||||
const producerInternalOnlyInstance = apm
|
||||
.service('producer-internal-only', 'production', 'go')
|
||||
.service({
|
||||
name: 'producer-internal-only',
|
||||
environment: 'production',
|
||||
agentName: 'go',
|
||||
})
|
||||
.instance('instance a');
|
||||
|
||||
const events = timerange(
|
||||
|
@ -21,13 +25,17 @@ function getProducerInternalOnly() {
|
|||
.rate(1)
|
||||
.generator((timestamp) => {
|
||||
return producerInternalOnlyInstance
|
||||
.transaction(`Transaction A`)
|
||||
.transaction({ transactionName: `Transaction A` })
|
||||
.timestamp(timestamp)
|
||||
.duration(1000)
|
||||
.success()
|
||||
.children(
|
||||
producerInternalOnlyInstance
|
||||
.span(`Span A`, 'external', 'http')
|
||||
.span({
|
||||
spanName: `Span A`,
|
||||
spanType: 'external',
|
||||
spanSubtype: 'http',
|
||||
})
|
||||
.timestamp(timestamp + 50)
|
||||
.duration(100)
|
||||
.success()
|
||||
|
@ -61,7 +69,11 @@ function getProducerInternalOnly() {
|
|||
|
||||
function getProducerExternalOnly() {
|
||||
const producerExternalOnlyInstance = apm
|
||||
.service('producer-external-only', 'production', 'java')
|
||||
.service({
|
||||
name: 'producer-external-only',
|
||||
environment: 'production',
|
||||
agentName: 'java',
|
||||
})
|
||||
.instance('instance b');
|
||||
|
||||
const events = timerange(
|
||||
|
@ -72,13 +84,17 @@ function getProducerExternalOnly() {
|
|||
.rate(1)
|
||||
.generator((timestamp) => {
|
||||
return producerExternalOnlyInstance
|
||||
.transaction(`Transaction B`)
|
||||
.transaction({ transactionName: `Transaction B` })
|
||||
.timestamp(timestamp)
|
||||
.duration(1000)
|
||||
.success()
|
||||
.children(
|
||||
producerExternalOnlyInstance
|
||||
.span(`Span B`, 'external', 'http')
|
||||
.span({
|
||||
spanName: `Span B`,
|
||||
spanType: 'external',
|
||||
spanSubtype: 'http',
|
||||
})
|
||||
.defaults({
|
||||
'span.links': [
|
||||
{ trace: { id: 'trace#1' }, span: { id: 'span#1' } },
|
||||
|
@ -88,7 +104,11 @@ function getProducerExternalOnly() {
|
|||
.duration(100)
|
||||
.success(),
|
||||
producerExternalOnlyInstance
|
||||
.span(`Span B.1`, 'external', 'http')
|
||||
.span({
|
||||
spanName: `Span B.1`,
|
||||
spanType: 'external',
|
||||
spanSubtype: 'http',
|
||||
})
|
||||
.timestamp(timestamp + 50)
|
||||
.duration(100)
|
||||
.success()
|
||||
|
@ -132,7 +152,11 @@ function getProducerConsumer({
|
|||
producerInternalOnlySpanASpanLink?: SpanLink;
|
||||
}) {
|
||||
const producerConsumerInstance = apm
|
||||
.service('producer-consumer', 'production', 'ruby')
|
||||
.service({
|
||||
name: 'producer-consumer',
|
||||
environment: 'production',
|
||||
agentName: 'ruby',
|
||||
})
|
||||
.instance('instance c');
|
||||
|
||||
const events = timerange(
|
||||
|
@ -143,7 +167,7 @@ function getProducerConsumer({
|
|||
.rate(1)
|
||||
.generator((timestamp) => {
|
||||
return producerConsumerInstance
|
||||
.transaction(`Transaction C`)
|
||||
.transaction({ transactionName: `Transaction C` })
|
||||
.defaults({
|
||||
'span.links': producerInternalOnlySpanASpanLink
|
||||
? [producerInternalOnlySpanASpanLink]
|
||||
|
@ -154,7 +178,11 @@ function getProducerConsumer({
|
|||
.success()
|
||||
.children(
|
||||
producerConsumerInstance
|
||||
.span(`Span C`, 'external', 'http')
|
||||
.span({
|
||||
spanName: `Span C`,
|
||||
spanType: 'external',
|
||||
spanSubtype: 'http',
|
||||
})
|
||||
.timestamp(timestamp + 50)
|
||||
.duration(100)
|
||||
.success()
|
||||
|
@ -209,7 +237,11 @@ function getConsumerMultiple({
|
|||
producerConsumerTransactionCSpanLink?: SpanLink;
|
||||
}) {
|
||||
const consumerMultipleInstance = apm
|
||||
.service('consumer-multiple', 'production', 'nodejs')
|
||||
.service({
|
||||
name: 'consumer-multiple',
|
||||
environment: 'production',
|
||||
agentName: 'nodejs',
|
||||
})
|
||||
.instance('instance d');
|
||||
|
||||
const events = timerange(
|
||||
|
@ -220,7 +252,7 @@ function getConsumerMultiple({
|
|||
.rate(1)
|
||||
.generator((timestamp) => {
|
||||
return consumerMultipleInstance
|
||||
.transaction(`Transaction D`)
|
||||
.transaction({ transactionName: `Transaction D` })
|
||||
.defaults({
|
||||
'span.links':
|
||||
producerInternalOnlySpanASpanLink && producerConsumerSpanCSpanLink
|
||||
|
@ -235,7 +267,11 @@ function getConsumerMultiple({
|
|||
.success()
|
||||
.children(
|
||||
consumerMultipleInstance
|
||||
.span(`Span E`, 'external', 'http')
|
||||
.span({
|
||||
spanName: `Span E`,
|
||||
spanType: 'external',
|
||||
spanSubtype: 'http',
|
||||
})
|
||||
.defaults({
|
||||
'span.links':
|
||||
producerExternalOnlySpanBSpanLink &&
|
||||
|
|
|
@ -38,7 +38,9 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
let ruleId: string | undefined;
|
||||
|
||||
before(async () => {
|
||||
const serviceA = apm.service('a', 'production', 'java').instance('a');
|
||||
const serviceA = apm
|
||||
.service({ name: 'a', environment: 'production', agentName: 'java' })
|
||||
.instance('a');
|
||||
|
||||
const events = timerange(new Date(start).getTime(), new Date(end).getTime())
|
||||
.interval('1m')
|
||||
|
@ -52,7 +54,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
return [
|
||||
...range(0, count).flatMap((_) =>
|
||||
serviceA
|
||||
.transaction('tx', 'request')
|
||||
.transaction({ transactionName: 'tx' })
|
||||
.timestamp(timestamp)
|
||||
.duration(duration)
|
||||
.outcome(outcome)
|
||||
|
|
|
@ -101,9 +101,13 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
const NORMAL_RATE = 1;
|
||||
|
||||
before(async () => {
|
||||
const serviceA = apm.service('a', 'production', 'java').instance('a');
|
||||
const serviceA = apm
|
||||
.service({ name: 'a', environment: 'production', agentName: 'java' })
|
||||
.instance('a');
|
||||
|
||||
const serviceB = apm.service('b', 'development', 'go').instance('b');
|
||||
const serviceB = apm
|
||||
.service({ name: 'b', environment: 'development', agentName: 'go' })
|
||||
.instance('b');
|
||||
|
||||
const events = timerange(new Date(start).getTime(), new Date(end).getTime())
|
||||
.interval('1m')
|
||||
|
@ -117,13 +121,13 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
return [
|
||||
...range(0, count).flatMap((_) =>
|
||||
serviceA
|
||||
.transaction('tx', 'request')
|
||||
.transaction({ transactionName: 'tx', transactionType: 'request' })
|
||||
.timestamp(timestamp)
|
||||
.duration(duration)
|
||||
.outcome(outcome)
|
||||
),
|
||||
serviceB
|
||||
.transaction('tx', 'Worker')
|
||||
.transaction({ transactionName: 'tx', transactionType: 'Worker' })
|
||||
.timestamp(timestamp)
|
||||
.duration(duration)
|
||||
.success(),
|
||||
|
|
|
@ -27,14 +27,16 @@ export async function generateData({
|
|||
warmStartRate: number;
|
||||
}) {
|
||||
const { transactionName, duration, serviceName } = dataConfig;
|
||||
const instance = apm.service(serviceName, 'production', 'go').instance('instance-a');
|
||||
const instance = apm
|
||||
.service({ name: serviceName, environment: 'production', agentName: 'go' })
|
||||
.instance('instance-a');
|
||||
|
||||
const traceEvents = timerange(start, end)
|
||||
.interval('1m')
|
||||
.rate(coldStartRate)
|
||||
.generator((timestamp) =>
|
||||
instance
|
||||
.transaction(transactionName)
|
||||
.transaction({ transactionName })
|
||||
.defaults({
|
||||
'faas.coldstart': true,
|
||||
})
|
||||
|
@ -48,7 +50,7 @@ export async function generateData({
|
|||
.rate(warmStartRate)
|
||||
.generator((timestamp) =>
|
||||
instance
|
||||
.transaction(transactionName)
|
||||
.transaction({ transactionName })
|
||||
.defaults({
|
||||
'faas.coldstart': false,
|
||||
})
|
||||
|
|
|
@ -33,7 +33,9 @@ export async function generateData({
|
|||
warmStartRate: number;
|
||||
}) {
|
||||
const { coldStartTransaction, warmStartTransaction, serviceName } = dataConfig;
|
||||
const instance = apm.service(serviceName, 'production', 'go').instance('instance-a');
|
||||
const instance = apm
|
||||
.service({ name: serviceName, environment: 'production', agentName: 'go' })
|
||||
.instance('instance-a');
|
||||
|
||||
const traceEvents = [
|
||||
timerange(start, end)
|
||||
|
@ -41,7 +43,7 @@ export async function generateData({
|
|||
.rate(coldStartRate)
|
||||
.generator((timestamp) =>
|
||||
instance
|
||||
.transaction(coldStartTransaction.name)
|
||||
.transaction({ transactionName: coldStartTransaction.name })
|
||||
.defaults({
|
||||
'faas.coldstart': true,
|
||||
})
|
||||
|
@ -54,7 +56,7 @@ export async function generateData({
|
|||
.rate(warmStartRate)
|
||||
.generator((timestamp) =>
|
||||
instance
|
||||
.transaction(warmStartTransaction.name)
|
||||
.transaction({ transactionName: warmStartTransaction.name })
|
||||
.defaults({
|
||||
'faas.coldstart': false,
|
||||
})
|
||||
|
|
|
@ -136,14 +136,20 @@ function generateApmData(synthtrace: ApmSynthtraceEsClient) {
|
|||
new Date('2021-10-01T00:01:00.000Z').getTime()
|
||||
);
|
||||
|
||||
const instance = apm.service('multiple-env-service', 'production', 'go').instance('my-instance');
|
||||
const instance = apm
|
||||
.service({ name: 'multiple-env-service', environment: 'production', agentName: 'go' })
|
||||
.instance('my-instance');
|
||||
|
||||
return synthtrace.index([
|
||||
range
|
||||
.interval('1s')
|
||||
.rate(1)
|
||||
.generator((timestamp) =>
|
||||
instance.transaction('GET /api').timestamp(timestamp).duration(30).success()
|
||||
instance
|
||||
.transaction({ transactionName: 'GET /api' })
|
||||
.timestamp(timestamp)
|
||||
.duration(30)
|
||||
.success()
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -30,7 +30,9 @@ export async function generateData({
|
|||
start: number;
|
||||
end: number;
|
||||
}) {
|
||||
const instance = apm.service('synth-go', 'production', 'go').instance('instance-a');
|
||||
const instance = apm
|
||||
.service({ name: 'synth-go', environment: 'production', agentName: 'go' })
|
||||
.instance('instance-a');
|
||||
const { rate, transaction, span } = dataConfig;
|
||||
|
||||
await synthtraceEsClient.index(
|
||||
|
@ -39,13 +41,13 @@ export async function generateData({
|
|||
.rate(rate)
|
||||
.generator((timestamp) =>
|
||||
instance
|
||||
.transaction(transaction.name)
|
||||
.transaction({ transactionName: transaction.name })
|
||||
.timestamp(timestamp)
|
||||
.duration(transaction.duration)
|
||||
.success()
|
||||
.children(
|
||||
instance
|
||||
.span(span.name, span.type, span.subType)
|
||||
.span({ spanName: span.name, spanType: span.type, spanSubtype: span.subType })
|
||||
.duration(transaction.duration)
|
||||
.success()
|
||||
.destination(span.destination)
|
||||
|
|
|
@ -27,8 +27,12 @@ export async function generateOperationData({
|
|||
end: number;
|
||||
synthtraceEsClient: ApmSynthtraceEsClient;
|
||||
}) {
|
||||
const synthGoInstance = apm.service('synth-go', 'production', 'go').instance('instance-a');
|
||||
const synthJavaInstance = apm.service('synth-java', 'development', 'java').instance('instance-a');
|
||||
const synthGoInstance = apm
|
||||
.service({ name: 'synth-go', environment: 'production', agentName: 'go' })
|
||||
.instance('instance-a');
|
||||
const synthJavaInstance = apm
|
||||
.service({ name: 'synth-java', environment: 'development', agentName: 'java' })
|
||||
.instance('instance-a');
|
||||
|
||||
const interval = timerange(start, end).interval('1m');
|
||||
|
||||
|
@ -37,7 +41,7 @@ export async function generateOperationData({
|
|||
.rate(generateOperationDataConfig.ES_SEARCH_UNKNOWN_RATE)
|
||||
.generator((timestamp) =>
|
||||
synthGoInstance
|
||||
.span('/_search', 'db', 'elasticsearch')
|
||||
.span({ spanName: '/_search', spanType: 'db', spanSubtype: 'elasticsearch' })
|
||||
.destination('elasticsearch')
|
||||
.timestamp(timestamp)
|
||||
.duration(generateOperationDataConfig.ES_SEARCH_DURATION)
|
||||
|
@ -46,7 +50,7 @@ export async function generateOperationData({
|
|||
.rate(generateOperationDataConfig.ES_SEARCH_SUCCESS_RATE)
|
||||
.generator((timestamp) =>
|
||||
synthGoInstance
|
||||
.span('/_search', 'db', 'elasticsearch')
|
||||
.span({ spanName: '/_search', spanType: 'db', spanSubtype: 'elasticsearch' })
|
||||
.destination('elasticsearch')
|
||||
.timestamp(timestamp)
|
||||
.success()
|
||||
|
@ -56,7 +60,7 @@ export async function generateOperationData({
|
|||
.rate(generateOperationDataConfig.ES_SEARCH_FAILURE_RATE)
|
||||
.generator((timestamp) =>
|
||||
synthGoInstance
|
||||
.span('/_search', 'db', 'elasticsearch')
|
||||
.span({ spanName: '/_search', spanType: 'db', spanSubtype: 'elasticsearch' })
|
||||
.destination('elasticsearch')
|
||||
.timestamp(timestamp)
|
||||
.failure()
|
||||
|
@ -66,7 +70,7 @@ export async function generateOperationData({
|
|||
.rate(generateOperationDataConfig.ES_BULK_RATE)
|
||||
.generator((timestamp) =>
|
||||
synthJavaInstance
|
||||
.span('/_bulk', 'db', 'elasticsearch')
|
||||
.span({ spanName: '/_bulk', spanType: 'db', spanSubtype: 'elasticsearch' })
|
||||
.destination('elasticsearch')
|
||||
.timestamp(timestamp)
|
||||
.duration(generateOperationDataConfig.ES_BULK_DURATION)
|
||||
|
@ -75,7 +79,7 @@ export async function generateOperationData({
|
|||
.rate(generateOperationDataConfig.REDIS_SET_RATE)
|
||||
.generator((timestamp) =>
|
||||
synthJavaInstance
|
||||
.span('SET', 'db', 'redis')
|
||||
.span({ spanName: 'SET', spanType: 'db', spanSubtype: 'redis' })
|
||||
.destination('redis')
|
||||
.timestamp(timestamp)
|
||||
.duration(generateOperationDataConfig.REDIS_SET_DURATION)
|
||||
|
|
|
@ -70,9 +70,13 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
'Top dependency spans when data is loaded',
|
||||
{ config: 'basic', archives: [] },
|
||||
() => {
|
||||
const javaInstance = apm.service('java', 'production', 'java').instance('instance-a');
|
||||
const javaInstance = apm
|
||||
.service({ name: 'java', environment: 'production', agentName: 'java' })
|
||||
.instance('instance-a');
|
||||
|
||||
const goInstance = apm.service('go', 'development', 'go').instance('instance-a');
|
||||
const goInstance = apm
|
||||
.service({ name: 'go', environment: 'development', agentName: 'go' })
|
||||
.instance('instance-a');
|
||||
|
||||
before(async () => {
|
||||
await synthtraceEsClient.index([
|
||||
|
@ -81,40 +85,48 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
.rate(1)
|
||||
.generator((timestamp) => [
|
||||
javaInstance
|
||||
.span('without transaction', 'db', 'elasticsearch')
|
||||
.span({
|
||||
spanName: 'without transaction',
|
||||
spanType: 'db',
|
||||
spanSubtype: 'elasticsearch',
|
||||
})
|
||||
.destination('elasticsearch')
|
||||
.duration(200)
|
||||
.timestamp(timestamp),
|
||||
javaInstance
|
||||
.transaction('GET /api/my-endpoint')
|
||||
.transaction({ transactionName: 'GET /api/my-endpoint' })
|
||||
.duration(100)
|
||||
.timestamp(timestamp)
|
||||
.children(
|
||||
javaInstance
|
||||
.span('/_search', 'db', 'elasticsearch')
|
||||
.span({ spanName: '/_search', spanType: 'db', spanSubtype: 'elasticsearch' })
|
||||
.destination('elasticsearch')
|
||||
.duration(100)
|
||||
.success()
|
||||
.timestamp(timestamp)
|
||||
),
|
||||
goInstance
|
||||
.transaction('GET /api/my-other-endpoint')
|
||||
.transaction({ transactionName: 'GET /api/my-other-endpoint' })
|
||||
.duration(100)
|
||||
.timestamp(timestamp)
|
||||
.children(
|
||||
goInstance
|
||||
.span('/_search', 'db', 'elasticsearch')
|
||||
.span({ spanName: '/_search', spanType: 'db', spanSubtype: 'elasticsearch' })
|
||||
.destination('elasticsearch')
|
||||
.duration(50)
|
||||
.timestamp(timestamp)
|
||||
),
|
||||
goInstance
|
||||
.transaction('GET /api/my-other-endpoint')
|
||||
.transaction({ transactionName: 'GET /api/my-other-endpoint' })
|
||||
.duration(100)
|
||||
.timestamp(timestamp)
|
||||
.children(
|
||||
goInstance
|
||||
.span('/_search', 'db', 'fake-elasticsearch')
|
||||
.span({
|
||||
spanName: '/_search',
|
||||
spanType: 'db',
|
||||
spanSubtype: 'fake-elasticsearch',
|
||||
})
|
||||
.destination('fake-elasticsearch')
|
||||
.duration(50)
|
||||
.timestamp(timestamp)
|
||||
|
|
|
@ -122,7 +122,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
const GO_PROD_ID_ERROR_RATE = 50;
|
||||
before(async () => {
|
||||
const serviceGoProdInstance = apm
|
||||
.service(serviceName, 'production', 'go')
|
||||
.service({ name: serviceName, environment: 'production', agentName: 'go' })
|
||||
.instance('instance-a');
|
||||
|
||||
const transactionNameProductList = 'GET /api/product/list';
|
||||
|
@ -134,7 +134,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
.rate(GO_PROD_LIST_RATE)
|
||||
.generator((timestamp) =>
|
||||
serviceGoProdInstance
|
||||
.transaction(transactionNameProductList)
|
||||
.transaction({ transactionName: transactionNameProductList })
|
||||
.timestamp(timestamp)
|
||||
.duration(1000)
|
||||
.success()
|
||||
|
@ -144,7 +144,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
.rate(GO_PROD_LIST_ERROR_RATE)
|
||||
.generator((timestamp) =>
|
||||
serviceGoProdInstance
|
||||
.transaction(transactionNameProductList)
|
||||
.transaction({ transactionName: transactionNameProductList })
|
||||
.duration(1000)
|
||||
.timestamp(timestamp)
|
||||
.failure()
|
||||
|
@ -154,7 +154,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
.rate(GO_PROD_ID_RATE)
|
||||
.generator((timestamp) =>
|
||||
serviceGoProdInstance
|
||||
.transaction(transactionNameProductId)
|
||||
.transaction({ transactionName: transactionNameProductId })
|
||||
.timestamp(timestamp)
|
||||
.duration(1000)
|
||||
.success()
|
||||
|
@ -164,7 +164,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
.rate(GO_PROD_ID_ERROR_RATE)
|
||||
.generator((timestamp) =>
|
||||
serviceGoProdInstance
|
||||
.transaction(transactionNameProductId)
|
||||
.transaction({ transactionName: transactionNameProductId })
|
||||
.duration(1000)
|
||||
.timestamp(timestamp)
|
||||
.failure()
|
||||
|
|
|
@ -68,7 +68,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
const GO_PROD_ID_ERROR_RATE = 50;
|
||||
before(async () => {
|
||||
const serviceGoProdInstance = apm
|
||||
.service(serviceName, 'production', 'go')
|
||||
.service({ name: serviceName, environment: 'production', agentName: 'go' })
|
||||
.instance('instance-a');
|
||||
|
||||
const transactionNameProductList = 'GET /api/product/list';
|
||||
|
@ -80,7 +80,10 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
.rate(GO_PROD_LIST_RATE)
|
||||
.generator((timestamp) =>
|
||||
serviceGoProdInstance
|
||||
.transaction(transactionNameProductList, 'Worker')
|
||||
.transaction({
|
||||
transactionName: transactionNameProductList,
|
||||
transactionType: 'Worker',
|
||||
})
|
||||
.timestamp(timestamp)
|
||||
.duration(1000)
|
||||
.success()
|
||||
|
@ -90,7 +93,10 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
.rate(GO_PROD_LIST_ERROR_RATE)
|
||||
.generator((timestamp) =>
|
||||
serviceGoProdInstance
|
||||
.transaction(transactionNameProductList, 'Worker')
|
||||
.transaction({
|
||||
transactionName: transactionNameProductList,
|
||||
transactionType: 'Worker',
|
||||
})
|
||||
.duration(1000)
|
||||
.timestamp(timestamp)
|
||||
.failure()
|
||||
|
@ -100,7 +106,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
.rate(GO_PROD_ID_RATE)
|
||||
.generator((timestamp) =>
|
||||
serviceGoProdInstance
|
||||
.transaction(transactionNameProductId)
|
||||
.transaction({ transactionName: transactionNameProductId })
|
||||
.timestamp(timestamp)
|
||||
.duration(1000)
|
||||
.success()
|
||||
|
@ -110,7 +116,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
.rate(GO_PROD_ID_ERROR_RATE)
|
||||
.generator((timestamp) =>
|
||||
serviceGoProdInstance
|
||||
.transaction(transactionNameProductId)
|
||||
.transaction({ transactionName: transactionNameProductId })
|
||||
.duration(1000)
|
||||
.timestamp(timestamp)
|
||||
.failure()
|
||||
|
|
|
@ -68,7 +68,9 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
};
|
||||
|
||||
before(async () => {
|
||||
const serviceInstance = apm.service(serviceName, 'production', 'go').instance('instance-a');
|
||||
const serviceInstance = apm
|
||||
.service({ name: serviceName, environment: 'production', agentName: 'go' })
|
||||
.instance('instance-a');
|
||||
|
||||
await synthtraceEsClient.index([
|
||||
timerange(start, end)
|
||||
|
@ -76,7 +78,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
.rate(appleTransaction.successRate)
|
||||
.generator((timestamp) =>
|
||||
serviceInstance
|
||||
.transaction(appleTransaction.name)
|
||||
.transaction({ transactionName: appleTransaction.name })
|
||||
.timestamp(timestamp)
|
||||
.duration(1000)
|
||||
.success()
|
||||
|
@ -86,8 +88,10 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
.rate(appleTransaction.failureRate)
|
||||
.generator((timestamp) =>
|
||||
serviceInstance
|
||||
.transaction(appleTransaction.name)
|
||||
.errors(serviceInstance.error('error 1', 'foo').timestamp(timestamp))
|
||||
.transaction({ transactionName: appleTransaction.name })
|
||||
.errors(
|
||||
serviceInstance.error({ message: 'error 1', type: 'foo' }).timestamp(timestamp)
|
||||
)
|
||||
.duration(1000)
|
||||
.timestamp(timestamp)
|
||||
.failure()
|
||||
|
@ -97,7 +101,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
.rate(bananaTransaction.successRate)
|
||||
.generator((timestamp) =>
|
||||
serviceInstance
|
||||
.transaction(bananaTransaction.name)
|
||||
.transaction({ transactionName: bananaTransaction.name })
|
||||
.timestamp(timestamp)
|
||||
.duration(1000)
|
||||
.success()
|
||||
|
@ -107,8 +111,10 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
.rate(bananaTransaction.failureRate)
|
||||
.generator((timestamp) =>
|
||||
serviceInstance
|
||||
.transaction(bananaTransaction.name)
|
||||
.errors(serviceInstance.error('error 2', 'bar').timestamp(timestamp))
|
||||
.transaction({ transactionName: bananaTransaction.name })
|
||||
.errors(
|
||||
serviceInstance.error({ message: 'error 2', type: 'bar' }).timestamp(timestamp)
|
||||
)
|
||||
.duration(1000)
|
||||
.timestamp(timestamp)
|
||||
.failure()
|
||||
|
|
|
@ -31,7 +31,9 @@ export async function generateData({
|
|||
start: number;
|
||||
end: number;
|
||||
}) {
|
||||
const serviceGoProdInstance = apm.service(serviceName, 'production', 'go').instance('instance-a');
|
||||
const serviceGoProdInstance = apm
|
||||
.service({ name: serviceName, environment: 'production', agentName: 'go' })
|
||||
.instance('instance-a');
|
||||
|
||||
const interval = '1m';
|
||||
|
||||
|
@ -43,7 +45,7 @@ export async function generateData({
|
|||
.rate(transaction.successRate)
|
||||
.generator((timestamp) =>
|
||||
serviceGoProdInstance
|
||||
.transaction(transaction.name)
|
||||
.transaction({ transactionName: transaction.name })
|
||||
.timestamp(timestamp)
|
||||
.duration(1000)
|
||||
.success()
|
||||
|
@ -54,9 +56,11 @@ export async function generateData({
|
|||
.rate(transaction.failureRate)
|
||||
.generator((timestamp) =>
|
||||
serviceGoProdInstance
|
||||
.transaction(transaction.name)
|
||||
.transaction({ transactionName: transaction.name })
|
||||
.errors(
|
||||
serviceGoProdInstance.error(`Error ${index}`, transaction.name).timestamp(timestamp)
|
||||
serviceGoProdInstance
|
||||
.error({ message: `Error ${index}`, type: transaction.name })
|
||||
.timestamp(timestamp)
|
||||
)
|
||||
.duration(1000)
|
||||
.timestamp(timestamp)
|
||||
|
|
|
@ -31,7 +31,9 @@ export async function generateData({
|
|||
start: number;
|
||||
end: number;
|
||||
}) {
|
||||
const serviceGoProdInstance = apm.service(serviceName, 'production', 'go').instance('instance-a');
|
||||
const serviceGoProdInstance = apm
|
||||
.service({ name: serviceName, environment: 'production', agentName: 'go' })
|
||||
.instance('instance-a');
|
||||
|
||||
const interval = '1m';
|
||||
|
||||
|
@ -43,7 +45,7 @@ export async function generateData({
|
|||
.rate(transaction.successRate)
|
||||
.generator((timestamp) =>
|
||||
serviceGoProdInstance
|
||||
.transaction(transaction.name)
|
||||
.transaction({ transactionName: transaction.name })
|
||||
.timestamp(timestamp)
|
||||
.duration(1000)
|
||||
.success()
|
||||
|
@ -54,10 +56,10 @@ export async function generateData({
|
|||
.rate(transaction.failureRate)
|
||||
.generator((timestamp) =>
|
||||
serviceGoProdInstance
|
||||
.transaction(transaction.name)
|
||||
.transaction({ transactionName: transaction.name })
|
||||
.errors(
|
||||
serviceGoProdInstance
|
||||
.error('Error 1', transaction.name, 'Error test')
|
||||
.error({ message: 'Error 1', type: transaction.name, groupingName: 'Error test' })
|
||||
.timestamp(timestamp)
|
||||
)
|
||||
.duration(1000)
|
||||
|
|
|
@ -31,7 +31,9 @@ export async function generateData({
|
|||
start: number;
|
||||
end: number;
|
||||
}) {
|
||||
const serviceGoProdInstance = apm.service(serviceName, 'production', 'go').instance('instance-a');
|
||||
const serviceGoProdInstance = apm
|
||||
.service({ name: serviceName, environment: 'production', agentName: 'go' })
|
||||
.instance('instance-a');
|
||||
|
||||
const interval = '1m';
|
||||
|
||||
|
@ -43,7 +45,7 @@ export async function generateData({
|
|||
.rate(transaction.successRate)
|
||||
.generator((timestamp) =>
|
||||
serviceGoProdInstance
|
||||
.transaction(transaction.name)
|
||||
.transaction({ transactionName: transaction.name })
|
||||
.timestamp(timestamp)
|
||||
.duration(1000)
|
||||
.success()
|
||||
|
@ -54,13 +56,13 @@ export async function generateData({
|
|||
.rate(transaction.failureRate)
|
||||
.generator((timestamp) =>
|
||||
serviceGoProdInstance
|
||||
.transaction(transaction.name)
|
||||
.transaction({ transactionName: transaction.name })
|
||||
.errors(
|
||||
serviceGoProdInstance
|
||||
.error(`Error 1 transaction ${transaction.name}`)
|
||||
.error({ message: `Error 1 transaction ${transaction.name}` })
|
||||
.timestamp(timestamp),
|
||||
serviceGoProdInstance
|
||||
.error(`Error 2 transaction ${transaction.name}`)
|
||||
.error({ message: `Error 2 transaction ${transaction.name}` })
|
||||
.timestamp(timestamp)
|
||||
)
|
||||
.duration(1000)
|
||||
|
|
|
@ -17,10 +17,12 @@ export async function generateData({
|
|||
end: number;
|
||||
}) {
|
||||
const serviceRunsInContainerInstance = apm
|
||||
.service('synth-go', 'production', 'go')
|
||||
.service({ name: 'synth-go', environment: 'production', agentName: 'go' })
|
||||
.instance('instance-a');
|
||||
|
||||
const serviceInstance = apm.service('synth-java', 'production', 'java').instance('instance-b');
|
||||
const serviceInstance = apm
|
||||
.service({ name: 'synth-java', environment: 'production', agentName: 'java' })
|
||||
.instance('instance-b');
|
||||
|
||||
await synthtraceEsClient.index(
|
||||
timerange(start, end)
|
||||
|
@ -28,7 +30,7 @@ export async function generateData({
|
|||
.generator((timestamp) => {
|
||||
return [
|
||||
serviceRunsInContainerInstance
|
||||
.transaction('GET /apple 🍎')
|
||||
.transaction({ transactionName: 'GET /apple 🍎' })
|
||||
.defaults({
|
||||
'container.id': 'foo',
|
||||
'host.hostname': 'bar',
|
||||
|
@ -38,7 +40,7 @@ export async function generateData({
|
|||
.duration(1000)
|
||||
.success(),
|
||||
serviceInstance
|
||||
.transaction('GET /banana 🍌')
|
||||
.transaction({ transactionName: 'GET /banana 🍌' })
|
||||
.defaults({
|
||||
'host.hostname': 'bar',
|
||||
})
|
||||
|
|
|
@ -124,10 +124,10 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
const GO_DEV_DURATION = 500;
|
||||
before(async () => {
|
||||
const serviceGoProdInstance = apm
|
||||
.service(serviceName, 'production', 'go')
|
||||
.service({ name: serviceName, environment: 'production', agentName: 'go' })
|
||||
.instance('instance-a');
|
||||
const serviceGoDevInstance = apm
|
||||
.service(serviceName, 'development', 'go')
|
||||
.service({ name: serviceName, environment: 'development', agentName: 'go' })
|
||||
.instance('instance-b');
|
||||
|
||||
await synthtraceEsClient.index([
|
||||
|
@ -136,7 +136,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
.rate(GO_PROD_RATE)
|
||||
.generator((timestamp) =>
|
||||
serviceGoProdInstance
|
||||
.transaction('GET /api/product/list')
|
||||
.transaction({ transactionName: 'GET /api/product/list' })
|
||||
.duration(GO_PROD_DURATION)
|
||||
.timestamp(timestamp)
|
||||
),
|
||||
|
@ -145,7 +145,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
.rate(GO_DEV_RATE)
|
||||
.generator((timestamp) =>
|
||||
serviceGoDevInstance
|
||||
.transaction('GET /api/product/:id')
|
||||
.transaction({ transactionName: 'GET /api/product/:id' })
|
||||
.duration(GO_DEV_DURATION)
|
||||
.timestamp(timestamp)
|
||||
),
|
||||
|
|
|
@ -67,10 +67,10 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
const GO_DEV_DURATION = 500;
|
||||
before(async () => {
|
||||
const serviceGoProdInstance = apm
|
||||
.service(serviceName, 'production', 'go')
|
||||
.service({ name: serviceName, environment: 'production', agentName: 'go' })
|
||||
.instance('instance-a');
|
||||
const serviceGoDevInstance = apm
|
||||
.service(serviceName, 'development', 'go')
|
||||
.service({ name: serviceName, environment: 'development', agentName: 'go' })
|
||||
.instance('instance-b');
|
||||
|
||||
await synthtraceEsClient.index([
|
||||
|
@ -79,7 +79,10 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
.rate(GO_PROD_RATE)
|
||||
.generator((timestamp) =>
|
||||
serviceGoProdInstance
|
||||
.transaction('GET /api/product/list', 'Worker')
|
||||
.transaction({
|
||||
transactionName: 'GET /api/product/list',
|
||||
transactionType: 'Worker',
|
||||
})
|
||||
.duration(GO_PROD_DURATION)
|
||||
.timestamp(timestamp)
|
||||
),
|
||||
|
@ -88,7 +91,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
.rate(GO_DEV_RATE)
|
||||
.generator((timestamp) =>
|
||||
serviceGoDevInstance
|
||||
.transaction('GET /api/product/:id')
|
||||
.transaction({ transactionName: 'GET /api/product/:id' })
|
||||
.duration(GO_DEV_DURATION)
|
||||
.timestamp(timestamp)
|
||||
),
|
||||
|
|
|
@ -90,14 +90,14 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
const JAVA_PROD_RATE = 45;
|
||||
before(async () => {
|
||||
const serviceGoProdInstance = apm
|
||||
.service('synth-go', 'production', 'go')
|
||||
.service({ name: 'synth-go', environment: 'production', agentName: 'go' })
|
||||
.instance('instance-a');
|
||||
const serviceGoDevInstance = apm
|
||||
.service('synth-go', 'development', 'go')
|
||||
.service({ name: 'synth-go', environment: 'development', agentName: 'go' })
|
||||
.instance('instance-b');
|
||||
|
||||
const serviceJavaInstance = apm
|
||||
.service('synth-java', 'production', 'java')
|
||||
.service({ name: 'synth-java', environment: 'production', agentName: 'java' })
|
||||
.instance('instance-c');
|
||||
|
||||
await synthtraceEsClient.index([
|
||||
|
@ -106,7 +106,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
.rate(GO_PROD_RATE)
|
||||
.generator((timestamp) =>
|
||||
serviceGoProdInstance
|
||||
.transaction('GET /api/product/list')
|
||||
.transaction({ transactionName: 'GET /api/product/list' })
|
||||
.duration(1000)
|
||||
.timestamp(timestamp)
|
||||
),
|
||||
|
@ -115,7 +115,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
.rate(GO_DEV_RATE)
|
||||
.generator((timestamp) =>
|
||||
serviceGoDevInstance
|
||||
.transaction('GET /api/product/:id')
|
||||
.transaction({ transactionName: 'GET /api/product/:id' })
|
||||
.duration(1000)
|
||||
.timestamp(timestamp)
|
||||
),
|
||||
|
@ -124,7 +124,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
.rate(JAVA_PROD_RATE)
|
||||
.generator((timestamp) =>
|
||||
serviceJavaInstance
|
||||
.transaction('POST /api/product/buy')
|
||||
.transaction({ transactionName: 'POST /api/product/buy' })
|
||||
.duration(1000)
|
||||
.timestamp(timestamp)
|
||||
),
|
||||
|
|
|
@ -50,7 +50,9 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
|
||||
registry.when('Service nodes when data is loaded', { config: 'basic', archives: [] }, () => {
|
||||
before(async () => {
|
||||
const instance = apm.service(serviceName, 'production', 'go').instance(instanceName);
|
||||
const instance = apm
|
||||
.service({ name: serviceName, environment: 'production', agentName: 'go' })
|
||||
.instance(instanceName);
|
||||
await synthtraceEsClient.index(
|
||||
timerange(start, end)
|
||||
.interval('1m')
|
||||
|
|
|
@ -296,8 +296,16 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
const rangeEnd = new Date('2021-01-01T12:15:00.000Z').getTime() - 1;
|
||||
|
||||
before(async () => {
|
||||
const goService = apm.service('opbeans-go', 'production', 'go');
|
||||
const javaService = apm.service('opbeans-java', 'production', 'java');
|
||||
const goService = apm.service({
|
||||
name: 'opbeans-go',
|
||||
environment: 'production',
|
||||
agentName: 'go',
|
||||
});
|
||||
const javaService = apm.service({
|
||||
name: 'opbeans-java',
|
||||
environment: 'production',
|
||||
agentName: 'java',
|
||||
});
|
||||
|
||||
const goInstanceA = goService.instance('go-instance-a');
|
||||
const goInstanceB = goService.instance('go-instance-b');
|
||||
|
@ -310,7 +318,11 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
function withSpans(timestamp: number) {
|
||||
return new Array(3).fill(undefined).map(() =>
|
||||
goInstanceA
|
||||
.span('GET apm-*/_search', 'db', 'elasticsearch')
|
||||
.span({
|
||||
spanName: 'GET apm-*/_search',
|
||||
spanType: 'db',
|
||||
spanSubtype: 'elasticsearch',
|
||||
})
|
||||
.timestamp(timestamp + 100)
|
||||
.duration(300)
|
||||
.destination('elasticsearch')
|
||||
|
@ -321,7 +333,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
return synthtraceEsClient.index([
|
||||
interval.rate(GO_A_INSTANCE_RATE_SUCCESS).generator((timestamp) =>
|
||||
goInstanceA
|
||||
.transaction('GET /api/product/list')
|
||||
.transaction({ transactionName: 'GET /api/product/list' })
|
||||
.success()
|
||||
.duration(500)
|
||||
.timestamp(timestamp)
|
||||
|
@ -329,7 +341,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
),
|
||||
interval.rate(GO_A_INSTANCE_RATE_FAILURE).generator((timestamp) =>
|
||||
goInstanceA
|
||||
.transaction('GET /api/product/list')
|
||||
.transaction({ transactionName: 'GET /api/product/list' })
|
||||
.failure()
|
||||
.duration(500)
|
||||
.timestamp(timestamp)
|
||||
|
@ -337,7 +349,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
),
|
||||
interval.rate(GO_B_INSTANCE_RATE_SUCCESS).generator((timestamp) =>
|
||||
goInstanceB
|
||||
.transaction('GET /api/product/list')
|
||||
.transaction({ transactionName: 'GET /api/product/list' })
|
||||
.success()
|
||||
.duration(500)
|
||||
.timestamp(timestamp)
|
||||
|
@ -345,7 +357,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
),
|
||||
interval.rate(JAVA_INSTANCE_RATE).generator((timestamp) =>
|
||||
javaInstance
|
||||
.transaction('GET /api/product/list')
|
||||
.transaction({ transactionName: 'GET /api/product/list' })
|
||||
.success()
|
||||
.duration(500)
|
||||
.timestamp(timestamp)
|
||||
|
|
|
@ -27,7 +27,9 @@ export async function generateData({
|
|||
start: number;
|
||||
end: number;
|
||||
}) {
|
||||
const serviceGoProdInstance = apm.service(serviceName, 'production', 'go').instance('instance-a');
|
||||
const serviceGoProdInstance = apm
|
||||
.service({ name: serviceName, environment: 'production', agentName: 'go' })
|
||||
.instance('instance-a');
|
||||
|
||||
const transactionNameProductList = 'GET /api/product/list';
|
||||
const transactionNameProductId = 'GET /api/product/:id';
|
||||
|
@ -47,7 +49,7 @@ export async function generateData({
|
|||
.rate(PROD_LIST_RATE)
|
||||
.generator((timestamp) =>
|
||||
serviceGoProdInstance
|
||||
.transaction(transactionNameProductList)
|
||||
.transaction({ transactionName: transactionNameProductList })
|
||||
.timestamp(timestamp)
|
||||
.duration(1000)
|
||||
.success()
|
||||
|
@ -57,8 +59,10 @@ export async function generateData({
|
|||
.rate(PROD_LIST_ERROR_RATE)
|
||||
.generator((timestamp) =>
|
||||
serviceGoProdInstance
|
||||
.transaction(transactionNameProductList)
|
||||
.errors(serviceGoProdInstance.error(ERROR_NAME_1, 'foo').timestamp(timestamp))
|
||||
.transaction({ transactionName: transactionNameProductList })
|
||||
.errors(
|
||||
serviceGoProdInstance.error({ message: ERROR_NAME_1, type: 'foo' }).timestamp(timestamp)
|
||||
)
|
||||
.duration(1000)
|
||||
.timestamp(timestamp)
|
||||
.failure()
|
||||
|
@ -68,7 +72,7 @@ export async function generateData({
|
|||
.rate(PROD_ID_RATE)
|
||||
.generator((timestamp) =>
|
||||
serviceGoProdInstance
|
||||
.transaction(transactionNameProductId)
|
||||
.transaction({ transactionName: transactionNameProductId })
|
||||
.timestamp(timestamp)
|
||||
.duration(1000)
|
||||
.success()
|
||||
|
@ -78,8 +82,10 @@ export async function generateData({
|
|||
.rate(PROD_ID_ERROR_RATE)
|
||||
.generator((timestamp) =>
|
||||
serviceGoProdInstance
|
||||
.transaction(transactionNameProductId)
|
||||
.errors(serviceGoProdInstance.error(ERROR_NAME_2, 'bar').timestamp(timestamp))
|
||||
.transaction({ transactionName: transactionNameProductId })
|
||||
.errors(
|
||||
serviceGoProdInstance.error({ message: ERROR_NAME_2, type: 'bar' }).timestamp(timestamp)
|
||||
)
|
||||
.duration(1000)
|
||||
.timestamp(timestamp)
|
||||
.failure()
|
||||
|
|
|
@ -57,7 +57,9 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
{ config: 'basic', archives: [] },
|
||||
() => {
|
||||
before(async () => {
|
||||
const instance = apm.service(serviceName, 'production', 'go').instance(instanceName);
|
||||
const instance = apm
|
||||
.service({ name: serviceName, environment: 'production', agentName: 'go' })
|
||||
.instance(instanceName);
|
||||
await synthtraceEsClient.index(
|
||||
timerange(start, end)
|
||||
.interval('1m')
|
||||
|
@ -65,7 +67,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
.generator((timestamp) =>
|
||||
instance
|
||||
.containerId(instanceName)
|
||||
.transaction('GET /api/product/list')
|
||||
.transaction({ transactionName: 'GET /api/product/list' })
|
||||
.timestamp(timestamp)
|
||||
.duration(1000)
|
||||
.success()
|
||||
|
|
|
@ -65,7 +65,9 @@ export async function generateData({
|
|||
const { name: serviceRunTimeName, version: serviceRunTimeVersion } = runtime;
|
||||
const { name: agentName, version: agentVersion } = agent;
|
||||
|
||||
const instance = apm.service(serviceName, 'production', agentName).instance('instance-a');
|
||||
const instance = apm
|
||||
.service({ name: serviceName, environment: 'production', agentName })
|
||||
.instance('instance-a');
|
||||
|
||||
const traceEvents = [
|
||||
timerange(start, end)
|
||||
|
@ -74,7 +76,7 @@ export async function generateData({
|
|||
.generator((timestamp) =>
|
||||
instance
|
||||
.containerId('instance-a')
|
||||
.transaction(transaction.name)
|
||||
.transaction({ transactionName: transaction.name })
|
||||
.timestamp(timestamp)
|
||||
.defaults({
|
||||
'cloud.provider': provider,
|
||||
|
@ -101,7 +103,7 @@ export async function generateData({
|
|||
.rate(rate)
|
||||
.generator((timestamp) =>
|
||||
instance
|
||||
.transaction(transaction.name)
|
||||
.transaction({ transactionName: transaction.name })
|
||||
.timestamp(timestamp)
|
||||
.defaults({
|
||||
'cloud.provider': provider,
|
||||
|
|
|
@ -33,14 +33,16 @@ export async function generateData({
|
|||
const { serviceName, agentName, rate, cloud, transaction } = dataConfig;
|
||||
const { provider, serviceName: cloudServiceName } = cloud;
|
||||
|
||||
const instance = apm.service(serviceName, 'production', agentName).instance('instance-a');
|
||||
const instance = apm
|
||||
.service({ name: serviceName, environment: 'production', agentName })
|
||||
.instance('instance-a');
|
||||
|
||||
const traceEvents = timerange(start, end)
|
||||
.interval('30s')
|
||||
.rate(rate)
|
||||
.generator((timestamp) =>
|
||||
instance
|
||||
.transaction(transaction.name)
|
||||
.transaction({ transactionName: transaction.name })
|
||||
.defaults({
|
||||
'kubernetes.pod.uid': 'test',
|
||||
'cloud.provider': provider,
|
||||
|
|
|
@ -53,11 +53,17 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
// FLAKY: https://github.com/elastic/kibana/issues/127939
|
||||
registry.when.skip('Sorted and filtered services', { config: 'trial', archives: [] }, () => {
|
||||
before(async () => {
|
||||
const serviceA = apm.service(SERVICE_NAME_PREFIX + 'a', 'production', 'java').instance('a');
|
||||
const serviceA = apm
|
||||
.service({ name: SERVICE_NAME_PREFIX + 'a', environment: 'production', agentName: 'java' })
|
||||
.instance('a');
|
||||
|
||||
const serviceB = apm.service(SERVICE_NAME_PREFIX + 'b', 'development', 'go').instance('b');
|
||||
const serviceB = apm
|
||||
.service({ name: SERVICE_NAME_PREFIX + 'b', environment: 'development', agentName: 'go' })
|
||||
.instance('b');
|
||||
|
||||
const serviceC = apm.service(SERVICE_NAME_PREFIX + 'c', 'development', 'go').instance('c');
|
||||
const serviceC = apm
|
||||
.service({ name: SERVICE_NAME_PREFIX + 'c', environment: 'development', agentName: 'go' })
|
||||
.instance('c');
|
||||
|
||||
const spikeStart = new Date('2021-01-07T12:00:00.000Z').getTime();
|
||||
const spikeEnd = new Date('2021-01-07T14:00:00.000Z').getTime();
|
||||
|
@ -69,11 +75,11 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
const isInSpike = spikeStart <= timestamp && spikeEnd >= timestamp;
|
||||
return [
|
||||
serviceA
|
||||
.transaction('GET /api')
|
||||
.transaction({ transactionName: 'GET /api' })
|
||||
.duration(isInSpike ? 1000 : 1100)
|
||||
.timestamp(timestamp),
|
||||
serviceB
|
||||
.transaction('GET /api')
|
||||
.transaction({ transactionName: 'GET /api' })
|
||||
.duration(isInSpike ? 1000 : 4000)
|
||||
.timestamp(timestamp),
|
||||
];
|
||||
|
@ -86,7 +92,10 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
.interval('15m')
|
||||
.rate(1)
|
||||
.generator((timestamp) => {
|
||||
return serviceC.transaction('GET /api', 'custom').duration(1000).timestamp(timestamp);
|
||||
return serviceC
|
||||
.transaction({ transactionName: 'GET /api', transactionType: 'custom' })
|
||||
.duration(1000)
|
||||
.timestamp(timestamp);
|
||||
});
|
||||
|
||||
await synthtraceClient.index(eventsWithinTimerange.merge(eventsOutsideOfTimerange));
|
||||
|
|
|
@ -71,14 +71,14 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
|
||||
before(async () => {
|
||||
const serviceGoProdInstance = apm
|
||||
.service(serviceName, 'production', 'go')
|
||||
.service({ name: serviceName, environment: 'production', agentName: 'go' })
|
||||
.instance('instance-a');
|
||||
const serviceGoDevInstance = apm
|
||||
.service(serviceName, 'development', 'go')
|
||||
.service({ name: serviceName, environment: 'development', agentName: 'go' })
|
||||
.instance('instance-b');
|
||||
|
||||
const serviceJavaInstance = apm
|
||||
.service('synth-java', 'development', 'java')
|
||||
.service({ name: 'synth-java', environment: 'development', agentName: 'java' })
|
||||
.instance('instance-c');
|
||||
|
||||
await synthtraceEsClient.index([
|
||||
|
@ -87,7 +87,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
.rate(GO_PROD_RATE)
|
||||
.generator((timestamp) =>
|
||||
serviceGoProdInstance
|
||||
.transaction('GET /api/product/list')
|
||||
.transaction({ transactionName: 'GET /api/product/list' })
|
||||
.duration(1000)
|
||||
.timestamp(timestamp)
|
||||
),
|
||||
|
@ -96,7 +96,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
.rate(GO_DEV_RATE)
|
||||
.generator((timestamp) =>
|
||||
serviceGoDevInstance
|
||||
.transaction('GET /api/product/:id')
|
||||
.transaction({ transactionName: 'GET /api/product/:id' })
|
||||
.duration(1000)
|
||||
.timestamp(timestamp)
|
||||
),
|
||||
|
@ -105,7 +105,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
.rate(JAVA_PROD_RATE)
|
||||
.generator((timestamp) =>
|
||||
serviceJavaInstance
|
||||
.transaction('POST /api/product/buy')
|
||||
.transaction({ transactionName: 'POST /api/product/buy' })
|
||||
.duration(1000)
|
||||
.timestamp(timestamp)
|
||||
),
|
||||
|
|
|
@ -71,19 +71,19 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
const errorInterval = range.interval('5s');
|
||||
|
||||
const multipleEnvServiceProdInstance = apm
|
||||
.service('multiple-env-service', 'production', 'go')
|
||||
.service({ name: 'multiple-env-service', environment: 'production', agentName: 'go' })
|
||||
.instance('multiple-env-service-production');
|
||||
|
||||
const multipleEnvServiceDevInstance = apm
|
||||
.service('multiple-env-service', 'development', 'go')
|
||||
.service({ name: 'multiple-env-service', environment: 'development', agentName: 'go' })
|
||||
.instance('multiple-env-service-development');
|
||||
|
||||
const metricOnlyInstance = apm
|
||||
.service('metric-only-service', 'production', 'java')
|
||||
.service({ name: 'metric-only-service', environment: 'production', agentName: 'java' })
|
||||
.instance('metric-only-production');
|
||||
|
||||
const errorOnlyInstance = apm
|
||||
.service('error-only-service', 'production', 'java')
|
||||
.service({ name: 'error-only-service', environment: 'production', agentName: 'java' })
|
||||
.instance('error-only-production');
|
||||
|
||||
const config = {
|
||||
|
@ -105,7 +105,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
.rate(config.multiple.prod.rps)
|
||||
.generator((timestamp) =>
|
||||
multipleEnvServiceProdInstance
|
||||
.transaction('GET /api')
|
||||
.transaction({ transactionName: 'GET /api' })
|
||||
.timestamp(timestamp)
|
||||
.duration(config.multiple.prod.duration)
|
||||
.success()
|
||||
|
@ -114,7 +114,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
.rate(config.multiple.dev.rps)
|
||||
.generator((timestamp) =>
|
||||
multipleEnvServiceDevInstance
|
||||
.transaction('GET /api')
|
||||
.transaction({ transactionName: 'GET /api' })
|
||||
.timestamp(timestamp)
|
||||
.duration(config.multiple.dev.duration)
|
||||
.failure()
|
||||
|
@ -123,7 +123,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
.rate(config.multiple.prod.rps)
|
||||
.generator((timestamp) =>
|
||||
multipleEnvServiceDevInstance
|
||||
.transaction('non-request', 'rpc')
|
||||
.transaction({ transactionName: 'non-request', transactionType: 'rpc' })
|
||||
.timestamp(timestamp)
|
||||
.duration(config.multiple.prod.duration)
|
||||
.success()
|
||||
|
@ -140,7 +140,9 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
),
|
||||
errorInterval
|
||||
.rate(1)
|
||||
.generator((timestamp) => errorOnlyInstance.error('Foo').timestamp(timestamp)),
|
||||
.generator((timestamp) =>
|
||||
errorOnlyInstance.error({ message: 'Foo' }).timestamp(timestamp)
|
||||
),
|
||||
]);
|
||||
});
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import uuid from 'uuid';
|
|||
|
||||
function getProducerInternalOnly() {
|
||||
const producerInternalOnlyInstance = apm
|
||||
.service('producer-internal-only', 'production', 'go')
|
||||
.service({ name: 'producer-internal-only', environment: 'production', agentName: 'go' })
|
||||
.instance('instance a');
|
||||
|
||||
const events = timerange(
|
||||
|
@ -21,13 +21,13 @@ function getProducerInternalOnly() {
|
|||
.rate(1)
|
||||
.generator((timestamp) => {
|
||||
return producerInternalOnlyInstance
|
||||
.transaction(`Transaction A`)
|
||||
.transaction({ transactionName: `Transaction A` })
|
||||
.timestamp(timestamp)
|
||||
.duration(1000)
|
||||
.success()
|
||||
.children(
|
||||
producerInternalOnlyInstance
|
||||
.span(`Span A`, 'external', 'http')
|
||||
.span({ spanName: `Span A`, spanType: 'external', spanSubtype: 'http' })
|
||||
.timestamp(timestamp + 50)
|
||||
.duration(100)
|
||||
.success()
|
||||
|
@ -57,7 +57,7 @@ function getProducerInternalOnly() {
|
|||
|
||||
function getProducerExternalOnly() {
|
||||
const producerExternalOnlyInstance = apm
|
||||
.service('producer-external-only', 'production', 'java')
|
||||
.service({ name: 'producer-external-only', environment: 'production', agentName: 'java' })
|
||||
.instance('instance b');
|
||||
|
||||
const events = timerange(
|
||||
|
@ -68,13 +68,13 @@ function getProducerExternalOnly() {
|
|||
.rate(1)
|
||||
.generator((timestamp) => {
|
||||
return producerExternalOnlyInstance
|
||||
.transaction(`Transaction B`)
|
||||
.transaction({ transactionName: `Transaction B` })
|
||||
.timestamp(timestamp)
|
||||
.duration(1000)
|
||||
.success()
|
||||
.children(
|
||||
producerExternalOnlyInstance
|
||||
.span(`Span B`, 'external', 'http')
|
||||
.span({ spanName: `Span B`, spanType: 'external', spanSubtype: 'http' })
|
||||
.defaults({
|
||||
'span.links': [{ trace: { id: 'trace#1' }, span: { id: 'span#1' } }],
|
||||
})
|
||||
|
@ -82,7 +82,7 @@ function getProducerExternalOnly() {
|
|||
.duration(100)
|
||||
.success(),
|
||||
producerExternalOnlyInstance
|
||||
.span(`Span B.1`, 'external', 'http')
|
||||
.span({ spanName: `Span B.1`, spanType: 'external', spanSubtype: 'http' })
|
||||
.timestamp(timestamp + 50)
|
||||
.duration(100)
|
||||
.success()
|
||||
|
@ -130,7 +130,7 @@ function getProducerConsumer({
|
|||
const externalTraceId = uuid.v4();
|
||||
|
||||
const producerConsumerInstance = apm
|
||||
.service('producer-consumer', 'production', 'ruby')
|
||||
.service({ name: 'producer-consumer', environment: 'production', agentName: 'ruby' })
|
||||
.instance('instance c');
|
||||
|
||||
const events = timerange(
|
||||
|
@ -141,7 +141,7 @@ function getProducerConsumer({
|
|||
.rate(1)
|
||||
.generator((timestamp) => {
|
||||
return producerConsumerInstance
|
||||
.transaction(`Transaction C`)
|
||||
.transaction({ transactionName: `Transaction C` })
|
||||
.defaults({
|
||||
'span.links': [
|
||||
producerInternalOnlySpanASpanLink,
|
||||
|
@ -154,7 +154,7 @@ function getProducerConsumer({
|
|||
.success()
|
||||
.children(
|
||||
producerConsumerInstance
|
||||
.span(`Span C`, 'external', 'http')
|
||||
.span({ spanName: `Span C`, spanType: 'external', spanSubtype: 'http' })
|
||||
.timestamp(timestamp + 50)
|
||||
.duration(100)
|
||||
.success()
|
||||
|
@ -200,7 +200,7 @@ function getConsumerMultiple({
|
|||
producerConsumerTransactionCLink: SpanLink;
|
||||
}) {
|
||||
const consumerMultipleInstance = apm
|
||||
.service('consumer-multiple', 'production', 'nodejs')
|
||||
.service({ name: 'consumer-multiple', environment: 'production', agentName: 'nodejs' })
|
||||
.instance('instance d');
|
||||
|
||||
const events = timerange(
|
||||
|
@ -211,14 +211,14 @@ function getConsumerMultiple({
|
|||
.rate(1)
|
||||
.generator((timestamp) => {
|
||||
return consumerMultipleInstance
|
||||
.transaction(`Transaction D`)
|
||||
.transaction({ transactionName: `Transaction D` })
|
||||
.defaults({ 'span.links': [producerInternalOnlySpanALink, producerConsumerSpanCLink] })
|
||||
.timestamp(timestamp)
|
||||
.duration(1000)
|
||||
.success()
|
||||
.children(
|
||||
consumerMultipleInstance
|
||||
.span(`Span E`, 'external', 'http')
|
||||
.span({ spanName: `Span E`, spanType: 'external', spanSubtype: 'http' })
|
||||
.defaults({
|
||||
'span.links': [producerExternalOnlySpanBLink, producerConsumerTransactionCLink],
|
||||
})
|
||||
|
|
|
@ -56,21 +56,31 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
let status: number;
|
||||
|
||||
before(async () => {
|
||||
const serviceGo1 = apm.service('synth-go-1', 'production', 'go').instance('instance');
|
||||
const serviceGo2 = apm.service('synth-go-2', 'production', 'go').instance('instance');
|
||||
const serviceGo1 = apm
|
||||
.service({ name: 'synth-go-1', environment: 'production', agentName: 'go' })
|
||||
.instance('instance');
|
||||
const serviceGo2 = apm
|
||||
.service({ name: 'synth-go-2', environment: 'production', agentName: 'go' })
|
||||
.instance('instance');
|
||||
|
||||
await synthtraceEsClient.index([
|
||||
timerange(start, end)
|
||||
.interval('5m')
|
||||
.rate(1)
|
||||
.generator((timestamp) =>
|
||||
serviceGo1.transaction('GET /api/product/list1').duration(2000).timestamp(timestamp)
|
||||
serviceGo1
|
||||
.transaction({ transactionName: 'GET /api/product/list1' })
|
||||
.duration(2000)
|
||||
.timestamp(timestamp)
|
||||
),
|
||||
timerange(start, end)
|
||||
.interval('5m')
|
||||
.rate(1)
|
||||
.generator((timestamp) =>
|
||||
serviceGo2.transaction('GET /api/product/list2').duration(2000).timestamp(timestamp)
|
||||
serviceGo2
|
||||
.transaction({ transactionName: 'GET /api/product/list2' })
|
||||
.duration(2000)
|
||||
.timestamp(timestamp)
|
||||
),
|
||||
]);
|
||||
|
||||
|
|
|
@ -99,10 +99,10 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
const JAVA_PROD_RATE = 25;
|
||||
before(async () => {
|
||||
const serviceGoProdInstance = apm
|
||||
.service('synth-go', 'production', 'go')
|
||||
.service({ name: 'synth-go', environment: 'production', agentName: 'go' })
|
||||
.instance('instance-a');
|
||||
const serviceJavaInstance = apm
|
||||
.service('synth-java', 'development', 'java')
|
||||
.service({ name: 'synth-java', environment: 'development', agentName: 'java' })
|
||||
.instance('instance-c');
|
||||
|
||||
await synthtraceEsClient.index([
|
||||
|
@ -111,22 +111,30 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
.rate(GO_PROD_RATE)
|
||||
.generator((timestamp) =>
|
||||
serviceGoProdInstance
|
||||
.transaction('GET /api/product/list')
|
||||
.transaction({ transactionName: 'GET /api/product/list' })
|
||||
.duration(1000)
|
||||
.timestamp(timestamp)
|
||||
.children(
|
||||
serviceGoProdInstance
|
||||
.span('GET apm-*/_search', 'db', 'elasticsearch')
|
||||
.span({
|
||||
spanName: 'GET apm-*/_search',
|
||||
spanType: 'db',
|
||||
spanSubtype: 'elasticsearch',
|
||||
})
|
||||
.duration(1000)
|
||||
.success()
|
||||
.destination('elasticsearch')
|
||||
.timestamp(timestamp),
|
||||
serviceGoProdInstance
|
||||
.span('custom_operation', 'app')
|
||||
.span({ spanName: 'custom_operation', spanType: 'app' })
|
||||
.duration(550)
|
||||
.children(
|
||||
serviceGoProdInstance
|
||||
.span('SELECT FROM products', 'db', 'postgresql')
|
||||
.span({
|
||||
spanName: 'SELECT FROM products',
|
||||
spanType: 'db',
|
||||
spanSubtype: 'postgresql',
|
||||
})
|
||||
.duration(500)
|
||||
.success()
|
||||
.destination('postgresql')
|
||||
|
@ -141,18 +149,22 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
.rate(JAVA_PROD_RATE)
|
||||
.generator((timestamp) =>
|
||||
serviceJavaInstance
|
||||
.transaction('POST /api/product/buy')
|
||||
.transaction({ transactionName: 'POST /api/product/buy' })
|
||||
.duration(1000)
|
||||
.timestamp(timestamp)
|
||||
.children(
|
||||
serviceJavaInstance
|
||||
.span('GET apm-*/_search', 'db', 'elasticsearch')
|
||||
.span({
|
||||
spanName: 'GET apm-*/_search',
|
||||
spanType: 'db',
|
||||
spanSubtype: 'elasticsearch',
|
||||
})
|
||||
.duration(1000)
|
||||
.success()
|
||||
.destination('elasticsearch')
|
||||
.timestamp(timestamp),
|
||||
serviceJavaInstance
|
||||
.span('custom_operation', 'app')
|
||||
.span({ spanName: 'custom_operation', spanType: 'app' })
|
||||
.duration(50)
|
||||
.success()
|
||||
.timestamp(timestamp)
|
||||
|
|
|
@ -110,10 +110,10 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
const GO_DEV_RATE = 20;
|
||||
before(async () => {
|
||||
const serviceGoProdInstance = apm
|
||||
.service(serviceName, 'production', 'go')
|
||||
.service({ name: serviceName, environment: 'production', agentName: 'go' })
|
||||
.instance('instance-a');
|
||||
const serviceGoDevInstance = apm
|
||||
.service(serviceName, 'development', 'go')
|
||||
.service({ name: serviceName, environment: 'development', agentName: 'go' })
|
||||
.instance('instance-b');
|
||||
|
||||
await synthtraceEsClient.index([
|
||||
|
@ -122,7 +122,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
.rate(GO_PROD_RATE)
|
||||
.generator((timestamp) =>
|
||||
serviceGoProdInstance
|
||||
.transaction('GET /api/product/list')
|
||||
.transaction({ transactionName: 'GET /api/product/list' })
|
||||
.duration(1000)
|
||||
.timestamp(timestamp)
|
||||
),
|
||||
|
@ -131,7 +131,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
.rate(GO_DEV_RATE)
|
||||
.generator((timestamp) =>
|
||||
serviceGoDevInstance
|
||||
.transaction('GET /api/product/:id')
|
||||
.transaction({ transactionName: 'GET /api/product/:id' })
|
||||
.duration(1000)
|
||||
.timestamp(timestamp)
|
||||
),
|
||||
|
|
|
@ -75,10 +75,10 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
const GO_DEV_RATE = 20;
|
||||
before(async () => {
|
||||
const serviceGoProdInstance = apm
|
||||
.service(serviceName, 'production', 'go')
|
||||
.service({ name: serviceName, environment: 'production', agentName: 'go' })
|
||||
.instance('instance-a');
|
||||
const serviceGoDevInstance = apm
|
||||
.service(serviceName, 'development', 'go')
|
||||
.service({ name: serviceName, environment: 'development', agentName: 'go' })
|
||||
.instance('instance-b');
|
||||
|
||||
await synthtraceEsClient.index([
|
||||
|
@ -87,7 +87,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
.rate(GO_PROD_RATE)
|
||||
.generator((timestamp) =>
|
||||
serviceGoProdInstance
|
||||
.transaction('GET /apple 🍎 ', 'Worker')
|
||||
.transaction({ transactionName: 'GET /apple 🍎 ', transactionType: 'Worker' })
|
||||
.duration(1000)
|
||||
.timestamp(timestamp)
|
||||
),
|
||||
|
@ -95,7 +95,10 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
.interval('1m')
|
||||
.rate(GO_DEV_RATE)
|
||||
.generator((timestamp) =>
|
||||
serviceGoDevInstance.transaction('GET /apple 🍎 ').duration(1000).timestamp(timestamp)
|
||||
serviceGoDevInstance
|
||||
.transaction({ transactionName: 'GET /apple 🍎 ' })
|
||||
.duration(1000)
|
||||
.timestamp(timestamp)
|
||||
),
|
||||
]);
|
||||
});
|
||||
|
|
|
@ -97,11 +97,17 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
|
||||
registry.when('Find traces when traces exist', { config: 'basic', archives: [] }, () => {
|
||||
before(() => {
|
||||
const java = apm.service('java', 'production', 'java').instance('java');
|
||||
const java = apm
|
||||
.service({ name: 'java', environment: 'production', agentName: 'java' })
|
||||
.instance('java');
|
||||
|
||||
const node = apm.service('node', 'development', 'nodejs').instance('node');
|
||||
const node = apm
|
||||
.service({ name: 'node', environment: 'development', agentName: 'nodejs' })
|
||||
.instance('node');
|
||||
|
||||
const python = apm.service('python', 'production', 'python').instance('python');
|
||||
const python = apm
|
||||
.service({ name: 'python', environment: 'production', agentName: 'python' })
|
||||
.instance('python');
|
||||
|
||||
function generateTrace(timestamp: number, order: Instance[], db?: 'elasticsearch' | 'redis') {
|
||||
return order
|
||||
|
@ -114,7 +120,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
const time = timestamp + invertedIndex * 10;
|
||||
|
||||
const transaction: Transaction = instance
|
||||
.transaction(`GET /${instance.fields['service.name']!}/api`)
|
||||
.transaction({ transactionName: `GET /${instance.fields['service.name']!}/api` })
|
||||
.timestamp(time)
|
||||
.duration(duration);
|
||||
|
||||
|
@ -122,7 +128,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
const next = order[invertedIndex + 1].fields['service.name']!;
|
||||
transaction.children(
|
||||
instance
|
||||
.span(`GET ${next}/api`, 'external', 'http')
|
||||
.span({ spanName: `GET ${next}/api`, spanType: 'external', spanSubtype: 'http' })
|
||||
.destination(next)
|
||||
.duration(duration)
|
||||
.timestamp(time + 1)
|
||||
|
@ -131,7 +137,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
} else if (db) {
|
||||
transaction.children(
|
||||
instance
|
||||
.span(db, 'db', db)
|
||||
.span({ spanName: db, spanType: 'db', spanSubtype: db })
|
||||
.destination(db)
|
||||
.duration(duration)
|
||||
.timestamp(time + 1)
|
||||
|
|
|
@ -55,25 +55,31 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
registry.when('Trace exists', { config: 'basic', archives: [] }, () => {
|
||||
let serviceATraceId: string;
|
||||
before(async () => {
|
||||
const instanceJava = apm.service('synth-apple', 'production', 'java').instance('instance-b');
|
||||
const instanceJava = apm
|
||||
.service({ name: 'synth-apple', environment: 'production', agentName: 'java' })
|
||||
.instance('instance-b');
|
||||
const events = timerange(start, end)
|
||||
.interval('1m')
|
||||
.rate(1)
|
||||
.generator((timestamp) => {
|
||||
return [
|
||||
instanceJava
|
||||
.transaction('GET /apple 🍏')
|
||||
.transaction({ transactionName: 'GET /apple 🍏' })
|
||||
.timestamp(timestamp)
|
||||
.duration(1000)
|
||||
.failure()
|
||||
.errors(
|
||||
instanceJava
|
||||
.error('[ResponseError] index_not_found_exception')
|
||||
.error({ message: '[ResponseError] index_not_found_exception' })
|
||||
.timestamp(timestamp + 50)
|
||||
)
|
||||
.children(
|
||||
instanceJava
|
||||
.span('get_green_apple_🍏', 'db', 'elasticsearch')
|
||||
.span({
|
||||
spanName: 'get_green_apple_🍏',
|
||||
spanType: 'db',
|
||||
spanSubtype: 'elasticsearch',
|
||||
})
|
||||
.timestamp(timestamp + 50)
|
||||
.duration(900)
|
||||
.success()
|
||||
|
|
|
@ -81,7 +81,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
const GO_PROD_ERROR_RATE = 25;
|
||||
before(async () => {
|
||||
const serviceGoProdInstance = apm
|
||||
.service(serviceName, 'production', 'go')
|
||||
.service({ name: serviceName, environment: 'production', agentName: 'go' })
|
||||
.instance('instance-a');
|
||||
|
||||
const transactionName = 'GET /api/product/list';
|
||||
|
@ -92,7 +92,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
.rate(GO_PROD_RATE)
|
||||
.generator((timestamp) =>
|
||||
serviceGoProdInstance
|
||||
.transaction(transactionName)
|
||||
.transaction({ transactionName })
|
||||
.timestamp(timestamp)
|
||||
.duration(1000)
|
||||
.success()
|
||||
|
@ -102,7 +102,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
.rate(GO_PROD_ERROR_RATE)
|
||||
.generator((timestamp) =>
|
||||
serviceGoProdInstance
|
||||
.transaction(transactionName)
|
||||
.transaction({ transactionName })
|
||||
.duration(1000)
|
||||
.timestamp(timestamp)
|
||||
.failure()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue