8000 refactor: remove tracer dependencies to support dsm sqs -> lambda by michael-zhao459 · Pull Request #612 · DataDog/datadog-lambda-python · GitHub
[go: up one dir, main page]

Skip to content

re 8000 factor: remove tracer dependencies to support dsm sqs -> lambda #612

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

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

michael-zhao459
Copy link
Collaborator
@michael-zhao459 michael-zhao459 commented Jun 9, 2025

What does this PR do?

Removes dependencies on internal tracer code. The get_dsm_context() is moved inside the lambda layer, and the public facing api for setting checkpoints is used instead of internal implementation code in the tracer.

Motivation

Helps decouple the lambda layer code from the tracer code, keeps with bests practice of not using internal implementation code.

Testing Guidelines

Function was properly unit tested

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)

Copy link
Collaborator Author
michael-zhao459 commented Jun 9, 2025

@michael-zhao459 michael-zhao459 marked this pull request as ready for review June 9, 2025 18:51
@michael-zhao459 michael-zhao459 requested review from a team as code owners June 9, 2025 18:51
@michael-zhao459 michael-zhao459 changed the title move get dsm context logic into lambda layer code feat: move get dsm context logic into lambda layer code Jun 9, 2025
< 8000 /span>
@michael-zhao459 michael-zhao459 marked this pull request as draft June 11, 2025 13:57
@michael-zhao459 michael-zhao459 changed the title feat: move get dsm context logic into lambda layer code refactor: remove tracer dependencies to support dsm lambda -> sqs Jun 11, 2025
@michael-zhao459 michael-zhao459 changed the title refactor: remove tracer dependencies to support dsm lambda -> sqs refactor: remove tracer dependencies to support dsm sqs -> lambda Jun 11, 2025
)
except Exception as e:
logger.error(format_err_with_traceback(e))
arn = record.get("eventSourceARN", "")

Choose a reason for hiding this comment

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

we remove the try / except here. Is there a reason for that (maybe there is and I don't see it).
But we want to make sure our instrumentation never prevents the lambda from being executed, even if there is an issue with the instrumentation.

context_json = _get_dsm_context_from_lambda(record)
if not context_json:
logger.debug("DataStreams skipped lambda message: %r", record)
return None

Choose a reason for hiding this comment

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

just return is enough

return None

carrier_get = _create_carrier_get(context_json)
set_consume_checkpoint("sqs", arn, carrier_get)

Choose a reason for hiding this comment

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

(Let's make sure we update the set manual_checkpoint=False here once the other PR is merged & the tracer released.

Copy link
Collaborator Author
@michael-zhao459 michael-zhao459 Jun 11, 2025

Choose a reason for hiding this comment

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

Plan on keeping this PR in draft until tracer released, and will make sure to update

- message.messageAttributes._datadog.stringValue (SQS -> lambda)
"""
context_json = None
message_attributes = message.get("messageAttributes")

Choose a reason for hiding this comment

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

is it possible for the message attributes to be in the message body (for the sns --> sqs case for example)? Is that maybe in a separate PR?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This will be in separate PR. I am trying to keep this one solely based on fixing the sqs logic

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