Skip to content

Commit 4b95397

Browse files
committed
Black.
1 parent be3f5ec commit 4b95397

3 files changed

Lines changed: 49 additions & 27 deletions

File tree

datadog_lambda/config.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,15 @@ class Config:
4949
service = _get_env("DD_SERVICE")
5050
env = _get_env("DD_ENV")
5151

52-
cold_start_tracing = _get_env("DD_COLD_START_TRACING", "true", as_bool, depends_on_tracing=True)
52+
cold_start_tracing = _get_env(
53+
"DD_COLD_START_TRACING", "true", as_bool, depends_on_tracing=True
54+
)
5355
min_cold_start_trace_duration = _get_env("DD_MIN_COLD_START_DURATION", 3, int)
5456
cold_start_trace_skip_lib = _get_env(
55-
"DD_COLD_START_TRACE_SKIP_LIB", "ddtrace.internal.compat,ddtrace.filters",
56-
as_list)
57+
"DD_COLD_START_TRACE_SKIP_LIB",
58+
"ddtrace.internal.compat,ddtrace.filters",
59+
as_list,
60+
)
5761

5862
capture_payload_max_depth = _get_env("DD_CAPTURE_LAMBDA_PAYLOAD_MAX_DEPTH", 10, int)
5963
capture_payload_enabled = _get_env("DD_CAPTURE_LAMBDA_PAYLOAD", "false", as_bool)
@@ -78,12 +82,15 @@ class Config:
7882
llmobs_enabled = _get_env("DD_LLMOBS_ENABLED", "false", as_bool)
7983
exception_replay_enabled = _get_env("DD_EXCEPTION_REPLAY_ENABLED", "false", as_bool)
8084

81-
make_inferred_span = _get_env("DD_TRACE_MANAGED_SERVICES", "true", as_bool,
82-
depends_on_tracing=True)
83-
encode_authorizer_context = _get_env("DD_ENCODE_AUTHORIZER_CONTEXT", "true", as_bool,
84-
depends_on_tracing=True)
85-
decode_authorizer_context = _get_env("DD_DECODE_AUTHORIZER_CONTEXT", "true", as_bool,
86-
depends_on_tracing=True)
85+
make_inferred_span = _get_env(
86+
"DD_TRACE_MANAGED_SERVICES", "true", as_bool, depends_on_tracing=True
87+
)
88+
encode_authorizer_context = _get_env(
89+
"DD_ENCODE_AUTHORIZER_CONTEXT", "true", as_bool, depends_on_tracing=True
90+
)
91+
decode_authorizer_context = _get_env(
92+
"DD_DECODE_AUTHORIZER_CONTEXT", "true", as_bool, depends_on_tracing=True
93+
)
8794

8895
local_test = _get_env("DD_LOCAL_TEST", "false", as_bool)
8996

datadog_lambda/wrapper.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,9 @@ def _after(self, event, context):
322322
if config.llmobs_enabled:
323323
LLMObs.flush()
324324

325-
if config.encode_authorizer_context and is_authorizer_response(self.response):
325+
if config.encode_authorizer_context and is_authorizer_response(
326+
self.response
327+
):
326328
self._inject_authorizer_span_headers(
327329
event.get("requestContext", {}).get("requestId")
328330
)

tests/test_config.py

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def _test_as_bool(env_key, conf_key, default):
2727
(env_key, conf_key, "purple", False),
2828
)
2929

30+
3031
def _test_int(env_key, conf_key, default):
3132
return (
3233
(env_key, conf_key, None, default),
@@ -38,6 +39,7 @@ def _test_int(env_key, conf_key, default):
3839
(env_key, conf_key, "purple", default),
3940
)
4041

