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

Redriven Step Functions Trace Merging #545

Merged
merged 8 commits into from
Jan 2, 2025
Merged

Conversation

avedmala
Copy link
Contributor

@avedmala avedmala commented Dec 4, 2024

What does this PR do?

Adds support for Step Functions trace merging in Redrive cases

We previously used hash(ExecutionId # StateName # StateEnteredTime) for spanID calculation but these values are identical across redrives for a Lambda task state. The new approach also adds a RedriveCount to the end of the hash but omits this value when it is 0 to have easy backwards compatability.

Motivation

https://github.com/DataDog/logs-backend/pull/84188

Testing Guidelines

Redriven Trace with Lambda and Trace Merging
Screenshot 2024-12-16 at 12 00 25 PM

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)

@avedmala avedmala changed the title use redrive count to generate step functions parent ID Redriven Step Functions Trace Merging Dec 16, 2024
sfn_event = {
"Execution": {
"Id": "arn:aws:states:sa-east-1:425362996713:execution:abhinav-activity-state-machine:72a7ca3e-901c-41bb-b5a3-5f279b92a316",
"Name": "72a7ca3e-901c-41bb-b5a3-5f279b92a316",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated these cases to match the logs-backend and also the node tests added in DataDog/datadog-lambda-js#598

@avedmala avedmala marked this pull request as ready for review December 17, 2024 15:58
@avedmala avedmala requested a review from a team as a code owner December 17, 2024 15:58
state_name = context.get("State").get("Name")
state_entered_time = context.get("State").get("EnteredTime")

redrive_postfix = "" if redrive_count == 0 else f"#{redrive_count}"

Choose a reason for hiding this comment

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

Is it possible that redrive _count is null?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Execution.RedriveCount will always be in the SFNs context object, defaulting to 0

Only Execution.RedriveTime has a risk of being missing, only appearing when redrive count is 1 or more

https://docs.aws.amazon.com/step-functions/latest/dg/input-output-contextobject.html

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Even though this is supposed to be true, I found some instances in customer logs where RedriveCount is null. Wasn't able to reproduce it myself. I'll add some null-check here and also for the node layer change accordingly

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess we'll need to assume all the new fields could be null in the future. There may be some edge cases that AWS does not handle well.

Copy link
Contributor

@kimi-p kimi-p left a comment

Choose a reason for hiding this comment

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

lgtm

@avedmala avedmala merged commit b6edd91 into main Jan 2, 2025
50 checks passed
@avedmala avedmala deleted the avedmala/sfn-redrive-merging branch January 2, 2025 20:47
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