Skip to content

chore(all): Switch to use only eu-west-1 in tests and doc #562

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

Merged
merged 4 commits into from
Feb 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions docs/core/logger.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ This functionality will include the following keys in your structured logs:
Key | Example
------------------------------------------------- | ---------------------------------------------------------------------------------
**cold_start**: `bool` | `false`
**function_name** `string` | `shopping-cart-api-lambda-prod-eu-central-1`
**function_name** `string` | `shopping-cart-api-lambda-prod-eu-west-1`
**function_memory_size**: `number` | `128`
**function_arn**: `string` | `arn:aws:lambda:eu-central-1:123456789012:function:shopping-cart-api-lambda-prod-eu-central-1`
**function_arn**: `string` | `arn:aws:lambda:eu-west-1:123456789012:function:shopping-cart-api-lambda-prod-eu-west-1`
**function_request_id**: `string` | `c6af9ac6-7b61-11e6-9a41-93e812345678`

=== "Manual"
Expand Down Expand Up @@ -165,10 +165,10 @@ In each case, the printed log will look like this:
```json hl_lines="2-6"
{
"cold_start": true,
"function_arn": "arn:aws:lambda:eu-central-1:123456789012:function:shopping-cart-api-lambda-prod-eu-central-1",
"function_arn": "arn:aws:lambda:eu-west-1:123456789012:function:shopping-cart-api-lambda-prod-eu-west-1",
"function_memory_size": 128,
"function_request_id": "c6af9ac6-7b61-11e6-9a41-93e812345678",
"function_name": "shopping-cart-api-lambda-prod-eu-central-1",
"function_name": "shopping-cart-api-lambda-prod-eu-west-1",
"level": "INFO",
"message": "This is an INFO log with some context",
"service": "serverlessAirline",
Expand All @@ -193,7 +193,7 @@ You can append additional persistent keys and values in the logs generated durin
const logger = new Logger({
persistentLogAttributes: {
aws_account_id: '123456789012',
aws_region: 'eu-central-1',
aws_region: 'eu-west-1',
logger: {
name: '@aws-lambda-powertools/logger',
version: '0.0.1',
Expand All @@ -204,7 +204,7 @@ You can append additional persistent keys and values in the logs generated durin
// OR add persistent log keys to an existing Logger instance with the appendKeys method:
// logger.appendKeys({
// aws_account_id: '123456789012',
// aws_region: 'eu-central-1',
// aws_region: 'eu-west-1',
// logger: {
// name: '@aws-lambda-powertools/logger',
// version: '0.0.1',
Expand Down Expand Up @@ -234,7 +234,7 @@ You can append additional persistent keys and values in the logs generated durin
"timestamp": "2021-12-12T21:49:58.084Z",
"xray_trace_id": "abcdef123456abcdef123456abcdef123456",
"aws_account_id": "123456789012",
"aws_region": "eu-central-1",
"aws_region": "eu-west-1",
"logger": {
"name": "@aws-lambda-powertools/logger",
"version": "0.0.1"
Expand All @@ -247,7 +247,7 @@ You can append additional persistent keys and values in the logs generated durin
"timestamp": "2021-12-12T21:49:58.088Z",
"xray_trace_id": "abcdef123456abcdef123456abcdef123456",
"aws_account_id": "123456789012",
"aws_region": "eu-central-1",
"aws_region": "eu-west-1",
"logger": {
"name": "@aws-lambda-powertools/logger",
"version": "0.0.1"
Expand Down Expand Up @@ -666,15 +666,15 @@ This is how the printed log would look:
{
"message": "This is an INFO log",
"service": "serverlessAirline",
"awsRegion": "eu-central-1",
"awsRegion": "eu-west-1",
"correlationIds": {
"awsRequestId": "c6af9ac6-7b61-11e6-9a41-93e812345678",
"xRayTraceId": "abcdef123456abcdef123456abcdef123456",
"myCustomCorrelationId": "foo-bar-baz"
},
"lambdaFunction": {
"name": "shopping-cart-api-lambda-prod-eu-central-1",
"arn": "arn:aws:lambda:eu-central-1:123456789012:function:shopping-cart-api-lambda-prod-eu-central-1",
"name": "shopping-cart-api-lambda-prod-eu-west-1",
"arn": "arn:aws:lambda:eu-west-1:123456789012:function:shopping-cart-api-lambda-prod-eu-west-1",
"memoryLimitInMB": 128,
"version": "$LATEST",
"coldStart": true
Expand Down Expand Up @@ -709,7 +709,7 @@ This is a Jest sample that provides the minimum information necessary for Logger
memoryLimitInMB: '128',
logGroupName: '/aws/lambda/foo-bar-function',
logStreamName: '2021/03/09/[$LATEST]abcdef123456abcdef123456abcdef123456',
invokedFunctionArn: 'arn:aws:lambda:eu-central-1:123456789012:function:foo-bar-function',
invokedFunctionArn: 'arn:aws:lambda:eu-west-1:123456789012:function:foo-bar-function',
awsRequestId: 'c6af9ac6-7b61-11e6-9a41-93e812345678',
getRemainingTimeInMillis: () => 1234,
done: () => console.log('Done!'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const helloworldContext: Context = {
memoryLimitInMB: '128',
logGroupName: '/aws/lambda/foo-bar-function-123456abcdef',
logStreamName: '2021/03/09/[$LATEST]abcdef123456abcdef123456abcdef123456',
invokedFunctionArn: 'arn:aws:lambda:eu-central-1:123456789012:function:Example',
invokedFunctionArn: 'arn:aws:lambda:eu-west-1:123456789012:function:Example',
awsRequestId: 'c6af9ac6-7b61-11e6-9a41-93e8deadbeef',
getRemainingTimeInMillis: () => 1234,
done: () => console.log('Done!'),
Expand Down
2 changes: 1 addition & 1 deletion packages/logger/examples/persistent-attributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const lambdaHandler: Handler = async () => {
// Add persistent log keys to an existing Logger instance:
logger.appendKeys({
aws_account_id: '123456789012',
aws_region: 'eu-central-1',
aws_region: 'eu-west-1',
logger: {
name: powertool.name,
version: powertool.version,
Expand Down
2 changes: 1 addition & 1 deletion packages/logger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"test:e2e:nodejs12x": "RUNTIME=nodejs12x jest --group=e2e/logger",
"test:e2e:nodejs14x": "RUNTIME=nodejs14x jest --group=e2e/logger",
"test:e2e": "concurrently \"npm:test:e2e:nodejs12x\" \"npm:test:e2e:nodejs14x\"",
"watch": "jest --watch",
"watch": "jest --watch --group=unit",
"build": "tsc",
"lint": "eslint --ext .ts --fix --no-error-on-unmatched-pattern src tests",
"format": "eslint --fix --ext .ts --fix --no-error-on-unmatched-pattern src tests",
Expand Down
6 changes: 3 additions & 3 deletions packages/logger/tests/helpers/InvocationLogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ export class InvocationLogs {
* In each log, each content is separated by '\t'
* [
* 'START RequestId: c6af9ac6-7b61-11e6-9a41-93e812345678 Version: $LATEST',
* '2022-01-27T16:04:39.323Z\tc6af9ac6-7b61-11e6-9a41-93e812345678\tINFO\t{"cold_start":true,"function_arn":"arn:aws:lambda:eu-central-1:561912387782:function:loggerMiddyStandardFeatures-c555a2ec-1121-4586-9c04-185ab36ea34c","function_memory_size":128,"function_name":"loggerMiddyStandardFeatures-c555a2ec-1121-4586-9c04-185ab36ea34c","function_request_id":"7f586697-238a-4c3b-9250-a5f057c1119c","level":"INFO","message":"This is an INFO log with some context and persistent key","service":"logger-e2e-testing","timestamp":"2022-01-27T16:04:39.323Z","persistentKey":"works"}',
* '2022-01-27T16:04:39.323Z\tc6af9ac6-7b61-11e6-9a41-93e812345678\tINFO\t{"cold_start":true,"function_arn":"arn:aws:lambda:eu-central-1:561912387782:function:loggerMiddyStandardFeatures-c555a2ec-1121-4586-9c04-185ab36ea34c","function_memory_size":128,"function_name":"loggerMiddyStandardFeatures-c555a2ec-1121-4586-9c04-185ab36ea34c","function_request_id":"7f586697-238a-4c3b-9250-a5f057c1119c","level":"INFO","message":"This is an INFO log with some context","service":"logger-e2e-testing","timestamp":"2022-01-27T16:04:39.323Z","persistentKey":"works","additionalKey":"additionalValue"}',
* '2022-01-27T16:04:39.323Z\tc6af9ac6-7b61-11e6-9a41-93e812345678\tERROR\t{"cold_start":true,"function_arn":"arn:aws:lambda:eu-central-1:561912387782:function:loggerMiddyStandardFeatures-c555a2ec-1121-4586-9c04-185ab36ea34c","function_memory_size":128,"function_name":"loggerMiddyStandardFeatures-c555a2ec-1121-4586-9c04-185ab36ea34c","function_request_id":"7f586697-238a-4c3b-9250-a5f057c1119c","level":"ERROR","message":"There was an error","service":"logger-e2e-testing","timestamp":"2022-01-27T16:04:39.323Z","persistentKey":"works","error":{"name":"Error","location":"/var/task/index.js:2778","message":"you cannot prevent this","stack":"Error: you cannot prevent this\\n at testFunction (/var/task/index.js:2778:11)\\n at runRequest (/var/task/index.js:2314:36)"}}',
* '2022-01-27T16:04:39.323Z\tc6af9ac6-7b61-11e6-9a41-93e812345678\tINFO\t{"cold_start":true,"function_arn":"arn:aws:lambda:eu-west-1:561912387782:function:loggerMiddyStandardFeatures-c555a2ec-1121-4586-9c04-185ab36ea34c","function_memory_size":128,"function_name":"loggerMiddyStandardFeatures-c555a2ec-1121-4586-9c04-185ab36ea34c","function_request_id":"7f586697-238a-4c3b-9250-a5f057c1119c","level":"INFO","message":"This is an INFO log with some context and persistent key","service":"logger-e2e-testing","timestamp":"2022-01-27T16:04:39.323Z","persistentKey":"works"}',
* '2022-01-27T16:04:39.323Z\tc6af9ac6-7b61-11e6-9a41-93e812345678\tINFO\t{"cold_start":true,"function_arn":"arn:aws:lambda:eu-west-1:561912387782:function:loggerMiddyStandardFeatures-c555a2ec-1121-4586-9c04-185ab36ea34c","function_memory_size":128,"function_name":"loggerMiddyStandardFeatures-c555a2ec-1121-4586-9c04-185ab36ea34c","function_request_id":"7f586697-238a-4c3b-9250-a5f057c1119c","level":"INFO","message":"This is an INFO log with some context","service":"logger-e2e-testing","timestamp":"2022-01-27T16:04:39.323Z","persistentKey":"works","additionalKey":"additionalValue"}',
* '2022-01-27T16:04:39.323Z\tc6af9ac6-7b61-11e6-9a41-93e812345678\tERROR\t{"cold_start":true,"function_arn":"arn:aws:lambda:eu-west-1:561912387782:function:loggerMiddyStandardFeatures-c555a2ec-1121-4586-9c04-185ab36ea34c","function_memory_size":128,"function_name":"loggerMiddyStandardFeatures-c555a2ec-1121-4586-9c04-185ab36ea34c","function_request_id":"7f586697-238a-4c3b-9250-a5f057c1119c","level":"ERROR","message":"There was an error","service":"logger-e2e-testing","timestamp":"2022-01-27T16:04:39.323Z","persistentKey":"works","error":{"name":"Error","location":"/var/task/index.js:2778","message":"you cannot prevent this","stack":"Error: you cannot prevent this\\n at testFunction (/var/task/index.js:2778:11)\\n at runRequest (/var/task/index.js:2314:36)"}}',
* 'END RequestId: c6af9ac6-7b61-11e6-9a41-93e812345678',
* 'REPORT RequestId: c6af9ac6-7b61-11e6-9a41-93e812345678\tDuration: 2.16 ms\tBilled Duration: 3 ms\tMemory Size: 128 MB\tMax Memory Used: 57 MB\t',
* ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
process.env._X_AMZN_TRACE_ID = 'abcdef123456abcdef123456abcdef123456';
process.env.AWS_LAMBDA_FUNCTION_NAME = 'my-lambda-function';
process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE = '128';
process.env.AWS_REGION = 'eu-central-1';
process.env.AWS_REGION = 'eu-west-1';

// Powertools variables
process.env.LOG_LEVEL = 'DEBUG';
Expand Down
30 changes: 15 additions & 15 deletions packages/logger/tests/unit/Logger.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ describe('Class: Logger', () => {
expect(console[methodOfLogger]).toBeCalledTimes(1);
expect(console[methodOfLogger]).toHaveBeenNthCalledWith(1, JSON.stringify({
cold_start: true,
function_arn: 'arn:aws:lambda:eu-central-1:123456789012:function:foo-bar-function',
function_arn: 'arn:aws:lambda:eu-west-1:123456789012:function:foo-bar-function',
function_memory_size: 128,
function_name: 'foo-bar-function',
function_request_id: 'c6af9ac6-7b61-11e6-9a41-93e812345678',
Expand Down Expand Up @@ -368,7 +368,7 @@ describe('Class: Logger', () => {
logLevel: 'DEBUG',
persistentLogAttributes: {
aws_account_id: '123456789012',
aws_region: 'eu-central-1',
aws_region: 'eu-west-1',
},
});

Expand All @@ -386,7 +386,7 @@ describe('Class: Logger', () => {
timestamp: '2016-06-20T12:08:10.000Z',
xray_trace_id: 'abcdef123456abcdef123456abcdef123456',
aws_account_id: '123456789012',
aws_region: 'eu-central-1',
aws_region: 'eu-west-1',
}));
});

Expand Down Expand Up @@ -446,7 +446,7 @@ describe('Class: Logger', () => {
memoryLimitInMB: '128',
logGroupName: '/aws/lambda/foo-bar-function-with-cold-start',
logStreamName: '2021/03/09/[$LATEST]abcdef123456abcdef123456abcdef123456',
invokedFunctionArn: 'arn:aws:lambda:eu-central-1:123456789012:function:foo-bar-function-with-cold-start',
invokedFunctionArn: 'arn:aws:lambda:eu-west-1:123456789012:function:foo-bar-function-with-cold-start',
awsRequestId: 'c6af9ac6-7b61-11e6-9a41-93e812345678',
getRemainingTimeInMillis: () => 1234,
done: () => console.log('Done!'),
Expand Down Expand Up @@ -477,14 +477,14 @@ describe('Class: Logger', () => {
logsSampled: false,
persistentLogAttributes: {},
powertoolLogData: {
awsRegion: 'eu-central-1',
awsRegion: 'eu-west-1',
environment: '',
lambdaContext: {
awsRequestId: 'c6af9ac6-7b61-11e6-9a41-93e812345678',
coldStart: true,
functionName: 'foo-bar-function-with-cold-start',
functionVersion: '$LATEST',
invokedFunctionArn: 'arn:aws:lambda:eu-central-1:123456789012:function:foo-bar-function-with-cold-start',
invokedFunctionArn: 'arn:aws:lambda:eu-west-1:123456789012:function:foo-bar-function-with-cold-start',
memoryLimitInMB: 128,
},
sampleRateValue: undefined,
Expand Down Expand Up @@ -544,7 +544,7 @@ describe('Class: Logger', () => {
// Act
logger.appendKeys({
aws_account_id: '123456789012',
aws_region: 'eu-central-1',
aws_region: 'eu-west-1',
logger: {
name: 'aws-lambda-powertool-typescript',
version: '0.2.4',
Expand All @@ -555,7 +555,7 @@ describe('Class: Logger', () => {
expect(logger).toEqual(expect.objectContaining({
persistentLogAttributes: {
aws_account_id: '123456789012',
aws_region: 'eu-central-1',
aws_region: 'eu-west-1',
logger: {
name: 'aws-lambda-powertool-typescript',
version: '0.2.4',
Expand Down Expand Up @@ -708,7 +708,7 @@ describe('Class: Logger', () => {
expect(console['info']).toBeCalledTimes(1);
expect(console['info']).toHaveBeenNthCalledWith(1, JSON.stringify({
cold_start: true,
function_arn: 'arn:aws:lambda:eu-central-1:123456789012:function:foo-bar-function',
function_arn: 'arn:aws:lambda:eu-west-1:123456789012:function:foo-bar-function',
function_memory_size: 128,
function_name: 'foo-bar-function',
function_request_id: 'c6af9ac6-7b61-11e6-9a41-93e812345678',
Expand Down Expand Up @@ -751,7 +751,7 @@ describe('Class: Logger', () => {
}));
expect(console['info']).toHaveBeenNthCalledWith(2, JSON.stringify({
cold_start: true,
function_arn: 'arn:aws:lambda:eu-central-1:123456789012:function:foo-bar-function',
function_arn: 'arn:aws:lambda:eu-west-1:123456789012:function:foo-bar-function',
function_memory_size: 128,
function_name: 'foo-bar-function',
function_request_id: 'c6af9ac6-7b61-11e6-9a41-93e812345678',
Expand Down Expand Up @@ -798,7 +798,7 @@ describe('Class: Logger', () => {
}));
expect(console['info']).toHaveBeenNthCalledWith(2, JSON.stringify({
cold_start: true,
function_arn: 'arn:aws:lambda:eu-central-1:123456789012:function:foo-bar-function',
function_arn: 'arn:aws:lambda:eu-west-1:123456789012:function:foo-bar-function',
function_memory_size: 128,
function_name: 'foo-bar-function',
function_request_id: 'c6af9ac6-7b61-11e6-9a41-93e812345678',
Expand Down Expand Up @@ -905,7 +905,7 @@ describe('Class: Logger', () => {
logsSampled: false,
persistentLogAttributes: {},
powertoolLogData: {
awsRegion: 'eu-central-1',
awsRegion: 'eu-west-1',
environment: '',
sampleRateValue: undefined,
serviceName: 'hello-world',
Expand All @@ -929,7 +929,7 @@ describe('Class: Logger', () => {
extra: 'This is an attribute that will be logged only by the child logger',
},
powertoolLogData: {
awsRegion: 'eu-central-1',
awsRegion: 'eu-west-1',
environment: '',
sampleRateValue: undefined,
serviceName: 'hello-world',
Expand All @@ -951,7 +951,7 @@ describe('Class: Logger', () => {
logsSampled: true,
persistentLogAttributes: {},
powertoolLogData: {
awsRegion: 'eu-central-1',
awsRegion: 'eu-west-1',
environment: '',
sampleRateValue: 1,
serviceName: 'hello-world',
Expand All @@ -973,7 +973,7 @@ describe('Class: Logger', () => {
logsSampled: false,
persistentLogAttributes: {},
powertoolLogData: {
awsRegion: 'eu-central-1',
awsRegion: 'eu-west-1',
environment: '',
sampleRateValue: undefined,
serviceName: 'hello-world',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('Class: PowertoolLogFormatter', () => {
const formatter = new PowertoolLogFormatter();
const unformattedAttributes = {
sampleRateValue: undefined,
awsRegion: 'eu-central-1',
awsRegion: 'eu-west-1',
environment: '',
serviceName: 'hello-world',
xRayTraceId: 'abcdef123456abcdef123456abcdef123456',
Expand Down Expand Up @@ -59,7 +59,7 @@ describe('Class: PowertoolLogFormatter', () => {
const formatter = new PowertoolLogFormatter();
const unformattedAttributes: UnformattedAttributes = {
sampleRateValue: 0.25,
awsRegion: 'eu-central-1',
awsRegion: 'eu-west-1',
environment: 'prod',
serviceName: 'hello-world',
xRayTraceId: 'abcdef123456abcdef123456abcdef123456',
Expand All @@ -72,7 +72,7 @@ describe('Class: PowertoolLogFormatter', () => {
memoryLimitInMB: 123,
functionVersion: '1.23.3',
coldStart: true,
invokedFunctionArn: 'arn:aws:lambda:eu-central-1:123456789012:function:Example',
invokedFunctionArn: 'arn:aws:lambda:eu-west-1:123456789012:function:Example',
awsRequestId: 'abcdefg123456789',
},
};
Expand All @@ -83,7 +83,7 @@ describe('Class: PowertoolLogFormatter', () => {
// Assess
expect(value).toEqual({
cold_start: true,
function_arn: 'arn:aws:lambda:eu-central-1:123456789012:function:Example',
function_arn: 'arn:aws:lambda:eu-west-1:123456789012:function:Example',
function_memory_size: 123,
function_name: 'my-lambda-function',
function_request_id: 'abcdefg123456789',
Expand Down
Loading