-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[APM] AWS lambda estimated cost #143986
[APM] AWS lambda estimated cost #143986
Changes from 6 commits
7b46afb
27d39f1
4181937
f18a94e
eac10bd
dcb0999
9af962c
3645a90
6e19c00
3394f13
0dd60e5
df8bd2f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,11 @@ | |
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
import { calcMemoryUsed, calcMemoryUsedRate } from './helper'; | ||
import { | ||
calcMemoryUsed, | ||
calcMemoryUsedRate, | ||
calcEstimatedCost, | ||
} from './helper'; | ||
describe('calcMemoryUsed', () => { | ||
it('returns undefined when memory values are no a number', () => { | ||
[ | ||
|
@@ -38,3 +42,85 @@ describe('calcMemoryUsedRate', () => { | |
expect(calcMemoryUsedRate({ memoryFree: 50, memoryTotal: 100 })).toBe(0.5); | ||
}); | ||
}); | ||
|
||
const AWS_LAMBDA_PRICE_FACTOR = { | ||
x86_64: 0.0000166667, | ||
arm: 0.0000133334, | ||
}; | ||
|
||
describe('calcEstimatedCost', () => { | ||
it('returns 0 when price factor is not defined', () => { | ||
cauemarcondes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
expect( | ||
calcEstimatedCost({ | ||
totalMemory: 1, | ||
billedDuration: 1, | ||
transactionThroughput: 1, | ||
architecture: 'arm', | ||
}) | ||
).toEqual(0); | ||
}); | ||
|
||
it('returns 0 when architecture is not defined', () => { | ||
expect( | ||
cauemarcondes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
calcEstimatedCost({ | ||
totalMemory: 1, | ||
billedDuration: 1, | ||
transactionThroughput: 1, | ||
awsLambdaPriceFactor: AWS_LAMBDA_PRICE_FACTOR, | ||
}) | ||
).toEqual(0); | ||
}); | ||
|
||
it('returns 0 when compute usage is not defined', () => { | ||
expect( | ||
calcEstimatedCost({ | ||
transactionThroughput: 1, | ||
awsLambdaPriceFactor: AWS_LAMBDA_PRICE_FACTOR, | ||
architecture: 'arm', | ||
}) | ||
).toEqual(0); | ||
}); | ||
|
||
it('returns 0 when request cost per million is not defined', () => { | ||
expect( | ||
calcEstimatedCost({ | ||
totalMemory: 1, | ||
billedDuration: 1, | ||
transactionThroughput: 1, | ||
awsLambdaPriceFactor: AWS_LAMBDA_PRICE_FACTOR, | ||
architecture: 'arm', | ||
}) | ||
).toEqual(0); | ||
}); | ||
|
||
describe('x86_64 architecture', () => { | ||
const architecture = 'x86_64'; | ||
it('returns correct cost when usage is less than 6 b gb-sec', () => { | ||
expect( | ||
calcEstimatedCost({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it'd be useful to have several invocations here, it would make it more clear from just reading the test how different factors influence the final result. |
||
awsLambdaPriceFactor: AWS_LAMBDA_PRICE_FACTOR, | ||
architecture, | ||
billedDuration: 4000, | ||
totalMemory: 536870912, // 0.5gb | ||
transactionThroughput: 100000, | ||
awsLambdaRequestCostPerMillion: 0.2, | ||
}) | ||
).toEqual(0.03); | ||
}); | ||
}); | ||
describe('arm architecture', () => { | ||
const architecture = 'arm'; | ||
it('returns correct cost', () => { | ||
expect( | ||
calcEstimatedCost({ | ||
awsLambdaPriceFactor: AWS_LAMBDA_PRICE_FACTOR, | ||
architecture, | ||
billedDuration: 8000, | ||
totalMemory: 536870912, // 0.5gb | ||
transactionThroughput: 200000, | ||
awsLambdaRequestCostPerMillion: 0.2, | ||
}) | ||
).toEqual(0.05); | ||
}); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be useful to have a tooltip to inform the user how the avg cost is calculated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@boriskirov can you come up with a copy, please?