-
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 investigate-in-timeline
- Loading branch information
Showing
264 changed files
with
12,114 additions
and
814 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
Validating CODEOWNERS rules …
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 |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
* 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 { generateLongId, generateShortId } from '../utils/generate_id'; | ||
import { ApmFields } from './apm_fields'; | ||
import { BaseSpan } from './base_span'; | ||
import { Metricset } from './metricset'; | ||
|
||
export type FaasTriggerType = 'http' | 'pubsub' | 'datasource' | 'timer' | 'other'; | ||
|
||
export class Serverless extends BaseSpan { | ||
private readonly metric: Metricset<ApmFields>; | ||
|
||
constructor(fields: ApmFields) { | ||
const faasExection = generateLongId(); | ||
const triggerType = 'other'; | ||
super({ | ||
...fields, | ||
'processor.event': 'transaction', | ||
'transaction.id': generateShortId(), | ||
'transaction.sampled': true, | ||
'faas.execution': faasExection, | ||
'faas.trigger.type': triggerType, | ||
'transaction.name': fields['transaction.name'] || fields['faas.name'], | ||
'transaction.type': 'request', | ||
}); | ||
this.metric = new Metricset<ApmFields>({ | ||
...fields, | ||
'metricset.name': 'app', | ||
'faas.execution': faasExection, | ||
'faas.id': fields['service.name'], | ||
}); | ||
} | ||
|
||
duration(duration: number) { | ||
this.fields['transaction.duration.us'] = duration * 1000; | ||
return this; | ||
} | ||
|
||
coldStart(coldstart: boolean) { | ||
this.fields['faas.coldstart'] = coldstart; | ||
this.metric.fields['faas.coldstart'] = coldstart; | ||
return this; | ||
} | ||
|
||
billedDuration(billedDuration: number) { | ||
this.metric.fields['faas.billed_duration'] = billedDuration; | ||
return this; | ||
} | ||
|
||
faasTimeout(faasTimeout: number) { | ||
this.metric.fields['faas.timeout'] = faasTimeout; | ||
return this; | ||
} | ||
|
||
memory({ total, free }: { total: number; free: number }) { | ||
this.metric.fields['system.memory.total'] = total; | ||
this.metric.fields['system.memory.actual.free'] = free; | ||
return this; | ||
} | ||
|
||
coldStartDuration(coldStartDuration: number) { | ||
this.metric.fields['faas.coldstart_duration'] = coldStartDuration; | ||
return this; | ||
} | ||
|
||
faasDuration(faasDuration: number) { | ||
this.metric.fields['faas.duration'] = faasDuration; | ||
return this; | ||
} | ||
|
||
timestamp(time: number): this { | ||
super.timestamp(time); | ||
this.metric.fields['@timestamp'] = time; | ||
return this; | ||
} | ||
|
||
serialize(): ApmFields[] { | ||
const transaction = super.serialize(); | ||
const metric = this.metric.serialize(); | ||
return [...transaction, ...metric]; | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
packages/kbn-apm-synthtrace/src/lib/apm/serverless_function.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,45 @@ | ||
/* | ||
* 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 { Entity } from '../entity'; | ||
import { generateShortId } from '../utils/generate_id'; | ||
import { ApmFields } from './apm_fields'; | ||
import { ServerlessInstance } from './serverless_instance'; | ||
|
||
export class ServerlessFunction extends Entity<ApmFields> { | ||
instance({ instanceName, ...apmFields }: { instanceName: string } & ApmFields) { | ||
return new ServerlessInstance({ | ||
...this.fields, | ||
['service.node.name']: instanceName, | ||
'host.name': instanceName, | ||
...apmFields, | ||
}); | ||
} | ||
} | ||
|
||
export function serverlessFunction({ | ||
functionName, | ||
serviceName, | ||
environment, | ||
agentName, | ||
}: { | ||
functionName: string; | ||
environment: string; | ||
agentName: string; | ||
serviceName?: string; | ||
}) { | ||
const faasId = `arn:aws:lambda:us-west-2:${generateShortId()}:function:${functionName}`; | ||
return new ServerlessFunction({ | ||
'service.name': serviceName || faasId, | ||
'faas.id': faasId, | ||
'faas.name': functionName, | ||
'service.environment': environment, | ||
'agent.name': agentName, | ||
'service.runtime.name': 'AWS_lambda', | ||
}); | ||
} |
22 changes: 22 additions & 0 deletions
22
packages/kbn-apm-synthtrace/src/lib/apm/serverless_instance.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,22 @@ | ||
/* | ||
* 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 { Entity } from '../entity'; | ||
import { ApmFields } from './apm_fields'; | ||
import { FaasTriggerType, Serverless } from './serverless'; | ||
|
||
export class ServerlessInstance extends Entity<ApmFields> { | ||
invocation(params: { transactionName?: string; faasTriggerType?: FaasTriggerType } = {}) { | ||
const { transactionName, faasTriggerType = 'other' } = params; | ||
return new Serverless({ | ||
...this.fields, | ||
'transaction.name': transactionName, | ||
'faas.trigger.type': faasTriggerType, | ||
}); | ||
} | ||
} |
Oops, something went wrong.