datadog_lambda 6.105.0__tar.gz → 6.106.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 (29) hide show
  1. {datadog_lambda-6.105.0 → datadog_lambda-6.106.0}/PKG-INFO +1 -1
  2. {datadog_lambda-6.105.0 → datadog_lambda-6.106.0}/datadog_lambda/metric.py +16 -0
  3. {datadog_lambda-6.105.0 → datadog_lambda-6.106.0}/datadog_lambda/tracing.py +11 -7
  4. datadog_lambda-6.106.0/datadog_lambda/version.py +1 -0
  5. {datadog_lambda-6.105.0 → datadog_lambda-6.106.0}/pyproject.toml +1 -1
  6. datadog_lambda-6.105.0/datadog_lambda/version.py +0 -1
  7. {datadog_lambda-6.105.0 → datadog_lambda-6.106.0}/LICENSE +0 -0
  8. {datadog_lambda-6.105.0 → datadog_lambda-6.106.0}/LICENSE-3rdparty.csv +0 -0
  9. {datadog_lambda-6.105.0 → datadog_lambda-6.106.0}/NOTICE +0 -0
  10. {datadog_lambda-6.105.0 → datadog_lambda-6.106.0}/README.md +0 -0
  11. {datadog_lambda-6.105.0 → datadog_lambda-6.106.0}/datadog_lambda/__init__.py +0 -0
  12. {datadog_lambda-6.105.0 → datadog_lambda-6.106.0}/datadog_lambda/api.py +0 -0
  13. {datadog_lambda-6.105.0 → datadog_lambda-6.106.0}/datadog_lambda/cold_start.py +0 -0
  14. {datadog_lambda-6.105.0 → datadog_lambda-6.106.0}/datadog_lambda/constants.py +0 -0
  15. {datadog_lambda-6.105.0 → datadog_lambda-6.106.0}/datadog_lambda/dogstatsd.py +0 -0
  16. {datadog_lambda-6.105.0 → datadog_lambda-6.106.0}/datadog_lambda/extension.py +0 -0
  17. {datadog_lambda-6.105.0 → datadog_lambda-6.106.0}/datadog_lambda/handler.py +0 -0
  18. {datadog_lambda-6.105.0 → datadog_lambda-6.106.0}/datadog_lambda/logger.py +0 -0
  19. {datadog_lambda-6.105.0 → datadog_lambda-6.106.0}/datadog_lambda/module_name.py +0 -0
  20. {datadog_lambda-6.105.0 → datadog_lambda-6.106.0}/datadog_lambda/patch.py +0 -0
  21. {datadog_lambda-6.105.0 → datadog_lambda-6.106.0}/datadog_lambda/span_pointers.py +0 -0
  22. {datadog_lambda-6.105.0 → datadog_lambda-6.106.0}/datadog_lambda/stats_writer.py +0 -0
  23. {datadog_lambda-6.105.0 → datadog_lambda-6.106.0}/datadog_lambda/statsd_writer.py +0 -0
  24. {datadog_lambda-6.105.0 → datadog_lambda-6.106.0}/datadog_lambda/tag_object.py +0 -0
  25. {datadog_lambda-6.105.0 → datadog_lambda-6.106.0}/datadog_lambda/tags.py +0 -0
  26. {datadog_lambda-6.105.0 → datadog_lambda-6.106.0}/datadog_lambda/thread_stats_writer.py +0 -0
  27. {datadog_lambda-6.105.0 → datadog_lambda-6.106.0}/datadog_lambda/trigger.py +0 -0
  28. {datadog_lambda-6.105.0 → datadog_lambda-6.106.0}/datadog_lambda/wrapper.py +0 -0
  29. {datadog_lambda-6.105.0 → datadog_lambda-6.106.0}/datadog_lambda/xray.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: datadog_lambda
