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

Check for the new direct invocation trace format and use that #146

Merged

Conversation

agocs
Copy link
Contributor

@agocs agocs commented Jun 16, 2021

What does this PR do?

Updates datadog-lambda-python so it can extract trace contexts stored in context.client_context.custom using the new propagation format, described in this doc: https://docs.google.com/document/d/1pruSeesAr2bAVMtz_rUlsiBZKFoFWdB4nSq5Vuym2l8/edit#heading=h.ptr8uhqw5ht

Motivation

Storing a map containing trace context in context.client_context.custom._datadog causes compatibility issues with Go and Java lambda functions. C.f. aws/aws-lambda-java-libs#212. We're updating the trace propagation format to fix this issue.

Testing Guidelines

  • Added a unit test

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)

@agocs agocs requested a review from a team as a code owner June 16, 2021 15:43
Copy link
Contributor

@DarcyRaynerDD DarcyRaynerDD left a comment

Choose a reason for hiding this comment

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

LGTM, left a nit


trace_id = None # type: Optional[str]
parent_id = None # type: Optional[str]
sampling_priority = None # type: Optional[str]
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the "str" type is a bit complicated, because it should be 'unicode' in python 2.7, and 'str' in 3+. It seems like the correct type would be 'Text' https://mypy.readthedocs.io/en/stable/cheat_sheet.html#built-in-types

Not sure it's worth introducing type hinting in this PR. I think it would make sense to start at the same time we drop 2.7 support, so we can use the more convenient 3+ syntax

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes sense. My instinct is to scatter type hints in as many places as possible, but it's probably better to wait until the 2 -> 3 conversion.

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.

None yet

2 participants