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

Change context missing strategy behaviour to Log Error #83

Merged
merged 3 commits into from
Jan 20, 2023

Conversation

jj22ee
Copy link
Contributor

@jj22ee jj22ee commented Jan 18, 2023

Issue #, if available:

Description of changes:
This change sets the default context missing strategy to 'LOG_ERROR' instead of 'RUNTIME_ERROR' to mitigate malformed trace headers from breaking services.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@jj22ee jj22ee requested a review from a team as a code owner January 18, 2023 21:31
@@ -20,14 +20,15 @@ def test_change_context_missing
context = XRay::DefaultContext.new
context.clear!
context.context_missing = 'UNKWON'
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: is this a typo?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is, but I cannot tell if it is deliberate. The purpose of this line is to set a random invalid context_missing value, so this typo could either be on purpose or not. Setting it to 'UNKNOWN' will yield the same result.

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense. If they both yield the same result, maybe it would be better to just correct the typo for readability? What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to 'INVALID_STRATEGY'

@@ -36,7 +37,6 @@ def test_runtime_error
def test_log_error
context = XRay::DefaultContext.new
context.clear!
context.context_missing = 'LOG_ERROR'
Copy link
Contributor

@carolabadeer carolabadeer Jan 18, 2023

Choose a reason for hiding this comment

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

Since this test is called test_log_error, perhaps adding an assertion that context.context_missing is LOG_ERROR by default would also make sense

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. Originally test_runtime_error assumed the default value, so I thought to test test_log_error assuming the default value as well with the new change. I think it makes sense to incorporate your suggestion, and then add a test_default_context_missing test case.

def test_default_context_missing
context = XRay::DefaultContext.new
context.clear!
refute context.current_entity

Choose a reason for hiding this comment

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

Is there an easy way to see if a log was added here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good callout. The XRay Ruby SDKs don't test the output of the logger anywhere else unfortunately, it won't be a quick change. This can be tackled in another enhancement.

Choose a reason for hiding this comment

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

Sounds good. Feel free to merge this then.

@jj22ee jj22ee merged commit 2e2e2ef into aws:master Jan 20, 2023
@jj22ee jj22ee deleted the change-default-strat branch January 20, 2023 01:11
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