Skip to content

Commit d0ef887

Browse files
committed
Add encode_authorizer_context.
1 parent 2437a53 commit d0ef887

3 files changed

Lines changed: 3 additions & 7 deletions

File tree

datadog_lambda/config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ class Config:
8080

8181
make_inferred_span = _get_env("DD_TRACE_MANAGED_SERVICES", "true", as_bool,
8282
depends_on_tracing=True)
83+
encode_authorizer_context = _get_env("DD_ENCODE_AUTHORIZER_CONTEXT", "true", as_bool,
84+
depends_on_tracing=True)
8385

8486
local_test = _get_env("DD_LOCAL_TEST", "false", as_bool)
8587

datadog_lambda/wrapper.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
logger = logging.getLogger(__name__)
5858

5959
DD_TRACE_MANAGED_SERVICES = "DD_TRACE_MANAGED_SERVICES"
60-
DD_ENCODE_AUTHORIZER_CONTEXT = "DD_ENCODE_AUTHORIZER_CONTEXT"
6160
DD_DECODE_AUTHORIZER_CONTEXT = "DD_DECODE_AUTHORIZER_CONTEXT"
6261
DD_COLD_START_TRACING = "DD_COLD_START_TRACING"
6362
DD_REQUESTS_SERVICE_NAME = "DD_REQUESTS_SERVICE_NAME"
@@ -126,9 +125,6 @@ def __init__(self, func):
126125
depends_on_dd_tracing_enabled = (
127126
lambda original_boolean: config.trace_enabled and original_boolean
128127
)
129-
self.encode_authorizer_context = depends_on_dd_tracing_enabled(
130-
os.environ.get(DD_ENCODE_AUTHORIZER_CONTEXT, "true").lower() == "true"
131-
)
132128
self.decode_authorizer_context = depends_on_dd_tracing_enabled(
133129
os.environ.get(DD_DECODE_AUTHORIZER_CONTEXT, "true").lower() == "true"
134130
)
@@ -337,7 +333,7 @@ def _after(self, event, context):
337333
if config.llmobs_enabled:
338334
LLMObs.flush()
339335

340-
if self.encode_authorizer_context and is_authorizer_response(self.response):
336+
if config.encode_authorizer_context and is_authorizer_response(self.response):
341337
self._inject_authorizer_span_headers(
342338
event.get("requestContext", {}).get("requestId")
343339
)

tests/test_wrapper.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,10 +562,8 @@ def return_type_test(event, context):
562562
class TestLambdaDecoratorSettings(unittest.TestCase):
563563
@patch("datadog_lambda.config.Config.trace_enabled", False)
564564
def test_some_envs_should_depend_on_dd_tracing_enabled(self):
565-
os.environ[wrapper.DD_ENCODE_AUTHORIZER_CONTEXT] = "true"
566565
os.environ[wrapper.DD_DECODE_AUTHORIZER_CONTEXT] = "true"
567566
decorator = wrapper._LambdaDecorator(func=None)
568-
self.assertFalse(decorator.encode_authorizer_context)
569567
self.assertFalse(decorator.decode_authorizer_context)
570568

571569

0 commit comments

Comments
 (0)