datadog_lambda 8.122.0__tar.gz → 8.123.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. {datadog_lambda-8.122.0 → datadog_lambda-8.123.0}/PKG-INFO +1 -1
  2. {datadog_lambda-8.122.0 → datadog_lambda-8.123.0}/datadog_lambda/cold_start.py +17 -0
  3. {datadog_lambda-8.122.0 → datadog_lambda-8.123.0}/datadog_lambda/config.py +1 -0
  4. datadog_lambda-8.123.0/datadog_lambda/durable.py +49 -0
  5. {datadog_lambda-8.122.0 → datadog_lambda-8.123.0}/datadog_lambda/tracing.py +3 -0
  6. datadog_lambda-8.123.0/datadog_lambda/version.py +1 -0
  7. {datadog_lambda-8.122.0 → datadog_lambda-8.123.0}/datadog_lambda/wrapper.py +12 -2
  8. {datadog_lambda-8.122.0 → datadog_lambda-8.123.0}/pyproject.toml +2 -2
  9. datadog_lambda-8.122.0/datadog_lambda/version.py +0 -1
  10. {datadog_lambda-8.122.0 → datadog_lambda-8.123.0}/LICENSE +0 -0
  11. {datadog_lambda-8.122.0 → datadog_lambda-8.123.0}/LICENSE-3rdparty.csv +0 -0
  12. {datadog_lambda-8.122.0 → datadog_lambda-8.123.0}/NOTICE +0 -0
  13. {datadog_lambda-8.122.0 → datadog_lambda-8.123.0}/README.md +0 -0
  14. {datadog_lambda-8.122.0 → datadog_lambda-8.123.0}/datadog_lambda/__init__.py +0 -0
  15. {datadog_lambda-8.122.0 → datadog_lambda-8.123.0}/datadog_lambda/api.py +0 -0
  16. {datadog_lambda-8.122.0 → datadog_lambda-8.123.0}/datadog_lambda/asm.py +0 -0
  17. {datadog_lambda-8.122.0 → datadog_lambda-8.123.0}/datadog_lambda/constants.py +0 -0
  18. {datadog_lambda-8.122.0 → datadog_lambda-8.123.0}/datadog_lambda/dogstatsd.py +0 -0
  19. {datadog_lambda-8.122.0 → datadog_lambda-8.123.0}/datadog_lambda/extension.py +0 -0
  20. {datadog_lambda-8.122.0 → datadog_lambda-8.123.0}/datadog_lambda/handler.py +0 -0
  21. {datadog_lambda-8.122.0 → datadog_lambda-8.123.0}/datadog_lambda/logger.py +0 -0
  22. {datadog_lambda-8.122.0 → datadog_lambda-8.123.0}/datadog_lambda/metric.py +0 -0
  23. {datadog_lambda-8.122.0 → datadog_lambda-8.123.0}/datadog_lambda/module_name.py +0 -0
  24. {datadog_lambda-8.122.0 → datadog_lambda-8.123.0}/datadog_lambda/patch.py +0 -0
  25. {datadog_lambda-8.122.0 → datadog_lambda-8.123.0}/datadog_lambda/span_pointers.py +0 -0
  26. {datadog_lambda-8.122.0 → datadog_lambda-8.123.0}/datadog_lambda/stats_writer.py +0 -0
  27. {datadog_lambda-8.122.0 → datadog_lambda-8.123.0}/datadog_lambda/statsd_writer.py +0 -0
  28. {datadog_lambda-8.122.0 → datadog_lambda-8.123.0}/datadog_lambda/tag_object.py +0 -0
  29. {datadog_lambda-8.122.0 → datadog_lambda-8.123.0}/datadog_lambda/tags.py +0 -0
  30. {datadog_lambda-8.122.0 → datadog_lambda-8.123.0}/datadog_lambda/thread_stats_writer.py +0 -0
  31. {datadog_lambda-8.122.0 → datadog_lambda-8.123.0}/datadog_lambda/trigger.py +0 -0
  32. {datadog_lambda-8.122.0 → datadog_lambda-8.123.0}/datadog_lambda/xray.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: datadog_lambda
