datadog_lambda 8.114.0__tar.gz → 8.116.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 (31) hide show
  1. {datadog_lambda-8.114.0 → datadog_lambda-8.116.0}/PKG-INFO +2 -2
  2. {datadog_lambda-8.114.0 → datadog_lambda-8.116.0}/datadog_lambda/asm.py +2 -2
  3. {datadog_lambda-8.114.0 → datadog_lambda-8.116.0}/datadog_lambda/metric.py +27 -0
  4. {datadog_lambda-8.114.0 → datadog_lambda-8.116.0}/datadog_lambda/tracing.py +18 -0
  5. {datadog_lambda-8.114.0 → datadog_lambda-8.116.0}/datadog_lambda/trigger.py +2 -1
  6. datadog_lambda-8.116.0/datadog_lambda/version.py +1 -0
  7. {datadog_lambda-8.114.0 → datadog_lambda-8.116.0}/datadog_lambda/wrapper.py +14 -2
  8. {datadog_lambda-8.114.0 → datadog_lambda-8.116.0}/pyproject.toml +2 -2
  9. datadog_lambda-8.114.0/datadog_lambda/version.py +0 -1
  10. {datadog_lambda-8.114.0 → datadog_lambda-8.116.0}/LICENSE +0 -0
  11. {datadog_lambda-8.114.0 → datadog_lambda-8.116.0}/LICENSE-3rdparty.csv +0 -0
  12. {datadog_lambda-8.114.0 → datadog_lambda-8.116.0}/NOTICE +0 -0
  13. {datadog_lambda-8.114.0 → datadog_lambda-8.116.0}/README.md +0 -0
  14. {datadog_lambda-8.114.0 → datadog_lambda-8.116.0}/datadog_lambda/__init__.py +0 -0
  15. {datadog_lambda-8.114.0 → datadog_lambda-8.116.0}/datadog_lambda/api.py +0 -0
  16. {datadog_lambda-8.114.0 → datadog_lambda-8.116.0}/datadog_lambda/cold_start.py +0 -0
  17. {datadog_lambda-8.114.0 → datadog_lambda-8.116.0}/datadog_lambda/config.py +0 -0
  18. {datadog_lambda-8.114.0 → datadog_lambda-8.116.0}/datadog_lambda/constants.py +0 -0
  19. {datadog_lambda-8.114.0 → datadog_lambda-8.116.0}/datadog_lambda/dogstatsd.py +0 -0
  20. {datadog_lambda-8.114.0 → datadog_lambda-8.116.0}/datadog_lambda/extension.py +0 -0
  21. {datadog_lambda-8.114.0 → datadog_lambda-8.116.0}/datadog_lambda/handler.py +0 -0
  22. {datadog_lambda-8.114.0 → datadog_lambda-8.116.0}/datadog_lambda/logger.py +0 -0
  23. {datadog_lambda-8.114.0 → datadog_lambda-8.116.0}/datadog_lambda/module_name.py +0 -0
  24. {datadog_lambda-8.114.0 → datadog_lambda-8.116.0}/datadog_lambda/patch.py +0 -0
  25. {datadog_lambda-8.114.0 → datadog_lambda-8.116.0}/datadog_lambda/span_pointers.py +0 -0
  26. {datadog_lambda-8.114.0 → datadog_lambda-8.116.0}/datadog_lambda/stats_writer.py +0 -0
  27. {datadog_lambda-8.114.0 → datadog_lambda-8.116.0}/datadog_lambda/statsd_writer.py +0 -0
  28. {datadog_lambda-8.114.0 → datadog_lambda-8.116.0}/datadog_lambda/tag_object.py +0 -0
  29. {datadog_lambda-8.114.0 → datadog_lambda-8.116.0}/datadog_lambda/tags.py +0 -0
  30. {datadog_lambda-8.114.0 → datadog_lambda-8.116.0}/datadog_lambda/thread_stats_writer.py +0 -0
  31. {datadog_lambda-8.114.0 → datadog_lambda-8.116.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.114.0
3
+ Version: 8.116.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
@@ -19,7 +19,7 @@ Classifier: Programming Language :: Python :: 3.13
19
19
  Provides-Extra: dev
20
20
  Requires-Dist: botocore (>=1.34.0,<2.0.0) ; extra == "dev"
21
21
  Requires-Dist: datadog (>=0.51.0,<1.0.0)
22
- Requires-Dist: ddtrace (>=3.11.0,<4)
22
+ Requires-Dist: ddtrace (>=3.16.2,<4)
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"
@@ -126,8 +126,8 @@ def asm_start_request(
126
126
 
127
127
  request_ip = _get_request_header_client_ip(request_headers, peer_ip, True)
128
128
  if request_ip is not None:
129
- span.set_tag_str("http.client_ip", request_ip)
130
- span.set_tag_str("network.client.ip", request_ip)
129
+ span.set_tag("http.client_ip", request_ip)
130
+ span.set_tag("network.client.ip", request_ip)
131
131
 
132
132
  # Encode the parsed query and append it to reconstruct the original raw URI expected by AppSec.
133
133
  if parsed_query:
@@ -214,6 +214,33 @@ def submit_errors_metric(lambda_context):
214
214
  submit_enhanced_metric("errors", lambda_context)
215
215
 
216
216
 
217
+ def submit_batch_item_failures_metric(response, lambda_context):
218
+ """Submit aws.lambda.enhanced.batch_item_failures metric with the count of batch item failures
219
+
220
+ Args:
221
+ response (dict): Lambda function response object
222
+ lambda_context (object): Lambda context dict passed to the function by AWS
223
+ """
224
+ if not config.enhanced_metrics_enabled:
225
+ logger.debug(
226
+ "Not submitting batch_item_failures metric because enhanced metrics are disabled"
227
+ )
228
+ return
229
+
230
+ if not isinstance(response, dict):
231
+ return
232
+
233
+ batch_item_failures = response.get("batchItemFailures")
234
+ if batch_item_failures is not None and isinstance(batch_item_failures, list):
235
+ lambda_metric(
236
+ "aws.lambda.enhanced.batch_item_failures",
237
+ len(batch_item_failures),
238
+ timestamp=None,
239
+ tags=get_enhanced_metrics_tags(lambda_context),
240
+ force_async=True,
241
+ )
242
+
243
+
217
244
  def submit_dynamodb_stream_type_metric(event):
218
245
  stream_view_type = (
219
246
  event.get("Records", [{}])[0].get("dynamodb", {}).get("StreamViewType")
@@ -209,6 +209,20 @@ def extract_context_from_http_event_or_context(
209
209
  return context
210
210
 
211
211
 
212
+ def extract_context_from_request_header_or_context(event, lambda_context, event_source):
213
+ request = event.get("request")
214
+ if isinstance(request, (set, dict)) and "headers" in request:
215
+ context = extract_context_from_http_event_or_context(
216
+ request,
217
+ lambda_context,
218
+ event_source,
219
+ decode_authorizer_context=False,
220
+ )
221
+ else:
222
+ context = extract_context_from_lambda_context(lambda_context)
223
+ return context
224
+
225
+
212
226
  def create_sns_event(message):
213
227
  return {
214
228
  "Records": [
@@ -627,6 +641,10 @@ def extract_dd_trace_context(
627
641
 
628
642
  if extractor is not None:
629
643
  context = extract_context_custom_extractor(extractor, event, lambda_context)
644
+ elif isinstance(event, (set, dict)) and "request" in event:
645
+ context = extract_context_from_request_header_or_context(
646
+ event, lambda_context, event_source
647
+ )
630
648
  elif isinstance(event, (set, dict)) and "headers" in event:
631
649
  context = extract_context_from_http_event_or_context(
632
650
  event, lambda_context, event_source, decode_authorizer_context
@@ -325,7 +325,8 @@ def extract_http_tags(event):
325
325
  method = apigateway_v2_http.get("method")
326
326
 
327
327
  if path:
328
- http_tags["http.url_details.path"] = path
328
+ if http_tags.get("http.url"):
329
+ http_tags["http.url"] += path
329
330
  if method:
330
331
  http_tags["http.method"] = method
331
332
 
@@ -0,0 +1 @@
1
+ __version__ = "8.116.0"
@@ -46,6 +46,10 @@ from datadog_lambda.trigger import (
46
46
  extract_http_status_code_tag,
47
47
  )
48
48
 
49
+ # ddtrace imports are also tested in
50
+ # dd-trace-py/tests/internal/test_serverless.py please update those tests when
51
+ # making changes to any ddtrace import.
52
+
49
53
  if config.appsec_enabled:
50
54
  from datadog_lambda.asm import (
51
55
  asm_set_context,
@@ -65,7 +69,11 @@ if config.llmobs_enabled:
65
69
 
66
70
  if config.exception_replay_enabled:
67
71
  from ddtrace.debugging._exception.replay import SpanExceptionHandler
68
- from ddtrace.debugging._uploader import LogsIntakeUploaderV1
72
+
73
+ try:
74
+ from ddtrace.debugging._uploader import SignalUploader
75
+ except ImportError:
76
+ from ddtrace.debugging._uploader import LogsIntakeUploaderV1 as SignalUploader
69
77
 
70
78
  logger = logging.getLogger(__name__)
71
79
 
@@ -283,6 +291,10 @@ class _LambdaDecorator(object):
283
291
 
284
292
  def _after(self, event, context):
285
293
  try:
294
+ from datadog_lambda.metric import submit_batch_item_failures_metric
295
+
296
+ submit_batch_item_failures_metric(self.response, context)
297
+
286
298
  status_code = extract_http_status_code_tag(self.trigger_tags, self.response)
287
299
 
288
300
  if self.span:
@@ -370,7 +382,7 @@ class _LambdaDecorator(object):
370
382
 
371
383
  # Flush exception replay
372
384
  if config.exception_replay_enabled:
373
- LogsIntakeUploaderV1._instance.periodic()
385
+ SignalUploader._instance.periodic()
374
386
 
375
387
  if config.encode_authorizer_context and is_authorizer_response(
376
388
  self.response
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "datadog_lambda"
3
- version = "8.114.0"
3
+ version = "8.116.0"
4
4
  description = "The Datadog AWS Lambda Library"
5
5
  authors = ["Datadog, Inc. <dev@datadoghq.com>"]
6
6
  license = "Apache-2.0"
@@ -28,7 +28,7 @@ classifiers = [
28
28
  python = ">=3.8.0,<4"
29
29
  datadog = ">=0.51.0,<1.0.0"
30
30
  wrapt = "^1.11.2"
31
- ddtrace = ">=3.11.0,<4"
31
+ ddtrace = ">=3.16.2,<4"
32
32
  ujson = ">=5.9.0"
33
33
  botocore = { version = "^1.34.0", optional = true }
34
34
  requests = { version ="^2.22.0", optional = true }
@@ -1 +0,0 @@
1
- __version__ = "8.114.0"