Skip to content

Commit

Permalink
feat: added log-timeout to basic and obfuscate patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
theburningmonk committed Jun 6, 2019
1 parent 02c7710 commit dd47b86
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
12 changes: 1 addition & 11 deletions packages/lambda-powertools-middleware-log-timeout/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A [Middy](https://github.com/middyjs/middy) middleware that will log a timeout e

Main features:

* records an error log message with the invocation event as attribute when an invocation errors
* records an error log message with the invocation event as attribute when an invocation times out

## Getting Started

Expand All @@ -14,16 +14,6 @@ Alternatively, if you use the template `@perform/lambda-powertools-pattern-basic

## API

Accepts a configuration object of the following shape:

```js
{
// Log the timed out error message this many millis before a function
// actually times out. Defaults to 10ms.
thresholdMillis: double
}
```

```js
const middy = require('middy')
const logTimeout = require('@perform/lambda-powertools-middleware-log-timeout')
Expand Down
6 changes: 4 additions & 2 deletions packages/lambda-powertools-pattern-basic/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# lambda-powertools-pattern-basic

A basic pattern that helps you follow our guidelines around logging and monitoring and be a good citizen in DAZN 2.0 :-).
A basic pattern that helps you follow our guidelines around logging and monitoring.

Main features:

Expand All @@ -12,6 +12,8 @@ Main features:

* applies the `@perform/lambda-powertools-middleware-sample-logging` middleware at 1% sample rate

* applies the `@perform/lambda-powertools-middleware-log-timeout` middleware at default 10ms threshold (i.e. log an error message 10ms before an invocation actually times out)

## Getting Started

Install from NPM: `npm install @perform/lambda-powertools-pattern-basic`
Expand All @@ -24,4 +26,4 @@ const wrap = require('@perform/lambda-powertools-pattern-basic')
module.exports.handler = wrap(async (event, context) => {
return 42
})
```
```
2 changes: 2 additions & 0 deletions packages/lambda-powertools-pattern-basic/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const middy = require('middy')
const sampleLogging = require('@perform/lambda-powertools-middleware-sample-logging')
const captureCorrelationIds = require('@perform/lambda-powertools-middleware-correlation-ids')
const logTimeout = require('@perform/lambda-powertools-middleware-log-timeout')

const AWS_REGION = process.env.AWS_REGION || process.env.AWS_DEFAULT_REGION
const FUNCTION_NAME = process.env.AWS_LAMBDA_FUNCTION_NAME
Expand All @@ -17,4 +18,5 @@ module.exports = f => {
return middy(f)
.use(captureCorrelationIds({ sampleDebugLogRate: 0.01 }))
.use(sampleLogging({ sampleRate: 0.01 }))
.use(logTimeout())
}
1 change: 1 addition & 0 deletions packages/lambda-powertools-pattern-basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"dependencies": {
"@perform/lambda-powertools-middleware-correlation-ids": "^1.2.0",
"@perform/lambda-powertools-middleware-sample-logging": "^1.1.7",
"@perform/lambda-powertools-middleware-log-timeout": "^1.0.0",
"middy": "^0.15.0"
},
"publishConfig": {
Expand Down
10 changes: 6 additions & 4 deletions packages/lambda-powertools-pattern-obfuscate/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# lambda-powertools-pattern-obfuscate

A pattern that helps you follow our guidelines around logging and monitoring and be a good citizen in DAZN 2.0 :-) With added ability to obfuscate personal fields.
A pattern that helps you follow our guidelines around logging and monitoring. With added ability to obfuscate personal fields.

Main features:

Expand All @@ -12,8 +12,10 @@ Main features:

* applies the `@perform/lambda-powertools-middleware-sample-logging` middleware at 1% sample rate

* applies the `@perform/lambda-powertools-middleware-obfuscated-logging` middleware with passed obfuscation filters

* applies the `@perform/lambda-powertools-middleware-obfuscated-logging` middleware with passed obfuscation filters

* applies the `@perform/lambda-powertools-middleware-log-timeout` middleware at default 10ms threshold (i.e. log an error message 10ms before an invocation actually times out)

## Getting Started

Install from NPM: `npm install @perform/lambda-powertools-pattern-obfuscate`
Expand All @@ -26,4 +28,4 @@ const obfuscatedWrap = require('@perform/lambda-powertools-pattern-obfuscated')
module.exports.handler = obfuscatedWrap(['Records.*.firstName', 'Records.*.lastName'], async (event, context) => {
return 42
})
```
```
2 changes: 2 additions & 0 deletions packages/lambda-powertools-pattern-obfuscate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const middy = require('middy')
const sampleLogging = require('@perform/lambda-powertools-middleware-sample-logging')
const { obfuscaterMiddleware, FILTERING_MODE: obfuscaterFilteringMode } = require('@perform/lambda-powertools-middleware-obfuscater')
const captureCorrelationIds = require('@perform/lambda-powertools-middleware-correlation-ids')
const logTimeout = require('@perform/lambda-powertools-middleware-log-timeout')

const AWS_REGION = process.env.AWS_REGION || process.env.AWS_DEFAULT_REGION
const FUNCTION_NAME = process.env.AWS_LAMBDA_FUNCTION_NAME
Expand Down Expand Up @@ -53,6 +54,7 @@ const obfuscaterPattern = (obfuscationFilters, f, filterOnAfter = false, filteri
.use(errorObfuscater(obfuscationFilters, filteringMode))
.use(sampleLogging({ sampleRate: 0.01, obfuscationFilters }))
.use(genericObfuscater(obfuscationFilters, filteringMode, filterOnAfter))
.use(logTimeout())
}

module.exports = {
Expand Down
1 change: 1 addition & 0 deletions packages/lambda-powertools-pattern-obfuscate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"@perform/lambda-powertools-middleware-correlation-ids": "^1.2.0",
"@perform/lambda-powertools-middleware-obfuscater": "^1.1.7",
"@perform/lambda-powertools-middleware-sample-logging": "^1.1.7",
"@perform/lambda-powertools-middleware-log-timeout": "^1.0.0",
"middy": "^0.15.0"
},
"devDependencies": {
Expand Down

0 comments on commit dd47b86

Please sign in to comment.