3
- Version: 8.122.0
3
+ Version: 8.123.0
4
4
  Summary: The Datadog AWS Lambda Library
5
5
  Home-page: https://github.com/DataDog/datadog-lambda-python
6
6
  License: Apache-2.0
@@ -63,6 +63,19 @@ def get_proactive_init_tag():
63
63
  )
64
64
 
65
65
 
66
+ def is_managed_instances_mode():
67
+ """
68
+ Checks if the Lambda function is running in managed instances mode.
69
+ In managed instances mode, we should not create cold start tracing spans
70
+ as the gap between the sandbox initialization and the first
71
+ invocation might not be be a great experience.
72
+
73
+ Returns:
74
+ bool: True if running in managed instances mode, False otherwise
75
+ """
76
+ return config.aws_lambda_initialization_type == "lambda-managed-instances"
77
+
78
+
66
79
  class ImportNode(object):
67
80
  def __init__(self, module_name, full_file_path, start_time_ns, end_time_ns=None):
68
81
  self.module_name = module_name
@@ -145,6 +158,10 @@ def wrap_find_spec(original_find_spec):
145
158
 
146
159
 
147
160
  def initialize_cold_start_tracing():
161
+ # Skip cold start tracing initialization in managed instances mode
162
+ if is_managed_instances_mode():
163
+ return
164
+
148
165
  if is_new_sandbox() and config.cold_start_tracing:
149
166
  from sys import meta_path
150
167
 
@@ -98,6 +98,7 @@ class Config:
98
98
  integration_test = _get_env("DD_INTEGRATION_TEST", "false", as_bool)
99
99
 
100
100
  aws_lambda_function_name = _get_env("AWS_LAMBDA_FUNCTION_NAME")
101
+ aws_lambda_initialization_type = _get_env("AWS_LAMBDA_INITIALIZATION_TYPE")
101
102
 
102
103
  @property
103
104
  def function_name(self):
@@ -0,0 +1,49 @@
1
+ # Unless explicitly stated otherwise all files in this repository are licensed
2
+ # under the Apache License Version 2.0.
3
+ # This product includes software developed at Datadog (https://www.datadoghq.com/).
4
+ # Copyright 2019 Datadog, Inc.
5
+ import logging
6
+ import re
7
+
8
+ logger = logging.getLogger(__name__)
9
+
10
+
11
+ def _parse_durable_execution_arn(arn):
12
+ """
13
+ Parses a DurableExecutionArn to extract execution name and ID.
14
+ ARN format:
15
+ arn:aws:lambda:{region}:{account}:function:{func}:{version}/durable-execution/{name}/{id}
16
+ Returns (execution_name, execution_id) or None if parsing fails.
17
+ """
18
+ match = re.search(r"/durable-execution/([^/]+)/([^/]+)$", arn)
19
+ if not match:
20
+ return None
21
+ execution_name, execution_id = match.group(1), match.group(2)
22
+ if not execution_name or not execution_id:
23
+ return None
24
+ return execution_name, execution_id
25
+
26
+
27
+ def extract_durable_function_tags(event):
28
+ """
29
+ Extracts durable function tags from the Lambda event payload.
30
+ Returns a dict with durable function tags, or an empty dict if the event
31
+ is not a durable function invocation.
32
+ """
33
+ if not isinstance(event, dict):
34
+ return {}
35
+
36
+ durable_execution_arn = event.get("DurableExecutionArn")
37
+ if not isinstance(durable_execution_arn, str):
38
+ return {}
39
+
40
+ parsed = _parse_durable_execution_arn(durable_execution_arn)
41
+ if not parsed:
42
+ logger.error("Failed to parse DurableExecutionArn: %s", durable_execution_arn)
43
+ return {}
44
+
45
+ execution_name, execution_id = parsed
46
+ return {
47
+ "durable_function_execution_name": execution_name,
48
+ "durable_function_execution_id": execution_id,
49
+ }
@@ -1449,6 +1449,7 @@ def create_function_execution_span(
1449
1449
  trace_context_source,
1450
1450
  merge_xray_traces,
1451
1451
  trigger_tags,
1452
+ durable_function_tags=None,
1452
1453
  parent_span=None,
1453
1454
  span_pointers=None,
1454
1455
  ):
