From 1b4770fb85ebef38a3409d80585cdefac073cce4 Mon Sep 17 00:00:00 2001
From: Joey Zhao <5253430+joeyzhao2018@users.noreply.github.com>
Date: Fri, 3 Nov 2023 15:29:23 -0400
Subject: [PATCH 01/10] expose DD_CAPTURE_LAMBDA_PAYLOAD_MAX_DEPTH
---
README.md | 15 ++++++++++++++
datadog_lambda/tag_object.py | 6 +++---
datadog_lambda/wrapper.py | 39 +++++++++++++++++++-----------------
tests/test_tag_object.py | 25 +++++++++++++++++++++++
4 files changed, 64 insertions(+), 21 deletions(-)
diff --git a/README.md b/README.md
index 757c929d..e1c5f4a0 100644
--- a/README.md
+++ b/README.md
@@ -16,6 +16,19 @@ Follow the [installation instructions](https://docs.datadoghq.com/serverless/ins
Follow the [configuration instructions](https://docs.datadoghq.com/serverless/configuration) to tag your telemetry, capture request/response payloads, filter or scrub sensitive information from logs or traces, and more.
+Besides the environment variables supported by dd-trace-py, the datadog-lambda-python library added following environment variables.
+
+| Environment Variables | Default ValueDescription |
+| -------------------- | ------------ |
+| DD_ENCODE_AUTHORIZER_CONTEXT | When set to `true` for Lambda authorizers, the tracing context will be encoded into the response for propagation. Supported for NodeJS and Python. Defaults to `true`. |
+| DD_DECODE_AUTHORIZER_CONTEXT | When set to `true` for Lambdas that are authorized via Lambda authorizers, it will parse and use the encoded tracing context (if found). Supportedoo for NodeJS and Python. Defaults to `true`. |
+| DD_COLD_START_TRACING | Set to `false` to disable Cold Start Tracing. Used in NodeJS and Python. Defaults to `true`. |
+| DD_MIN_COLD_START_DURATION | Sets the minimum duration (in milliseconds) for a module load event to be traced via Cold Start Tracing. Number. Defaults to `3`. |
+| DD_COLD_START_TRACE_SKIP_LIB | optionally skip creating Cold Start Spans for a comma-separated list of libraries. Useful to limit depth or skip known libraries. Default depends on runtime. |
+| DD_CAPTURE_LAMBDA_PAYLOAD | [Captures incoming and outgoing AWS Lambda payloads][1] in the Datadog APM spans for Lambda invocations. Defaults to `false`. |
+| DD_CAPTURE_LAMBDA_PAYLOAD_MAX_DEPTH | The captured AWS Lambda payloads will become tags of the `aws.lambda` span. This sets how deep it fathoms the JSON structure. When the max depth reached, the tag's value will be the stringified value of the deeper nested items. Defaults to `10`.
For example, with input payload as
{
"lv1" : {
"lv2": {
"lv3": "val"
}
}
}
When set to `2`, the resulted tag's key is `function.request.lv1.lv2` and value `{\"lv3\": \"val\"}`.
When set to `0`, the the resulted tag's key is just `function.request` and value is `{\"lv1\":{\"lv2\":{\"lv3\": \"val\"}}}` |
+
+
## Opening Issues
If you encounter a bug with this package, we want to hear about it. Before opening a new issue, search the existing issues to avoid duplicates.
@@ -51,3 +64,5 @@ For product feedback and questions, join the `#serverless` channel in the [Datad
Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2019 Datadog, Inc.
+
+[1]: https://www.datadoghq.com/blog/troubleshoot-lambda-function-request-response-payloads/
diff --git a/datadog_lambda/tag_object.py b/datadog_lambda/tag_object.py
index 151801f6..b898d83e 100644
--- a/datadog_lambda/tag_object.py
+++ b/datadog_lambda/tag_object.py
@@ -13,12 +13,12 @@
def tag_object(span, key, obj, depth=0):
+ if obj is None:
+ return span.set_tag(key, obj)
if depth >= max_depth:
- return
+ return tag_object(span, key, str(obj))
else:
depth += 1
- if obj is None:
- return span.set_tag(key, obj)
if _should_try_string(obj):
parsed = None
try:
diff --git a/datadog_lambda/wrapper.py b/datadog_lambda/wrapper.py
index f9675c68..64f19701 100644
--- a/datadog_lambda/wrapper.py
+++ b/datadog_lambda/wrapper.py
@@ -49,7 +49,6 @@
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:
@@ -57,10 +56,6 @@
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,27 @@
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 {env_key} as int. Using the 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
+ 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 +173,7 @@ 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 +312,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)
diff --git a/tests/test_tag_object.py b/tests/test_tag_object.py
index 8e5ac3aa..4eefd21e 100644
--- a/tests/test_tag_object.py
+++ b/tests/test_tag_object.py
@@ -30,6 +30,31 @@ def test_tag_object(self):
)
self.assertEqual(1, 1)
+ def test_tag_object_max_depth(self):
+ payload = {
+ "hello": "world",
+ "level1": {"level2_dict": {"level3": 3}, "level2_list": [None, True, "nice", {"l3" :"v3"}], "level2_bool": True, "level2_int": 2},
+ "vals": [{"thingOne": 1}, {"thingTwo": 2}],
+ }
+ spanMock = MagicMock()
+ import datadog_lambda.tag_object as lib_ref
+ lib_ref.max_depth = 2 # setting up the test
+ tag_object(spanMock, "function.request", payload)
+ lib_ref.max_depth = 10 # revert the setup
+ spanMock.set_tag.assert_has_calls(
+ [
+ call("function.request.vals.0", "{'thingOne': 1}"),
+ call("function.request.vals.1", "{'thingTwo': 2}"),
+ call("function.request.hello", "world"),
+ call("function.request.level1.level2_dict", "{'level3': 3}"),
+ call("function.request.level1.level2_list", "[None, True, 'nice', {'l3': 'v3'}]"),
+ call("function.request.level1.level2_bool", "True"),
+ call('function.request.level1.level2_int', "2")
+ ],
+ True,
+ )
+ self.assertEqual(1, 1)
+
def test_redacted_tag_object(self):
payload = {
"authorization": "world",
From aed76486e4b40822c9632550480db711db7c7a5d Mon Sep 17 00:00:00 2001
From: Joey Zhao <5253430+joeyzhao2018@users.noreply.github.com>
Date: Mon, 6 Nov 2023 10:43:48 -0500
Subject: [PATCH 02/10] format
---
datadog_lambda/wrapper.py | 17 +++++++++++++----
datadog_lambda/xray.py | 1 -
tests/test_tag_object.py | 19 ++++++++++++++-----
3 files changed, 27 insertions(+), 10 deletions(-)
diff --git a/datadog_lambda/wrapper.py b/datadog_lambda/wrapper.py
index 64f19701..522627dd 100644
--- a/datadog_lambda/wrapper.py
+++ b/datadog_lambda/wrapper.py
@@ -73,20 +73,27 @@
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 {env_key} as int. Using the default value: {default_value}. Error: {e}")
+ logger.warn(
+ f"Failed to parse env {env_key} as int. Using the 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
- tag_object.max_depth = get_env_as_int(DD_CAPTURE_LAMBDA_PAYLOAD_MAX_DEPTH, tag_object.max_depth)
+ import datadog_lambda.tag_object as tag_object
+
+ 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)
@@ -173,7 +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 = get_env_as_int(DD_MIN_COLD_START_DURATION, 3)
+ 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",
diff --git a/datadog_lambda/xray.py b/datadog_lambda/xray.py
index bbaecb2e..88d108f5 100644
--- a/datadog_lambda/xray.py
+++ b/datadog_lambda/xray.py
@@ -75,7 +75,6 @@ def generate_random_id():
def build_segment(context, key, metadata):
-
segment = json.dumps(
{
"id": generate_random_id(),
diff --git a/tests/test_tag_object.py b/tests/test_tag_object.py
index 4eefd21e..93faa3db 100644
--- a/tests/test_tag_object.py
+++ b/tests/test_tag_object.py
@@ -33,23 +33,32 @@ def test_tag_object(self):
def test_tag_object_max_depth(self):
payload = {
"hello": "world",
- "level1": {"level2_dict": {"level3": 3}, "level2_list": [None, True, "nice", {"l3" :"v3"}], "level2_bool": True, "level2_int": 2},
+ "level1": {
+ "level2_dict": {"level3": 3},
+ "level2_list": [None, True, "nice", {"l3": "v3"}],
+ "level2_bool": True,
+ "level2_int": 2,
+ },
"vals": [{"thingOne": 1}, {"thingTwo": 2}],
}
spanMock = MagicMock()
import datadog_lambda.tag_object as lib_ref
- lib_ref.max_depth = 2 # setting up the test
+
+ lib_ref.max_depth = 2 # setting up the test
tag_object(spanMock, "function.request", payload)
- lib_ref.max_depth = 10 # revert the setup
+ lib_ref.max_depth = 10 # revert the setup
spanMock.set_tag.assert_has_calls(
[
call("function.request.vals.0", "{'thingOne': 1}"),
call("function.request.vals.1", "{'thingTwo': 2}"),
call("function.request.hello", "world"),
call("function.request.level1.level2_dict", "{'level3': 3}"),
- call("function.request.level1.level2_list", "[None, True, 'nice', {'l3': 'v3'}]"),
+ call(
+ "function.request.level1.level2_list",
+ "[None, True, 'nice', {'l3': 'v3'}]",
+ ),
call("function.request.level1.level2_bool", "True"),
- call('function.request.level1.level2_int', "2")
+ call("function.request.level1.level2_int", "2"),
],
True,
)
From ac2a6366c42390346efd3494a11c16be138c4cc5 Mon Sep 17 00:00:00 2001
From: Joey Zhao <5253430+joeyzhao2018@users.noreply.github.com>
Date: Mon, 6 Nov 2023 13:54:10 -0500
Subject: [PATCH 03/10] normalize package patch version in tests
---
scripts/run_integration_tests.sh | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/scripts/run_integration_tests.sh b/scripts/run_integration_tests.sh
index beb91921..90382458 100755
--- a/scripts/run_integration_tests.sh
+++ b/scripts/run_integration_tests.sh
@@ -200,8 +200,8 @@ for handler_name in "${LAMBDA_HANDLERS[@]}"; do
sed -E "s/(api_key=|'api_key': '|DD-API-KEY:)[a-z0-9\.\-]+/\1XXXX/g" |
# Normalize package version so that these snapshots aren't broken on version bumps
sed -E "s/(dd_lambda_layer:datadog-python[0-9]+_)[0-9]+\.[0-9]+\.[0-9]+/\1X\.X\.X/g" |
- sed -E "s/(datadog_lambda:v)([0-9]+\.[0-9]+\.[0-9])/\1XX/g" |
- sed -E "s/(datadogpy\/)([0-9]+\.[0-9]+\.[0-9])/\1XX/g" |
+ sed -E "s/(datadog_lambda:v)([0-9]+\.[0-9]+\.[0-9]+)/\1XX/g" |
+ sed -E "s/(datadogpy\/)([0-9]+\.[0-9]+\.[0-9]+)/\1XX/g" |
sed -E "s/(python )([0-9]\.[0-9]+\.[0-9]+)/\1XX/g" |
# Strip out run ID (from function name, resource, etc.)
sed -E "s/${!run_id}/XXXX/g" |
@@ -231,10 +231,10 @@ for handler_name in "${LAMBDA_HANDLERS[@]}"; do
sed -E "s/(\"connection_id\"\:\ \")[a-zA-Z0-9\-]+/\1XXXX/g" |
sed -E "s/(\"shardId\-)([0-9]+)\:([a-zA-Z0-9]+)[a-zA-Z0-9]/\1XXXX:XXXX/g" |
sed -E "s/(\"shardId\-)[0-9a-zA-Z]+/\1XXXX/g" |
- sed -E "s/(\"datadog_lambda\"\: \")([0-9]+\.[0-9]+\.[0-9])/\1X.X.X/g" |
+ sed -E "s/(\"datadog_lambda\"\: \")([0-9]+\.[0-9]+\.[0-9]+)/\1X.X.X/g" |
sed -E "s/(\"partition_key\"\:\ \")[a-zA-Z0-9\-]+/\1XXXX/g" |
sed -E "s/(\"object_etag\"\:\ \")[a-zA-Z0-9\-]+/\1XXXX/g" |
- sed -E "s/(\"dd_trace\"\: \")([0-9]+\.[0-9]+\.[0-9])/\1X.X.X/g" |
+ sed -E "s/(\"dd_trace\"\: \")([0-9]+\.[0-9]+\.[0-9]+)/\1X.X.X/g" |
sed -E "s/(traceparent\:)([A-Za-z0-9\-]+)/\1XXX/g" |
# Parse out account ID in ARN
sed -E "s/([a-zA-Z0-9]+):([a-zA-Z0-9]+):([a-zA-Z0-9]+):([a-zA-Z0-9\-]+):([a-zA-Z0-9\-\:]+)/\1:\2:\3:\4:XXXX:\4/g" |
From 8db9654bc8a5c38fee294deda5d53db056375ed7 Mon Sep 17 00:00:00 2001
From: Joey Zhao <5253430+joeyzhao2018@users.noreply.github.com>
Date: Tue, 7 Nov 2023 10:22:41 -0500
Subject: [PATCH 04/10] format
---
datadog_lambda/wrapper.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/datadog_lambda/wrapper.py b/datadog_lambda/wrapper.py
index 522627dd..81118848 100644
--- a/datadog_lambda/wrapper.py
+++ b/datadog_lambda/wrapper.py
@@ -79,7 +79,7 @@ def get_env_as_int(env_key, default_value: int) -> int:
return int(os.environ.get(env_key, default_value))
except Exception as e:
logger.warn(
- f"Failed to parse env {env_key} as int. Using the default value: {default_value}. Error: {e}"
+ f"Failed to parse {env_key} as int. Using default value: {default_value}. Error: {e}"
)
return default_value
From f3130530b473f789db465421a70e999800e2af0e Mon Sep 17 00:00:00 2001
From: Joey Zhao <5253430+joeyzhao2018@users.noreply.github.com>
Date: Tue, 7 Nov 2023 13:17:58 -0500
Subject: [PATCH 05/10] remove else
---
datadog_lambda/tag_object.py | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/datadog_lambda/tag_object.py b/datadog_lambda/tag_object.py
index b898d83e..fa5a5029 100644
--- a/datadog_lambda/tag_object.py
+++ b/datadog_lambda/tag_object.py
@@ -17,8 +17,7 @@ def tag_object(span, key, obj, depth=0):
return span.set_tag(key, obj)
if depth >= max_depth:
return tag_object(span, key, str(obj))
- else:
- depth += 1
+ depth += 1
if _should_try_string(obj):
parsed = None
try:
From 5f69726ffdbfcb63e67570b656a2e05325512a40 Mon Sep 17 00:00:00 2001
From: Joey Zhao <5253430+joeyzhao2018@users.noreply.github.com>
Date: Tue, 7 Nov 2023 13:23:21 -0500
Subject: [PATCH 06/10] use _redact_val
---
datadog_lambda/tag_object.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/datadog_lambda/tag_object.py b/datadog_lambda/tag_object.py
index fa5a5029..b8e26934 100644
--- a/datadog_lambda/tag_object.py
+++ b/datadog_lambda/tag_object.py
@@ -16,7 +16,7 @@ def tag_object(span, key, obj, depth=0):
if obj is None:
return span.set_tag(key, obj)
if depth >= max_depth:
- return tag_object(span, key, str(obj))
+ return tag_object(span, key, _redact_val(key, str(obj)[0:5000]))
depth += 1
if _should_try_string(obj):
parsed = None
From a6fcac3d90fa1db46c24a2ae819208efaebae8d6 Mon Sep 17 00:00:00 2001
From: Joey Zhao <5253430+joeyzhao2018@users.noreply.github.com>
Date: Tue, 7 Nov 2023 13:27:49 -0500
Subject: [PATCH 07/10] readme update
---
README.md | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index e1c5f4a0..a9c432ae 100644
--- a/README.md
+++ b/README.md
@@ -16,12 +16,14 @@ Follow the [installation instructions](https://docs.datadoghq.com/serverless/ins
Follow the [configuration instructions](https://docs.datadoghq.com/serverless/configuration) to tag your telemetry, capture request/response payloads, filter or scrub sensitive information from logs or traces, and more.
+For additional tracing configuration options, check out the [official documentation for Datadog trace client](https://ddtrace.readthedocs.io/en/stable/configuration.html).
+
Besides the environment variables supported by dd-trace-py, the datadog-lambda-python library added following environment variables.
| Environment Variables | Default ValueDescription |
| -------------------- | ------------ |
| DD_ENCODE_AUTHORIZER_CONTEXT | When set to `true` for Lambda authorizers, the tracing context will be encoded into the response for propagation. Supported for NodeJS and Python. Defaults to `true`. |
-| DD_DECODE_AUTHORIZER_CONTEXT | When set to `true` for Lambdas that are authorized via Lambda authorizers, it will parse and use the encoded tracing context (if found). Supportedoo for NodeJS and Python. Defaults to `true`. |
+| DD_DECODE_AUTHORIZER_CONTEXT | When set to `true` for Lambdas that are authorized via Lambda authorizers, it will parse and use the encoded tracing context (if found). Supported for NodeJS and Python. Defaults to `true`. |
| DD_COLD_START_TRACING | Set to `false` to disable Cold Start Tracing. Used in NodeJS and Python. Defaults to `true`. |
| DD_MIN_COLD_START_DURATION | Sets the minimum duration (in milliseconds) for a module load event to be traced via Cold Start Tracing. Number. Defaults to `3`. |
| DD_COLD_START_TRACE_SKIP_LIB | optionally skip creating Cold Start Spans for a comma-separated list of libraries. Useful to limit depth or skip known libraries. Default depends on runtime. |
From f119517bcdf20e7131f8487a0e48d5ae963e1ea4 Mon Sep 17 00:00:00 2001
From: Joey Zhao <5253430+joeyzhao2018@users.noreply.github.com>
Date: Thu, 9 Nov 2023 14:14:29 -0500
Subject: [PATCH 08/10] small fixes
---
tests/test_tag_object.py | 2 --
1 file changed, 2 deletions(-)
diff --git a/tests/test_tag_object.py b/tests/test_tag_object.py
index 93faa3db..eac84f7c 100644
--- a/tests/test_tag_object.py
+++ b/tests/test_tag_object.py
@@ -28,7 +28,6 @@ def test_tag_object(self):
],
True,
)
- self.assertEqual(1, 1)
def test_tag_object_max_depth(self):
payload = {
@@ -62,7 +61,6 @@ def test_tag_object_max_depth(self):
],
True,
)
- self.assertEqual(1, 1)
def test_redacted_tag_object(self):
payload = {
From 14dff707731197df23846b774a7e457638df8d98 Mon Sep 17 00:00:00 2001
From: Joey Zhao <5253430+joeyzhao2018@users.noreply.github.com>
Date: Thu, 9 Nov 2023 16:24:44 -0500
Subject: [PATCH 09/10] Update README.md
Co-authored-by: Brett Blue <84536271+brett0000FF@users.noreply.github.com>
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index a9c432ae..ab8c14d4 100644
--- a/README.md
+++ b/README.md
@@ -28,7 +28,7 @@ Besides the environment variables supported by dd-trace-py, the datadog-lambda-p
| DD_MIN_COLD_START_DURATION | Sets the minimum duration (in milliseconds) for a module load event to be traced via Cold Start Tracing. Number. Defaults to `3`. |
| DD_COLD_START_TRACE_SKIP_LIB | optionally skip creating Cold Start Spans for a comma-separated list of libraries. Useful to limit depth or skip known libraries. Default depends on runtime. |
| DD_CAPTURE_LAMBDA_PAYLOAD | [Captures incoming and outgoing AWS Lambda payloads][1] in the Datadog APM spans for Lambda invocations. Defaults to `false`. |
-| DD_CAPTURE_LAMBDA_PAYLOAD_MAX_DEPTH | The captured AWS Lambda payloads will become tags of the `aws.lambda` span. This sets how deep it fathoms the JSON structure. When the max depth reached, the tag's value will be the stringified value of the deeper nested items. Defaults to `10`.
For example, with input payload as {
"lv1" : {
"lv2": {
"lv3": "val"
}
}
}
When set to `2`, the resulted tag's key is `function.request.lv1.lv2` and value `{\"lv3\": \"val\"}`.
When set to `0`, the the resulted tag's key is just `function.request` and value is `{\"lv1\":{\"lv2\":{\"lv3\": \"val\"}}}` |
+| DD_CAPTURE_LAMBDA_PAYLOAD_MAX_DEPTH | Determines the level of detail captured from AWS Lambda payloads, which are then assigned as tags for the `aws.lambda` span. It specifies the nesting depth of the JSON payload structure to process. Once the specified maximum depth is reached, the tag's value is set to the stringified value of any nested elements beyond this level. The default is `10`.
For example, given the input payload: {
"lv1" : {
"lv2": {
"lv3": "val"
}
}
}
If the depth is set to `2`, the resulting tag's key is set to `function.request.lv1.lv2` and the value is `{\"lv3\": \"val\"}`.
If the depth is set to `0`, the resulting tag's key is set to `function.request` and value is `{\"lv1\":{\"lv2\":{\"lv3\": \"val\"}}}` |
## Opening Issues
From 513b6e705e5105c4e52fe3bbc50ee2d94318a129 Mon Sep 17 00:00:00 2001
From: Joey Zhao <5253430+joeyzhao2018@users.noreply.github.com>
Date: Thu, 9 Nov 2023 16:33:14 -0500
Subject: [PATCH 10/10] improve readme.md
---
README.md | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/README.md b/README.md
index ab8c14d4..e3702b1b 100644
--- a/README.md
+++ b/README.md
@@ -20,15 +20,15 @@ For additional tracing configuration options, check out the [official documentat
Besides the environment variables supported by dd-trace-py, the datadog-lambda-python library added following environment variables.
-| Environment Variables | Default ValueDescription |
-| -------------------- | ------------ |
-| DD_ENCODE_AUTHORIZER_CONTEXT | When set to `true` for Lambda authorizers, the tracing context will be encoded into the response for propagation. Supported for NodeJS and Python. Defaults to `true`. |
-| DD_DECODE_AUTHORIZER_CONTEXT | When set to `true` for Lambdas that are authorized via Lambda authorizers, it will parse and use the encoded tracing context (if found). Supported for NodeJS and Python. Defaults to `true`. |
-| DD_COLD_START_TRACING | Set to `false` to disable Cold Start Tracing. Used in NodeJS and Python. Defaults to `true`. |
-| DD_MIN_COLD_START_DURATION | Sets the minimum duration (in milliseconds) for a module load event to be traced via Cold Start Tracing. Number. Defaults to `3`. |
-| DD_COLD_START_TRACE_SKIP_LIB | optionally skip creating Cold Start Spans for a comma-separated list of libraries. Useful to limit depth or skip known libraries. Default depends on runtime. |
-| DD_CAPTURE_LAMBDA_PAYLOAD | [Captures incoming and outgoing AWS Lambda payloads][1] in the Datadog APM spans for Lambda invocations. Defaults to `false`. |
-| DD_CAPTURE_LAMBDA_PAYLOAD_MAX_DEPTH | Determines the level of detail captured from AWS Lambda payloads, which are then assigned as tags for the `aws.lambda` span. It specifies the nesting depth of the JSON payload structure to process. Once the specified maximum depth is reached, the tag's value is set to the stringified value of any nested elements beyond this level. The default is `10`.
For example, given the input payload: {
"lv1" : {
"lv2": {
"lv3": "val"
}
}
}
If the depth is set to `2`, the resulting tag's key is set to `function.request.lv1.lv2` and the value is `{\"lv3\": \"val\"}`.
If the depth is set to `0`, the resulting tag's key is set to `function.request` and value is `{\"lv1\":{\"lv2\":{\"lv3\": \"val\"}}}` |
+| Environment Variables | Description | Default Value |
+| -------------------- | ------------ | ------------- |
+| DD_ENCODE_AUTHORIZER_CONTEXT | When set to `true` for Lambda authorizers, the tracing context will be encoded into the response for propagation. Supported for NodeJS and Python. | `true` |
+| DD_DECODE_AUTHORIZER_CONTEXT | When set to `true` for Lambdas that are authorized via Lambda authorizers, it will parse and use the encoded tracing context (if found). Supported for NodeJS and Python. | `true` |
+| DD_COLD_START_TRACING | Set to `false` to disable Cold Start Tracing. Used in NodeJS and Python. | `true` |
+| DD_MIN_COLD_START_DURATION | Sets the minimum duration (in milliseconds) for a module load event to be traced via Cold Start Tracing. Number. | `3` |
+| DD_COLD_START_TRACE_SKIP_LIB | optionally skip creating Cold Start Spans for a comma-separated list of libraries. Useful to limit depth or skip known libraries. | `ddtrace.internal.compat,ddtrace.filters` |
+| DD_CAPTURE_LAMBDA_PAYLOAD | [Captures incoming and outgoing AWS Lambda payloads][1] in the Datadog APM spans for Lambda invocations. | `false` |
+| DD_CAPTURE_LAMBDA_PAYLOAD_MAX_DEPTH | Determines the level of detail captured from AWS Lambda payloads, which are then assigned as tags for the `aws.lambda` span. It specifies the nesting depth of the JSON payload structure to process. Once the specified maximum depth is reached, the tag's value is set to the stringified value of any nested elements beyond this level.
For example, given the input payload: {
"lv1" : {
"lv2": {
"lv3": "val"
}
}
}
If the depth is set to `2`, the resulting tag's key is set to `function.request.lv1.lv2` and the value is `{\"lv3\": \"val\"}`.
If the depth is set to `0`, the resulting tag's key is set to `function.request` and value is `{\"lv1\":{\"lv2\":{\"lv3\": \"val\"}}}` | `10` |
## Opening Issues