Skip to content

Commit

Permalink
Add option based configuration support for "report duration threshold…
Browse files Browse the repository at this point in the history
…" feature
  • Loading branch information
Serkan ÖZAL committed May 7, 2022
1 parent e0f06bb commit a2835ec
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,12 @@ const _beforeInvocation = async (opts, event, context) => {
await _startProfiler(opts)
}

const _shouldReport = (invocationDuration) => {
if (reportDurationThreshold) {
return invocationDuration > reportDurationThreshold
const _shouldReport = (opts, invocationDuration) => {
const _reportDurationThreshold =
reportDurationThreshold ||
(opts && opts.report && opts.report.durationThreshold)
if (_reportDurationThreshold) {
return invocationDuration > _reportDurationThreshold
} else {
return true
}
Expand Down Expand Up @@ -151,7 +154,7 @@ const _afterInvocation = async (
fileName ||
(opts && opts.s3 && opts.s3.fileName) ||
MIDDY_PROFILER_S3_FILE_NAME_DEFAULT_VALUE
if (_shouldReport(invocationDuration)) {
if (_shouldReport(opts, invocationDuration)) {
await reportToS3(
_profilingData,
_bucketName,
Expand Down

0 comments on commit a2835ec

Please sign in to comment.