@@ -1477,6 +1478,8 @@ def create_function_execution_span(
1477
1478
  if trace_context_source == TraceContextSource.XRAY and merge_xray_traces:
1478
1479
  tags["_dd.parent_source"] = trace_context_source
1479
1480
  tags.update(trigger_tags)
1481
+ if durable_function_tags:
1482
+ tags.update(durable_function_tags)
1480
1483
  tracer.set_tags(_dd_origin)
1481
1484
  # Determine service name based on config and env var
1482
1485
  if config.service:
@@ -0,0 +1 @@
1
+ __version__ = "8.123.0"
@@ -16,6 +16,7 @@ from datadog_lambda.cold_start import (
16
16
  is_cold_start,
17
17
  is_proactive_init,
18
18
  is_new_sandbox,
19
+ is_managed_instances_mode,
19
20
  ColdStartTracer,
20
21
  )
21
22
  from datadog_lambda.config import config
@@ -41,6 +42,7 @@ from datadog_lambda.tracing import (
41
42
  tracer,
42
43
  propagator,
43
44
  )
45
+ from datadog_lambda.durable import extract_durable_function_tags
44
46
  from datadog_lambda.trigger import (
45
47
  extract_trigger_tags,
46
48
  extract_http_status_code_tag,
@@ -242,6 +244,7 @@ class _LambdaDecorator(object):
242
244
  submit_invocations_metric(context)
243
245
 
244
246
  self.trigger_tags = extract_trigger_tags(event, context)
247
+ self.durable_function_tags = extract_durable_function_tags(event)
245
248
  # Extract Datadog trace context and source from incoming requests
246
249
  dd_context, trace_context_source, event_source = extract_dd_trace_context(
247
250
  event,
@@ -279,6 +282,7 @@ class _LambdaDecorator(object):
279
282
  trace_context_source=trace_context_source,
280
283
  merge_xray_traces=config.merge_xray_traces,
281
284
  trigger_tags=self.trigger_tags,
285
+ durable_function_tags=self.durable_function_tags,
282
286
  parent_span=self.inferred_span,
283
287
  span_pointers=calculate_span_pointers(event_source, event),
284
288
  )
@@ -288,7 +292,7 @@ class _LambdaDecorator(object):
288
292
  else:
289
293
  set_correlation_ids()
290
294
  if config.profiling_enabled and profiler and is_new_sandbox():
291
- self.prof.start(stop_on_exit=False, profile_children=True)
295
+ self.prof.start()
292
296
  logger.debug("datadog_lambda_wrapper _before() done")
293
297
  except Exception as e:
294
298
  logger.error(format_err_with_traceback(e))
@@ -338,7 +342,13 @@ class _LambdaDecorator(object):
338
342
  create_dd_dummy_metadata_subsegment(
339
343
  self.trigger_tags, XraySubsegment.LAMBDA_FUNCTION_TAGS_KEY
340
344
  )
341
- should_trace_cold_start = config.cold_start_tracing and is_new_sandbox()
345
+ # Skip creating cold start spans in managed instances mode
346
+ # In managed instances, the tracer library handles cold start independently
347
+ should_trace_cold_start = (
348
+ config.cold_start_tracing
349
+ and is_new_sandbox()
350
+ and not is_managed_instances_mode()
351
+ )
342
352
  if should_trace_cold_start:
343
353
  trace_ctx = tracer.current_trace_context()
344
354
 
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "datadog_lambda"
3
- version = "8.122.0"
3
+ version = "8.123.0"
4
4
  description = "The Datadog AWS Lambda Library"
5
5
  authors = ["Datadog, Inc. <dev@datadoghq.com>"]
6
6
  license = "Apache-2.0"
@@ -54,4 +54,4 @@ requires = ["poetry-core>=1.0.0"]
54
54
  build-backend = "poetry.core.masonry.api"
55
55
 
56
56
  [tool.pytest.ini_options]
57
- addopts = "--benchmark-disable --benchmark-autosave"
57
+ addopts = "--benchmark-disable --benchmark-autosave"
@@ -1 +0,0 @@
1
- __version__ = "8.122.0"