datadog_lambda 6.104.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.104.0 → datadog_lambda-6.106.0}/PKG-INFO +5 -5
  2. {datadog_lambda-6.104.0 → datadog_lambda-6.106.0}/README.md +2 -2
  3. {datadog_lambda-6.104.0 → datadog_lambda-6.106.0}/datadog_lambda/cold_start.py +1 -1
  4. {datadog_lambda-6.104.0 → datadog_lambda-6.106.0}/datadog_lambda/metric.py +16 -0
  5. {datadog_lambda-6.104.0 → datadog_lambda-6.106.0}/datadog_lambda/tracing.py +19 -4
  6. datadog_lambda-6.106.0/datadog_lambda/version.py +1 -0
  7. {datadog_lambda-6.104.0 → datadog_lambda-6.106.0}/pyproject.toml +4 -3
  8. datadog_lambda-6.104.0/datadog_lambda/version.py +0 -1
  9. {datadog_lambda-6.104.0 → datadog_lambda-6.106.0}/LICENSE +0 -0
  10. {datadog_lambda-6.104.0 → datadog_lambda-6.106.0}/LICENSE-3rdparty.csv +0 -0
  11. {datadog_lambda-6.104.0 → datadog_lambda-6.106.0}/NOTICE +0 -0
  12. {datadog_lambda-6.104.0 → datadog_lambda-6.106.0}/datadog_lambda/__init__.py +0 -0
  13. {datadog_lambda-6.104.0 → datadog_lambda-6.106.0}/datadog_lambda/api.py +0 -0
  14. {datadog_lambda-6.104.0 → datadog_lambda-6.106.0}/datadog_lambda/constants.py +0 -0
  15. {datadog_lambda-6.104.0 → datadog_lambda-6.106.0}/datadog_lambda/dogstatsd.py +0 -0
  16. {datadog_lambda-6.104.0 → datadog_lambda-6.106.0}/datadog_lambda/extension.py +0 -0
  17. {datadog_lambda-6.104.0 → datadog_lambda-6.106.0}/datadog_lambda/handler.py +0 -0
  18. {datadog_lambda-6.104.0 → datadog_lambda-6.106.0}/datadog_lambda/logger.py +0 -0
  19. {datadog_lambda-6.104.0 → datadog_lambda-6.106.0}/datadog_lambda/module_name.py +0 -0
  20. {datadog_lambda-6.104.0 → datadog_lambda-6.106.0}/datadog_lambda/patch.py +0 -0
  21. {datadog_lambda-6.104.0 → datadog_lambda-6.106.0}/datadog_lambda/span_pointers.py +0 -0
  22. {datadog_lambda-6.104.0 → datadog_lambda-6.106.0}/datadog_lambda/stats_writer.py +0 -0
  23. {datadog_lambda-6.104.0 → datadog_lambda-6.106.0}/datadog_lambda/statsd_writer.py +0 -0
  24. {datadog_lambda-6.104.0 → datadog_lambda-6.106.0}/datadog_lambda/tag_object.py +0 -0
  25. {datadog_lambda-6.104.0 → datadog_lambda-6.106.0}/datadog_lambda/tags.py +0 -0
  26. {datadog_lambda-6.104.0 → datadog_lambda-6.106.0}/datadog_lambda/thread_stats_writer.py +0 -0
  27. {datadog_lambda-6.104.0 → datadog_lambda-6.106.0}/datadog_lambda/trigger.py +0 -0
  28. {datadog_lambda-6.104.0 → datadog_lambda-6.106.0}/datadog_lambda/wrapper.py +0 -0
  29. {datadog_lambda-6.104.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.104.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
@@ -18,8 +18,8 @@ Classifier: Programming Language :: Python :: 3.12
18
18
  Classifier: Programming Language :: Python :: 3.13
19
19
  Provides-Extra: dev
20
20
  Requires-Dist: boto3 (>=1.34.0,<2.0.0) ; extra == "dev"
21
- Requires-Dist: datadog (>=0.41.0,<1.0.0)
22
- Requires-Dist: ddtrace (>=2.17.0)
21
+ Requires-Dist: datadog (>=0.51.0,<1.0.0)
22
+ Requires-Dist: ddtrace (>=2.20.0)
23
23
  Requires-Dist: flake8 (>=5.0.4,<6.0.0) ; extra == "dev"
24
24
  Requires-Dist: pytest (>=8.0.0,<9.0.0) ; extra == "dev"
25
25
  Requires-Dist: pytest-benchmark (>=4.0,<5.0) ; extra == "dev"
@@ -37,7 +37,7 @@ Description-Content-Type: text/markdown
37
37
  [![Slack](https://chat.datadoghq.com/badge.svg?bg=632CA6)](https://chat.datadoghq.com/)
38
38
  [![License](https://img.shields.io/badge/license-Apache--2.0-blue)](https://github.com/DataDog/datadog-lambda-python/blob/main/LICENSE)
39
39
 
40
- Datadog Lambda Library for Python (3.8, 3.9, 3.10, 3.11, and 3.12) enables [enhanced Lambda metrics](https://docs.datadoghq.com/serverless/enhanced_lambda_metrics), [distributed tracing](https://docs.datadoghq.com/serverless/distributed_tracing), and [custom metric submission](https://docs.datadoghq.com/serverless/custom_metrics) from AWS Lambda functions.
40
+ Datadog Lambda Library for Python (3.8, 3.9, 3.10, 3.11, 3.12, and 3.13) enables [enhanced Lambda metrics](https://docs.datadoghq.com/serverless/enhanced_lambda_metrics), [distributed tracing](https://docs.datadoghq.com/serverless/distributed_tracing), and [custom metric submission](https://docs.datadoghq.com/serverless/custom_metrics) from AWS Lambda functions.
41
41
 
42
42
  ## Installation
43
43
 
@@ -55,7 +55,7 @@ Besides the environment variables supported by dd-trace-py, the datadog-lambda-p
55
55
  | -------------------- | ------------ | ------------- |
56
56
  | DD_ENCODE_AUTHORIZER_CONTEXT | When set to `true` for Lambda authorizers, the tracing context will be encoded into the response for propagation. Supported for NodeJS and Python. | `true` |
57
57
  | DD_DECODE_AUTHORIZER_CONTEXT | When set to `true` for Lambdas that are authorized via Lambda authorizers, it will parse and use the encoded tracing context (if found). Supported for NodeJS and Python. | `true` |
58
- | DD_COLD_START_TRACING | Set to `false` to disable Cold Start Tracing. Used in NodeJS and Python. | `true` |
58
+ | DD_COLD_START_TRACING | When true (default), tracing occurs during cold start which creates many child spans. When false, only one cold start span is created. Used in NodeJS and Python. | `true` |
59
59
  | DD_MIN_COLD_START_DURATION | Sets the minimum duration (in milliseconds) for a module load event to be traced via Cold Start Tracing. Number. | `3` |
60
60
  | DD_COLD_START_TRACE_SKIP_LIB | optionally skip creating Cold Start Spans for a comma-separated list of libraries. Useful to limit depth or skip known libraries. | `ddtrace.internal.compat,ddtrace.filters` |
61
61
  | DD_CAPTURE_LAMBDA_PAYLOAD | [Captures incoming and outgoing AWS Lambda payloads][1] in the Datadog APM spans for Lambda invocations. | `false` |
@@ -6,7 +6,7 @@
6
6
  [![Slack](https://chat.datadoghq.com/badge.svg?bg=632CA6)](https://chat.datadoghq.com/)
7
7
  [![License](https://img.shields.io/badge/license-Apache--2.0-blue)](https://github.com/DataDog/datadog-lambda-python/blob/main/LICENSE)
8
8
 
9
- Datadog Lambda Library for Python (3.8, 3.9, 3.10, 3.11, and 3.12) enables [enhanced Lambda metrics](https://docs.datadoghq.com/serverless/enhanced_lambda_metrics), [distributed tracing](https://docs.datadoghq.com/serverless/distributed_tracing), and [custom metric submission](https://docs.datadoghq.com/serverless/custom_metrics) from AWS Lambda functions.
9
+ Datadog Lambda Library for Python (3.8, 3.9, 3.10, 3.11, 3.12, and 3.13) enables [enhanced Lambda metrics](https://docs.datadoghq.com/serverless/enhanced_lambda_metrics), [distributed tracing](https://docs.datadoghq.com/serverless/distributed_tracing), and [custom metric submission](https://docs.datadoghq.com/serverless/custom_metrics) from AWS Lambda functions.
10
10
 
11
11
  ## Installation
12
12
 
@@ -24,7 +24,7 @@ Besides the environment variables supported by dd-trace-py, the datadog-lambda-p
24
24
  | -------------------- | ------------ | ------------- |
25
25
  | DD_ENCODE_AUTHORIZER_CONTEXT | When set to `true` for Lambda authorizers, the tracing context will be encoded into the response for propagation. Supported for NodeJS and Python. | `true` |
26
26
  | DD_DECODE_AUTHORIZER_CONTEXT | When set to `true` for Lambdas that are authorized via Lambda authorizers, it will parse and use the encoded tracing context (if found). Supported for NodeJS and Python. | `true` |
27
- | DD_COLD_START_TRACING | Set to `false` to disable Cold Start Tracing. Used in NodeJS and Python. | `true` |
27
+ | DD_COLD_START_TRACING | When true (default), tracing occurs during cold start which creates many child spans. When false, only one cold start span is created. Used in NodeJS and Python. | `true` |
28
28
  | DD_MIN_COLD_START_DURATION | Sets the minimum duration (in milliseconds) for a module load event to be traced via Cold Start Tracing. Number. | `3` |
29
29
  | DD_COLD_START_TRACE_SKIP_LIB | optionally skip creating Cold Start Spans for a comma-separated list of libraries. Useful to limit depth or skip known libraries. | `ddtrace.internal.compat,ddtrace.filters` |
30
30
  | DD_CAPTURE_LAMBDA_PAYLOAD | [Captures incoming and outgoing AWS Lambda payloads][1] in the Datadog APM spans for Lambda invocations. | `false` |
@@ -31,7 +31,7 @@ def set_cold_start(init_timestamp_ns):
31
31
  _cold_start = False
32
32
  _proactive_initialization = False
33
33
  _lambda_container_initialized = True
34
- from ddtrace import tracer as _tracer
34
+ from ddtrace.trace import tracer as _tracer
35
35
 
36
36
 
37
37
  def is_cold_start():
@@ -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)
@@ -30,10 +30,10 @@ from datadog_lambda.xray import (
30
30
  parse_xray_header,
31
31
  )
32
32
 
33
- from ddtrace import tracer, patch, Span
33
+ from ddtrace import patch
34
34
  from ddtrace import __version__ as ddtrace_version
35
35
  from ddtrace.propagation.http import HTTPPropagator
36
- from ddtrace.context import Context
36
+ from ddtrace.trace import Context, Span, tracer
37
37
  from datadog_lambda import __version__ as datadog_lambda_version
38
38
  from datadog_lambda.trigger import (
39
39
  _EventSource,
@@ -384,12 +384,26 @@ def _parse_high_64_bits(trace_tags: str) -> str:
384
384
 
385
385
 
386
386
  def _generate_sfn_parent_id(context: dict) -> int:
387
+ """
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.
391
+
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.
394
+ """
387
395
  execution_id = context.get("Execution").get("Id")
396
+ redrive_count = context.get("Execution").get("RedriveCount", 0)
388
397
  state_name = context.get("State").get("Name")
389
398
  state_entered_time = context.get("State").get("EnteredTime")
399
+ retry_count = context.get("State").get("RetryCount", 0)
400
+
401
+ include_counts = not (retry_count == 0 and redrive_count == 0)
402
+ counts_suffix = f"#{retry_count}#{redrive_count}" if include_counts else ""
390
403
 
391
404
  return _deterministic_sha256_hash(
392
- f"{execution_id}#{state_name}#{state_entered_time}", HIGHER_64_BITS
405
+ f"{execution_id}#{state_name}#{state_entered_time}{counts_suffix}",
406
+ HIGHER_64_BITS,
393
407
  )
394
408
 
395
409
 
@@ -1357,8 +1371,9 @@ def create_function_execution_span(
1357
1371
  if parent_span:
1358
1372
  span.parent_id = parent_span.span_id
1359
1373
  if span_pointers:
1374
+ root_span = parent_span if parent_span else span
1360
1375
  for span_pointer_description in span_pointers:
1361
- span._add_span_pointer(
1376
+ root_span._add_span_pointer(
1362
1377
  pointer_kind=span_pointer_description.pointer_kind,
1363
1378
  pointer_direction=span_pointer_description.pointer_direction,
1364
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.104.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"
@@ -21,13 +21,14 @@ classifiers = [
21
21
  "Programming Language :: Python :: 3.10",
22
22
  "Programming Language :: Python :: 3.11",
23
23
  "Programming Language :: Python :: 3.12",
24
+ "Programming Language :: Python :: 3.13",
24
25
  ]
25
26
 
26
27
  [tool.poetry.dependencies]
27
28
  python = ">=3.8.0,<4"
28
- datadog = ">=0.41.0,<1.0.0"
29
+ datadog = ">=0.51.0,<1.0.0"
29
30
  wrapt = "^1.11.2"
30
- ddtrace = ">=2.17.0"
31
+ ddtrace = ">=2.20.0"
31
32
  ujson = ">=5.9.0"
32
33
  boto3 = { version = "^1.34.0", optional = true }
33
34
  requests = { version ="^2.22.0", optional = true }
@@ -1 +0,0 @@
1
- __version__ = "6.104.0"