Skip to content
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

Remove httpHeaders from $metadata #1491

Closed
trivikr opened this issue Sep 1, 2020 · 2 comments · Fixed by smithy-lang/smithy-typescript#251 or #1811
Closed

Remove httpHeaders from $metadata #1491

trivikr opened this issue Sep 1, 2020 · 2 comments · Fixed by smithy-lang/smithy-typescript#251 or #1811
Labels
feature-request New feature or enhancement. May require GitHub community feedback.

Comments

@trivikr
Copy link
Member

trivikr commented Sep 1, 2020

Is your feature request related to a problem? Please describe.
The httpHeaders for both request and response are now available through LOG_LEVEL=debug in SDK

Code
const { DynamoDB } = require("@aws-sdk/client-dynamodb");
const logger = require("pino")({ level: process.env.LOG_LEVEL || "info" });

(async () => {
  const client = new DynamoDB({ logger });
  await client.listTables({ Limit: 1 });
})();
Output with LOG_LEVEL=debug
$ LOG_LEVEL=debug node logger.js | jq '[."$metadata".httpHeaders,.httpResponse.headers]'
[
  null,
  null
]
[
  null,
  {
    "server": "Server",
    "date": "Tue, 01 Sep 2020 23:37:12 GMT",
    "content-type": "application/x-amz-json-1.0",
    "content-length": "73",
    "connection": "keep-alive",
    "x-amzn-requestid": "GCPCESF8VHS0R5U544ALE6NR47VV4KQNSO5AEMVJF66Q9ASUAAJG",
    "x-amz-crc32": "773170490"
  }
]
[
  {
    "server": "Server",
    "date": "Tue, 01 Sep 2020 23:37:12 GMT",
    "content-type": "application/x-amz-json-1.0",
    "content-length": "73",
    "connection": "keep-alive",
    "x-amzn-requestid": "GCPCESF8VHS0R5U544ALE6NR47VV4KQNSO5AEMVJF66Q9ASUAAJG",
    "x-amz-crc32": "773170490"
  },
  null
]
Output (default)
$ node logger.js | jq '."$metadata"'            
{
  "httpStatusCode": 200,
  "httpHeaders": {
    "server": "Server",
    "date": "Tue, 01 Sep 2020 23:40:42 GMT",
    "content-type": "application/x-amz-json-1.0",
    "content-length": "73",
    "connection": "keep-alive",
    "x-amzn-requestid": "5GMSNU7A4VJGCKT9DMMMP7B3ANVV4KQNSO5AEMVJF66Q9ASUAAJG",
    "x-amz-crc32": "773170490"
  },
  "requestId": "5GMSNU7A4VJGCKT9DMMMP7B3ANVV4KQNSO5AEMVJF66Q9ASUAAJG"
}

Note that response headers are accessible from httpResponse.headers when LOG_LEVEL=debug is used

Describe the solution you'd like
Remove httpHeaders from $metadata as:

  • it already populates information important for debugging (like requestId)
  • the response HTTP headers, if required, are available by setting LOG_LEVEL=debug with your favorite logger

Describe alternatives you've considered
Stick with examining redundant httpHeaders in $metadata

@trivikr trivikr added the feature-request New feature or enhancement. May require GitHub community feedback. label Sep 1, 2020
@trivikr
Copy link
Member Author

trivikr commented Sep 14, 2020

The $metadata itself might be removed from API response #1490

We might add a middleware to do all of the following:

  • Get important values (requestId, extendedRequestId, cfId) from httpHeaders
  • Remove httpHeaders from $metadata
  • Log metadata under logger.info, along with important values.
  • Delete metadata from API response.

This would delegate the responsibility of populating important values from protocols file to middleware. The entire deserializeMetadata method can be moved to the middleware.

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request New feature or enhancement. May require GitHub community feedback.
Projects
None yet
1 participant