8000 Extract status code when returned as string by nhulston · Pull Request #642 · DataDog/datadog-lambda-js · GitHub
[go: up one dir, main page]

Skip to content

Extract status code when returned as string #642

10000
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
Mar 19, 2025

Conversation

nhulston
Copy link
Contributor

What does this PR do?

Handles case where the status code is a string instead of a number.
We extract this status code in extractHTTPStatusCodeTag()

Motivation

#641

Testing Guidelines

Manual+unit

Additional Notes

Types of Changes

  • Bug fix
  • New feature
  • Breaking change
  • Misc (docs, refactoring, dependency upgrade, etc.)

Check all that apply

  • This PR's description is comprehensive
  • This PR contains breaking changes that are documented in the description
  • This PR introduces new APIs or parameters that are documented and unlikely to change in the foreseeable future
  • This PR impacts documentation, and it has been updated (or a ticket has been logged)
  • This PR's changes are covered by the automated tests
  • This PR collects user input/sensitive content into Datadog
  • This PR passes the integration tests (ask a Datadog member to run the tests)

@nhulston nhulston marked this pull request as ready for review March 19, 2025 14:27
@nhulston nhulston requested a review from a team as a code owner March 19, 2025 14:27
@nhulston nhulston requested a review from astuyve March 19, 2025 14:38
< 10000 table class="diff-table tab-size js-diff-table" data-tab-size="8" data-paste-markdown-skip> @@ -396,6 +396,7 @@ export function extractHTTPStatusCodeTag( if (typeof resultStatusCode === "number") { return resultStatusCode.toString(); } return resultStatusCode.toString();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in this case it's already a string, so you can just return the status code itself.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's just always return resultStatusCode.toString(); if it exists

Comment on lines 396 to 398
if (typeof resultStatusCode === "number") {
return resultStatusCode.toString();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (typeof resultStatusCode === "number") {
return resultStatusCode.toString();
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove it as it doesn't do anything special for numbers

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yeah that's the simplest solution

Copy link
Contributor
@joeyzhao2018 joeyzhao2018 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nhulston nhulston merged commit e782bde into main Mar 19, 2025
25 checks passed
@nhulston nhulston deleted the nicholas.hulston/extract-string-http-status-codes branch March 19, 2025 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0