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

Prevent error when attempting to use None context. #541

Merged
merged 1 commit into from
Nov 21, 2024

Conversation

purple4reina
Copy link
Contributor

What does this PR do?

When the dd trace context is None, don't continue trying to use it.

Motivation

Self monitoring hit this error:

Screenshot 2024-11-21 at 9 05 39 AM

Testing Guidelines

Additional Notes

I suspect there are more places in here that need to be addressed.

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)

@purple4reina purple4reina requested a review from a team as a code owner November 21, 2024 17:08
@purple4reina purple4reina force-pushed the rey.abolofia/none-context branch from d5548e3 to 20e281e Compare November 21, 2024 17:47
datadog_lambda/tracing.py Show resolved Hide resolved
@@ -991,6 +994,10 @@ def test_set_dd_trace_py_root_no_span_id(self):
self.mock_activate.assert_called()
self.mock_activate.assert_has_calls([call(expected_context)])

def test_set_dd_trace_py_root_none_context(self):
set_dd_trace_py_root(TraceContextSource.EVENT, True)
self.mock_activate.assert_not_called()
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: this seems a to be a bit spookily-long-distance

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I don't understand. The most important thing about this test is that it just doesn't raise an exception, which is what would happen before.

Copy link
Contributor

Choose a reason for hiding this comment

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

ah, i see! could we add a check that confirms that it is in fact none? or something?

@purple4reina purple4reina merged commit 6b67412 into main Nov 21, 2024
34 of 36 checks passed
@purple4reina purple4reina deleted the rey.abolofia/none-context branch November 21, 2024 20:06
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.

2 participants