-
Notifications
You must be signed in to change notification settings - Fork 388
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
Enable step function tracing at forwarder level #831
Conversation
@@ -32,6 +33,12 @@ def enrich(events, cache_layer): | |||
extract_host_from_guardduty(event) | |||
extract_host_from_route53(event) | |||
|
|||
# Set tracing behavior for all step functions | |||
if DD_STEP_FUNCTION_TRACE_ENABLED: | |||
event[DD_CUSTOM_TAGS] = ",".join( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Null check for event[DD_CUSTOM_TAGS]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will be moving this logic as per Kimi's comment and adding a null check on the entry
SetDdStepFunctionTraceEnabled: | ||
Fn::Equals: | ||
- Ref: DdStepFunctionTraceEnabled | ||
- true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The console will use the default value in Parameters:
section, so in this case it would be false
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be the default behavior, here is the flow
- Template has the default for the
DdStepFunctionTraceEnabled
to befalse
SetDdStepFunctionTraceEnabled
condition will then befalse
becauseDdStepFunctionTraceEnabled != true
DD_STEP_FUNCTION_TRACE_ENABLED
will beAWS::NoValue
, which means the env var won't be set
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry that I forgot to share the original PR with you before. Could you also add a test like this test from the previous PR?
if DD_STEP_FUNCTION_TRACE_ENABLED: | ||
event[DD_CUSTOM_TAGS] = ",".join( | ||
[event[DD_CUSTOM_TAGS]] + ["dd_step_function_trace_enabled:true"] | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should to add the step functions specific logic to handle_step_function_source()
.
datadog-serverless-functions/aws/logs_monitoring/steps/handlers/awslogs_handler.py
Line 161 in 93c2281
def handle_step_function_source(self): |
We'd also want to do the empty value (e.g. ""
) check like this one:
datadog-serverless-functions/aws/logs_monitoring/steps/handlers/awslogs_handler.py
Line 181 in 93c2281
if not self.metadata[DD_CUSTOM_TAGS] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved the logic to the handle_step_function_source()
but I used a slightly different approach with the join so I don't think need the empty check
SetDdStepFunctionTraceEnabled: | ||
Fn::Equals: | ||
- Ref: DdStepFunctionTraceEnabled | ||
- true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The console will use the default value in Parameters:
section, so in this case it would be false
.
@@ -184,6 +185,12 @@ def handle_step_function_source(self): | |||
+ ",".join(formatted_stepfunctions_tags) | |||
) | |||
|
|||
if DD_STEP_FUNCTION_TRACE_ENABLED: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
LGTM. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What does this PR do?
This PR adds logic to allow users to enable tracing for all their Step Functions via the
dd_step_function_trace_enabled
tagThis tag can be set via the
DdStepFunctionTraceEnabled
CloudFormation parameter which is used to set theDD_STEP_FUNCTION_TRACE_ENABLED
env varLink to log with the new tag and screenshot of the tag
Motivation
Testing Guidelines
Additional Notes
Types of changes
Check all that apply