42+
4143
def _test_as_list(env_key, conf_key, default):
4244
return (
4345
(env_key, conf_key, None, default.split(",")),
@@ -63,40 +65,46 @@ def _test_as_list(env_key, conf_key, default):
6365
*_test_as_bool("DD_INTEGRATION_TEST", "is_in_tests", default=False),
6466
*_test_as_bool("DD_BOTOCORE_ADD_SPAN_POINTERS", "add_span_pointers", default=True),
6567
*_test_as_bool("DD_TRACE_OTEL_ENABLED", "otel_enabled", default=False),
66-
*_test_as_bool("DD_INSTRUMENTATION_TELEMETRY_ENABLED", "telemetry_enabled", default=False),
68+
*_test_as_bool(
69+
"DD_INSTRUMENTATION_TELEMETRY_ENABLED", "telemetry_enabled", default=False
70+
),
6771
*_test_as_bool("DD_MERGE_XRAY_TRACES", "merge_xray_traces", default=False),
6872
*_test_as_bool("DD_PROFILING_ENABLED", "profiling_enabled", default=False),
6973
*_test_as_bool("DD_LLMOBS_ENABLED", "llmobs_enabled", default=False),
70-
*_test_as_bool("DD_EXCEPTION_REPLAY_ENABLED", "exception_replay_enabled", default=False),
71-
*_test_as_bool("DD_CAPTURE_LAMBDA_PAYLOAD", "capture_payload_enabled", default=False),
74+
*_test_as_bool(
75+
"DD_EXCEPTION_REPLAY_ENABLED", "exception_replay_enabled", default=False
76+
),
77+
*_test_as_bool(
78+
"DD_CAPTURE_LAMBDA_PAYLOAD", "capture_payload_enabled", default=False
79+
),
7280
*_test_as_bool("DD_LOCAL_TEST", "local_test", default=False),
73-
74-
*_test_int("DD_CAPTURE_LAMBDA_PAYLOAD_MAX_DEPTH", "capture_payload_max_depth", default=10),
75-
*_test_int("DD_MIN_COLD_START_DURATION", "min_cold_start_trace_duration", default=3),
76-
77-
*_test_as_list("DD_COLD_START_TRACE_SKIP_LIB", "cold_start_trace_skip_lib", default="ddtrace.internal.compat,ddtrace.filters"),
78-
81+
*_test_int(
82+
"DD_CAPTURE_LAMBDA_PAYLOAD_MAX_DEPTH", "capture_payload_max_depth", default=10
83+
),
84+
*_test_int(
85+
"DD_MIN_COLD_START_DURATION", "min_cold_start_trace_duration", default=3
86+
),
87+
*_test_as_list(
88+
"DD_COLD_START_TRACE_SKIP_LIB",
89+
"cold_start_trace_skip_lib",
90+
default="ddtrace.internal.compat,ddtrace.filters",
91+
),
7992
("DD_SERVICE", "service", None, None),
8093
("DD_SERVICE", "service", "", ""),
8194
("DD_SERVICE", "service", "my_service", "my_service"),
82-
8395
("AWS_LAMBDA_FUNCTION_NAME", "function_name", None, "function"),
8496
("AWS_LAMBDA_FUNCTION_NAME", "function_name", "", ""),
8597
("AWS_LAMBDA_FUNCTION_NAME", "function_name", "my_function", "my_function"),
86-
8798
("AWS_REGION", "is_gov_region", None, False),
8899
("AWS_REGION", "is_gov_region", "", False),
89100
("AWS_REGION", "is_gov_region", "us-gov-1", True),
90101
("AWS_REGION", "is_gov_region", "us-est-1", False),
91-
92102
("AWS_LAMBDA_FUNCTION_NAME", "is_lambda_context", None, False),
93103
("AWS_LAMBDA_FUNCTION_NAME", "is_lambda_context", "", False),
94104
("AWS_LAMBDA_FUNCTION_NAME", "is_lambda_context", "my_function", True),
95-
96105
("DD_TRACE_EXTRACTOR", "trace_extractor", None, None),
97106
("DD_TRACE_EXTRACTOR", "trace_extractor", "", ""),
98107
("DD_TRACE_EXTRACTOR", "trace_extractor", "my_extractor", "my_extractor"),
99-
100108
("DD_ENV", "env", None, None),
101109
("DD_ENV", "env", "", ""),
102110
("DD_ENV", "env", "my_env", "my_env"),
@@ -113,9 +121,14 @@ def test_config_from_environ(env_key, conf_key, env_val, conf_val, setenv):
113121
*_test_as_bool("DD_TRACE_MANAGED_SERVICES", "make_inferred_span", default=True),
114122
)
115123

116-
@pytest.mark.parametrize('env_key,conf_key,env_val,conf_val', _test_config_from_environ_depends_on_tracing)
117-
@pytest.mark.parametrize('trace_enabled', [True, False])
118-
def test_config_from_environ_depends_on_tracing(env_key, conf_key, env_val, conf_val, setenv, trace_enabled):
124+
125+
@pytest.mark.parametrize(
126+
"env_key,conf_key,env_val,conf_val", _test_config_from_environ_depends_on_tracing
127+
)
128+
@pytest.mark.parametrize("trace_enabled", [True, False])
129+
def test_config_from_environ_depends_on_tracing(
130+
env_key, conf_key, env_val, conf_val, setenv, trace_enabled
131+
):
119132
setenv(env_key, env_val)
120133
setenv("DD_TRACE_ENABLED", "true" if trace_enabled else "false")
121134
if trace_enabled:

0 commit comments

Comments
 (0)