|
60 | 60 | DD_LOGS_INJECTION = "DD_LOGS_INJECTION"
|
61 | 61 | DD_MERGE_XRAY_TRACES = "DD_MERGE_XRAY_TRACES"
|
62 | 62 | AWS_LAMBDA_FUNCTION_NAME = "AWS_LAMBDA_FUNCTION_NAME"
|
| 63 | +DD_LOCAL_TEST = "DD_LOCAL_TEST" |
63 | 64 | DD_TRACE_EXTRACTOR = "DD_TRACE_EXTRACTOR"
|
64 | 65 | DD_TRACE_MANAGED_SERVICES = "DD_TRACE_MANAGED_SERVICES"
|
65 | 66 | DD_ENCODE_AUTHORIZER_CONTEXT = "DD_ENCODE_AUTHORIZER_CONTEXT"
|
@@ -183,6 +184,9 @@ def __init__(self, func):
|
183 | 184 | self.min_cold_start_trace_duration = get_env_as_int(
|
184 | 185 | DD_MIN_COLD_START_DURATION, 3
|
185 | 186 | )
|
| 187 | + self.local_testing_mode = ( |
| 188 | + os.environ.get(DD_LOCAL_TEST, "false").lower() in ("true", "1") |
| 189 | + ) |
186 | 190 | self.cold_start_trace_skip_lib = [
|
187 | 191 | "ddtrace.internal.compat",
|
188 | 192 | "ddtrace.filters",
|
@@ -367,7 +371,10 @@ def _after(self, event, context):
|
367 | 371 |
|
368 | 372 | if not self.flush_to_log or should_use_extension:
|
369 | 373 | flush_stats()
|
370 |
| - if should_use_extension: |
| 374 | + if should_use_extension and self.local_testing_mode: |
| 375 | + # when testing locally, the extension does not know when an |
| 376 | + # invocation completes because it does not have access to the |
| 377 | + # logs api |
371 | 378 | flush_extension()
|
372 | 379 |
|
373 | 380 | if self.encode_authorizer_context and is_authorizer_response(self.response):
|
|
0 commit comments