-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into bfilar.ml-refactor-2
- Loading branch information
Showing
110 changed files
with
4,384 additions
and
1,455 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,35 +106,36 @@ The API returns details about the case and its comments. For example: | |
"comments":[{ | ||
"id": "8af6ac20-74f6-11ea-b83a-553aecdb28b6", | ||
"version": "WzIwNjM3LDFd", | ||
"comment":"That is nothing - Ethan Hunt answered a targeted social media campaign promoting phishy pension schemes to IMF operatives. Even worse, he likes baked beans.", | ||
"type":"user", | ||
"owner":"cases", | ||
"created_at":"2022-03-24T00:37:10.832Z", | ||
"comment": "That is nothing - Ethan Hunt answered a targeted social media campaign promoting phishy pension schemes to IMF operatives. Even worse, he likes baked beans.", | ||
"type": "user", | ||
"owner": "cases", | ||
"created_at": "2022-03-24T00:37:10.832Z", | ||
"created_by": { | ||
"email": "[email protected]", | ||
"full_name": "Ms Moneypenny", | ||
"username": "moneypenny" | ||
}, | ||
"pushed_at":null, | ||
"pushed_by":null, | ||
"updated_at":"2022-03-24T01:27:06.210Z", | ||
"pushed_at": null, | ||
"pushed_by": null, | ||
"updated_at": "2022-03-24T01:27:06.210Z", | ||
"updated_by": { | ||
"email": "[email protected]", | ||
"full_name": "James Bond", | ||
"username": "_007" | ||
} | ||
} | ||
], | ||
"totalAlerts":0, | ||
"totalAlerts": 0, | ||
"id": "293f1bc0-74f6-11ea-b83a-553aecdb28b6", | ||
"version": "WzIwNjM2LDFd", | ||
"totalComment": 1, | ||
"title": "This case will self-destruct in 5 seconds", | ||
"tags": ["phishing","social engineering"], | ||
"tags": ["phishing","social engineering"], | ||
"description": "James Bond clicked on a highly suspicious email banner advertising cheap holidays for underpaid civil servants.", | ||
"settings": {"syncAlerts":false}, | ||
"owner": "cases"," | ||
closed_at": null, | ||
"owner": "cases", | ||
"duration": null, | ||
"closed_at": null, | ||
"closed_by": null, | ||
"created_at": "2022-03-24T00:37:03.906Z", | ||
"created_by": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 114 additions & 0 deletions
114
packages/elastic-apm-synthtrace/src/scripts/examples/04_span_links.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { compact, shuffle } from 'lodash'; | ||
import { apm, ApmFields, EntityArrayIterable, timerange } from '../..'; | ||
import { generateLongId, generateShortId } from '../../lib/utils/generate_id'; | ||
import { Scenario } from '../scenario'; | ||
|
||
function generateExternalSpanLinks() { | ||
// randomly creates external span links 0 - 10 | ||
return Array(Math.floor(Math.random() * 11)) | ||
.fill(0) | ||
.map(() => ({ span: { id: generateLongId() }, trace: { id: generateShortId() } })); | ||
} | ||
|
||
function getSpanLinksFromEvents(events: ApmFields[]) { | ||
return compact( | ||
events.map((event) => { | ||
const spanId = event['span.id']; | ||
return spanId ? { span: { id: spanId }, trace: { id: event['trace.id']! } } : undefined; | ||
}) | ||
); | ||
} | ||
|
||
const scenario: Scenario<ApmFields> = async () => { | ||
return { | ||
generate: ({ from, to }) => { | ||
const producerInternalOnlyInstance = apm | ||
.service('producer-internal-only', 'production', 'go') | ||
.instance('instance-a'); | ||
const producerInternalOnlyEvents = timerange( | ||
new Date('2022-04-25T19:00:00.000Z'), | ||
new Date('2022-04-25T19:01:00.000Z') | ||
) | ||
.interval('1m') | ||
.rate(1) | ||
.generator((timestamp) => { | ||
return producerInternalOnlyInstance | ||
.transaction('Transaction A') | ||
.timestamp(timestamp) | ||
.duration(1000) | ||
.success() | ||
.children( | ||
producerInternalOnlyInstance | ||
.span('Span A', 'custom') | ||
.timestamp(timestamp + 50) | ||
.duration(100) | ||
.success() | ||
); | ||
}); | ||
|
||
const producerInternalOnlyApmFields = producerInternalOnlyEvents.toArray(); | ||
const spanASpanLink = getSpanLinksFromEvents(producerInternalOnlyApmFields); | ||
|
||
const producerConsumerInstance = apm | ||
.service('producer-consumer', 'production', 'java') | ||
.instance('instance-b'); | ||
const producerConsumerEvents = timerange(from, to) | ||
.interval('1m') | ||
.rate(1) | ||
.generator((timestamp) => { | ||
return producerConsumerInstance | ||
.transaction('Transaction B') | ||
.timestamp(timestamp) | ||
.duration(1000) | ||
.success() | ||
.children( | ||
producerConsumerInstance | ||
.span('Span B', 'external') | ||
.defaults({ | ||
'span.links': shuffle([...generateExternalSpanLinks(), ...spanASpanLink]), | ||
}) | ||
.timestamp(timestamp + 50) | ||
.duration(900) | ||
.success() | ||
); | ||
}); | ||
|
||
const producerConsumerApmFields = producerConsumerEvents.toArray(); | ||
const spanBSpanLink = getSpanLinksFromEvents(producerConsumerApmFields); | ||
|
||
const consumerInstance = apm.service('consumer', 'production', 'ruby').instance('instance-c'); | ||
const consumerEvents = timerange(from, to) | ||
.interval('1m') | ||
.rate(1) | ||
.generator((timestamp) => { | ||
return consumerInstance | ||
.transaction('Transaction C') | ||
.timestamp(timestamp) | ||
.duration(1000) | ||
.success() | ||
.children( | ||
consumerInstance | ||
.span('Span C', 'external') | ||
.defaults({ 'span.links': spanBSpanLink }) | ||
.timestamp(timestamp + 50) | ||
.duration(900) | ||
.success() | ||
); | ||
}); | ||
|
||
return new EntityArrayIterable(producerInternalOnlyApmFields) | ||
.merge(consumerEvents) | ||
.merge(new EntityArrayIterable(producerConsumerApmFields)); | ||
}, | ||
}; | ||
}; | ||
|
||
export default scenario; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.