3
- Version: 6.105.0
3
+ Version: 6.106.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
@@ -55,6 +55,22 @@ def lambda_metric(metric_name, value, timestamp=None, tags=None, force_async=Fal
55
55
  Note that if the extension is present, it will override the DD_FLUSH_TO_LOG value
56
56
  and always use the layer to send metrics to the extension
57
57
  """
58
+ if not metric_name or not isinstance(metric_name, str):
59
+ logger.warning(
60
+ "Ignoring metric submission. Invalid metric name: %s", metric_name
61
+ )
62
+ return
63
+
64
+ try:
65
+ float(value)
66
+ except (ValueError, TypeError):
67
+ logger.warning(
68
+ "Ignoring metric submission for metric '%s' because the value is not numeric: %r",
69
+ metric_name,
70
+ value,
71
+ )
72
+ return
73
+
58
74
  flush_to_logs = os.environ.get("DD_FLUSH_TO_LOG", "").lower() == "true"
59
75
  tags = [] if tags is None else list(tags)
60
76
  tags.append(dd_lambda_layer_tag)
@@ -385,21 +385,24 @@ def _parse_high_64_bits(trace_tags: str) -> str:
385
385
 
386
386
  def _generate_sfn_parent_id(context: dict) -> int:
387
387
  """
388
- The upstream Step Function can propagate its execution context to downstream Lambdas. The
389
- Lambda can use these details to share the same traceID and infer its parent's spanID.
388
+ Generates a stable parent span ID for a downstream Lambda invoked by a Step Function. The
389
+ upstream Step Function execution context is used to infer the parent's span ID, ensuring trace
390
+ continuity.
390
391
 
391
- Excluding redriveCount when its 0 to account for cases where customers are using an old
392
- version of the Lambda layer that doesn't use this value for its parentID generation.
392
+ `RetryCount` and `RedriveCount` are appended only when both are nonzero to maintain
393
+ compatibility with older Lambda layers that did not include these fields.
393
394
  """
394
395
  execution_id = context.get("Execution").get("Id")
395
396
  redrive_count = context.get("Execution").get("RedriveCount", 0)
396
397
  state_name = context.get("State").get("Name")
397
398
  state_entered_time = context.get("State").get("EnteredTime")
399
+ retry_count = context.get("State").get("RetryCount", 0)
398
400
 
399
- redrive_postfix = "" if redrive_count == 0 else f"#{redrive_count}"
401
+ include_counts = not (retry_count == 0 and redrive_count == 0)
402
+ counts_suffix = f"#{retry_count}#{redrive_count}" if include_counts else ""
400
403
 
401
404
  return _deterministic_sha256_hash(
402
- f"{execution_id}#{state_name}#{state_entered_time}{redrive_postfix}",
405
+ f"{execution_id}#{state_name}#{state_entered_time}{counts_suffix}",
403
406
  HIGHER_64_BITS,
404
407
  )
405
408
 
@@ -1368,8 +1371,9 @@ def create_function_execution_span(
1368
1371
  if parent_span:
1369
1372
  span.parent_id = parent_span.span_id
1370
1373
  if span_pointers:
1374
+ root_span = parent_span if parent_span else span
1371
1375
  for span_pointer_description in span_pointers:
1372
- span._add_span_pointer(
1376
+ root_span._add_span_pointer(
1373
1377
  pointer_kind=span_pointer_description.pointer_kind,
1374
1378
  pointer_direction=span_pointer_description.pointer_direction,
1375
1379
  pointer_hash=span_pointer_description.pointer_hash,
@@ -0,0 +1 @@
1
+ __version__ = "6.106.0"
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "datadog_lambda"
3
- version = "6.105.0"
3
+ version = "6.106.0"
4
4
  description = "The Datadog AWS Lambda Library"
5
5
  authors = ["Datadog, Inc. <dev@datadoghq.com>"]
6
6
  license = "Apache-2.0"
@@ -1 +0,0 @@
1
- __version__ = "6.105.0"