-
Notifications
You must be signed in to change notification settings - Fork 45
expose DD_CAPTURE_LAMBDA_PAYLOAD_MAX_DEPTH [SVLS-3853] #387
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
Merged
+87
−28
Merged
Changes from 7 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
1b4770f
expose DD_CAPTURE_LAMBDA_PAYLOAD_MAX_DEPTH
joeyzhao2018 aed7648
format
joeyzhao2018 ac2a636
normalize package patch version in tests
joeyzhao2018 8db9654
format
joeyzhao2018 f313053
remove else
joeyzhao2018 5f69726
use _redact_val
joeyzhao2018 a6fcac3
readme update
joeyzhao2018 f119517
small fixes
joeyzhao2018 14dff70
Update README.md
joeyzhao2018 513b6e7
improve readme.md
joeyzhao2018 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,18 +49,13 @@ | |
extract_trigger_tags, | ||
extract_http_status_code_tag, | ||
) | ||
from datadog_lambda.tag_object import tag_object | ||
|
||
profiling_env_var = os.environ.get("DD_PROFILING_ENABLED", "false").lower() == "true" | ||
if profiling_env_var: | ||
from ddtrace.profiling import profiler | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
dd_capture_lambda_payload_enabled = ( | ||
os.environ.get("DD_CAPTURE_LAMBDA_PAYLOAD", "false").lower() == "true" | ||
) | ||
|
||
DD_FLUSH_TO_LOG = "DD_FLUSH_TO_LOG" | ||
DD_LOGS_INJECTION = "DD_LOGS_INJECTION" | ||
DD_MERGE_XRAY_TRACES = "DD_MERGE_XRAY_TRACES" | ||
|
@@ -72,10 +67,34 @@ | |
DD_COLD_START_TRACING = "DD_COLD_START_TRACING" | ||
DD_MIN_COLD_START_DURATION = "DD_MIN_COLD_START_DURATION" | ||
DD_COLD_START_TRACE_SKIP_LIB = "DD_COLD_START_TRACE_SKIP_LIB" | ||
DD_CAPTURE_LAMBDA_PAYLOAD = "DD_CAPTURE_LAMBDA_PAYLOAD" | ||
DD_CAPTURE_LAMBDA_PAYLOAD_MAX_DEPTH = "DD_CAPTURE_LAMBDA_PAYLOAD_MAX_DEPTH" | ||
DD_REQUESTS_SERVICE_NAME = "DD_REQUESTS_SERVICE_NAME" | ||
DD_SERVICE = "DD_SERVICE" | ||
DD_ENV = "DD_ENV" | ||
|
||
|
||
def get_env_as_int(env_key, default_value: int) -> int: | ||
try: | ||
return int(os.environ.get(env_key, default_value)) | ||
except Exception as e: | ||
logger.warn( | ||
f"Failed to parse {env_key} as int. Using default value: {default_value}. Error: {e}" | ||
) | ||
return default_value | ||
|
||
|
||
dd_capture_lambda_payload_enabled = ( | ||
os.environ.get(DD_CAPTURE_LAMBDA_PAYLOAD, "false").lower() == "true" | ||
) | ||
|
||
if dd_capture_lambda_payload_enabled: | ||
import datadog_lambda.tag_object as tag_object | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice lazy loading!! |
||
|
||
tag_object.max_depth = get_env_as_int( | ||
DD_CAPTURE_LAMBDA_PAYLOAD_MAX_DEPTH, tag_object.max_depth | ||
) | ||
|
||
env_env_var = os.environ.get(DD_ENV, None) | ||
|
||
init_timestamp_ns = time_ns() | ||
|
@@ -161,14 +180,9 @@ def __init__(self, func): | |
self.cold_start_tracing = depends_on_dd_tracing_enabled( | ||
os.environ.get(DD_COLD_START_TRACING, "true").lower() == "true" | ||
) | ||
self.min_cold_start_trace_duration = 3 | ||
if DD_MIN_COLD_START_DURATION in os.environ: | ||
try: | ||
self.min_cold_start_trace_duration = int( | ||
os.environ[DD_MIN_COLD_START_DURATION] | ||
) | ||
except Exception: | ||
logger.debug(f"Malformatted env {DD_MIN_COLD_START_DURATION}") | ||
self.min_cold_start_trace_duration = get_env_as_int( | ||
DD_MIN_COLD_START_DURATION, 3 | ||
) | ||
self.cold_start_trace_skip_lib = [ | ||
"ddtrace.internal.compat", | ||
"ddtrace.filters", | ||
|
@@ -307,16 +321,14 @@ def _after(self, event, context): | |
create_dd_dummy_metadata_subsegment( | ||
self.trigger_tags, XraySubsegment.LAMBDA_FUNCTION_TAGS_KEY | ||
) | ||
should_trace_cold_start = ( | ||
dd_tracing_enabled and self.cold_start_tracing and is_new_sandbox() | ||
) | ||
should_trace_cold_start = self.cold_start_tracing and is_new_sandbox() | ||
if should_trace_cold_start: | ||
trace_ctx = tracer.current_trace_context() | ||
|
||
if self.span: | ||
if dd_capture_lambda_payload_enabled: | ||
tag_object(self.span, "function.request", event) | ||
tag_object(self.span, "function.response", self.response) | ||
tag_object.tag_object(self.span, "function.request", event) | ||
tag_object.tag_object(self.span, "function.response", self.response) | ||
|
||
if status_code: | ||
self.span.set_tag("http.status_code", status_code) | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Need some help from docs team to improve the wording.
