datadog_lambda 6.96.0__tar.gz → 6.98.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.
- {datadog_lambda-6.96.0 → datadog_lambda-6.98.0}/PKG-INFO +3 -5
- {datadog_lambda-6.96.0 → datadog_lambda-6.98.0}/datadog_lambda/metric.py +23 -2
- {datadog_lambda-6.96.0 → datadog_lambda-6.98.0}/datadog_lambda/thread_stats_writer.py +3 -1
- datadog_lambda-6.98.0/datadog_lambda/version.py +1 -0
- {datadog_lambda-6.96.0 → datadog_lambda-6.98.0}/datadog_lambda/wrapper.py +12 -1
- {datadog_lambda-6.96.0 → datadog_lambda-6.98.0}/pyproject.toml +3 -8
- datadog_lambda-6.96.0/datadog_lambda/version.py +0 -1
- {datadog_lambda-6.96.0 → datadog_lambda-6.98.0}/LICENSE +0 -0
- {datadog_lambda-6.96.0 → datadog_lambda-6.98.0}/LICENSE-3rdparty.csv +0 -0
- {datadog_lambda-6.96.0 → datadog_lambda-6.98.0}/NOTICE +0 -0
- {datadog_lambda-6.96.0 → datadog_lambda-6.98.0}/README.md +0 -0
- {datadog_lambda-6.96.0 → datadog_lambda-6.98.0}/datadog_lambda/__init__.py +0 -0
- {datadog_lambda-6.96.0 → datadog_lambda-6.98.0}/datadog_lambda/api.py +0 -0
- {datadog_lambda-6.96.0 → datadog_lambda-6.98.0}/datadog_lambda/cold_start.py +0 -0
- {datadog_lambda-6.96.0 → datadog_lambda-6.98.0}/datadog_lambda/constants.py +0 -0
- {datadog_lambda-6.96.0 → datadog_lambda-6.98.0}/datadog_lambda/dogstatsd.py +0 -0
- {datadog_lambda-6.96.0 → datadog_lambda-6.98.0}/datadog_lambda/extension.py +0 -0
- {datadog_lambda-6.96.0 → datadog_lambda-6.98.0}/datadog_lambda/handler.py +0 -0
- {datadog_lambda-6.96.0 → datadog_lambda-6.98.0}/datadog_lambda/logger.py +0 -0
- {datadog_lambda-6.96.0 → datadog_lambda-6.98.0}/datadog_lambda/module_name.py +0 -0
- {datadog_lambda-6.96.0 → datadog_lambda-6.98.0}/datadog_lambda/patch.py +0 -0
- {datadog_lambda-6.96.0 → datadog_lambda-6.98.0}/datadog_lambda/stats_writer.py +0 -0
- {datadog_lambda-6.96.0 → datadog_lambda-6.98.0}/datadog_lambda/statsd_writer.py +0 -0
- {datadog_lambda-6.96.0 → datadog_lambda-6.98.0}/datadog_lambda/tag_object.py +0 -0
- {datadog_lambda-6.96.0 → datadog_lambda-6.98.0}/datadog_lambda/tags.py +0 -0
- {datadog_lambda-6.96.0 → datadog_lambda-6.98.0}/datadog_lambda/tracing.py +0 -0
- {datadog_lambda-6.96.0 → datadog_lambda-6.98.0}/datadog_lambda/trigger.py +0 -0
- {datadog_lambda-6.96.0 → datadog_lambda-6.98.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.
|
|
3
|
+
Version: 6.98.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
|
|
@@ -16,16 +16,14 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
16
16
|
Classifier: Programming Language :: Python :: 3.11
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.12
|
|
18
18
|
Provides-Extra: dev
|
|
19
|
-
Requires-Dist: boto3 (>=1.
|
|
19
|
+
Requires-Dist: boto3 (>=1.34.0,<2.0.0) ; extra == "dev"
|
|
20
20
|
Requires-Dist: datadog (>=0.41.0,<1.0.0)
|
|
21
|
-
Requires-Dist: ddtrace (>=2.
|
|
21
|
+
Requires-Dist: ddtrace (>=2.10.0)
|
|
22
22
|
Requires-Dist: flake8 (>=5.0.4,<6.0.0) ; extra == "dev"
|
|
23
23
|
Requires-Dist: pytest (>=8.0.0,<9.0.0) ; extra == "dev"
|
|
24
24
|
Requires-Dist: pytest-benchmark (>=4.0,<5.0) ; extra == "dev"
|
|
25
25
|
Requires-Dist: requests (>=2.22.0,<3.0.0) ; extra == "dev"
|
|
26
26
|
Requires-Dist: ujson (>=5.9.0)
|
|
27
|
-
Requires-Dist: urllib3 (<2.0.0) ; python_version < "3.11"
|
|
28
|
-
Requires-Dist: urllib3 (<2.1.0) ; python_version >= "3.11"
|
|
29
27
|
Requires-Dist: wrapt (>=1.11.2,<2.0.0)
|
|
30
28
|
Project-URL: Repository, https://github.com/DataDog/datadog-lambda-python
|
|
31
29
|
Description-Content-Type: text/markdown
|
|
@@ -7,6 +7,7 @@ import os
|
|
|
7
7
|
import time
|
|
8
8
|
import logging
|
|
9
9
|
import ujson as json
|
|
10
|
+
from datetime import datetime, timedelta
|
|
10
11
|
|
|
11
12
|
from datadog_lambda.extension import should_use_extension
|
|
12
13
|
from datadog_lambda.tags import get_enhanced_metrics_tags, dd_lambda_layer_tag
|
|
@@ -61,6 +62,18 @@ def lambda_metric(metric_name, value, timestamp=None, tags=None, force_async=Fal
|
|
|
61
62
|
if should_use_extension and timestamp is not None:
|
|
62
63
|
# The extension does not support timestamps for distributions so we create a
|
|
63
64
|
# a thread stats writer to submit metrics with timestamps to the API
|
|
65
|
+
timestamp_ceiling = int(
|
|
66
|
+
(datetime.now() - timedelta(hours=4)).timestamp()
|
|
67
|
+
) # 4 hours ago
|
|
68
|
+
if isinstance(timestamp, datetime):
|
|
69
|
+
timestamp = int(timestamp.timestamp())
|
|
70
|
+
if timestamp_ceiling > timestamp:
|
|
71
|
+
logger.warning(
|
|
72
|
+
"Timestamp %s is older than 4 hours, not submitting metric %s",
|
|
73
|
+
timestamp,
|
|
74
|
+
metric_name,
|
|
75
|
+
)
|
|
76
|
+
return
|
|
64
77
|
global extension_thread_stats
|
|
65
78
|
if extension_thread_stats is None:
|
|
66
79
|
from datadog_lambda.thread_stats_writer import ThreadStatsWriter
|
|
@@ -108,11 +121,19 @@ def write_metric_point_to_stdout(metric_name, value, timestamp=None, tags=[]):
|
|
|
108
121
|
)
|
|
109
122
|
|
|
110
123
|
|
|
111
|
-
def flush_stats():
|
|
124
|
+
def flush_stats(lambda_context=None):
|
|
112
125
|
lambda_stats.flush()
|
|
113
126
|
|
|
114
127
|
if extension_thread_stats is not None:
|
|
115
|
-
|
|
128
|
+
if lambda_context is not None:
|
|
129
|
+
tags = get_enhanced_metrics_tags(lambda_context)
|
|
130
|
+
split_arn = lambda_context.invoked_function_arn.split(":")
|
|
131
|
+
if len(split_arn) > 7:
|
|
132
|
+
# Get rid of the alias
|
|
133
|
+
split_arn.pop()
|
|
134
|
+
arn = ":".join(split_arn)
|
|
135
|
+
tags.append("function_arn:" + arn)
|
|
136
|
+
extension_thread_stats.flush(tags)
|
|
116
137
|
|
|
117
138
|
|
|
118
139
|
def submit_enhanced_metric(metric_name, lambda_context):
|
|
@@ -22,11 +22,13 @@ class ThreadStatsWriter(StatsWriter):
|
|
|
22
22
|
metric_name, value, tags=tags, timestamp=timestamp
|
|
23
23
|
)
|
|
24
24
|
|
|
25
|
-
def flush(self):
|
|
25
|
+
def flush(self, tags=None):
|
|
26
26
|
""" "Flush distributions from ThreadStats to Datadog.
|
|
27
27
|
Modified based on `datadog.threadstats.base.ThreadStats.flush()`,
|
|
28
28
|
to gain better control over exception handling.
|
|
29
29
|
"""
|
|
30
|
+
if tags:
|
|
31
|
+
self.thread_stats.constant_tags = self.thread_stats.constant_tags + tags
|
|
30
32
|
_, dists = self.thread_stats._get_aggregate_metrics_and_dists(float("inf"))
|
|
31
33
|
count_dists = len(dists)
|
|
32
34
|
if not count_dists:
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "6.98.0"
|
|
@@ -54,6 +54,10 @@ profiling_env_var = os.environ.get("DD_PROFILING_ENABLED", "false").lower() == "
|
|
|
54
54
|
if profiling_env_var:
|
|
55
55
|
from ddtrace.profiling import profiler
|
|
56
56
|
|
|
57
|
+
llmobs_env_var = os.environ.get("DD_LLMOBS_ENABLED", "false").lower() in ("true", "1")
|
|
58
|
+
if llmobs_env_var:
|
|
59
|
+
from ddtrace.llmobs import LLMObs
|
|
60
|
+
|
|
57
61
|
logger = logging.getLogger(__name__)
|
|
58
62
|
|
|
59
63
|
DD_FLUSH_TO_LOG = "DD_FLUSH_TO_LOG"
|
|
@@ -221,6 +225,10 @@ class _LambdaDecorator(object):
|
|
|
221
225
|
# Patch third-party libraries for tracing
|
|
222
226
|
patch_all()
|
|
223
227
|
|
|
228
|
+
# Enable LLM Observability
|
|
229
|
+
if llmobs_env_var:
|
|
230
|
+
LLMObs.enable()
|
|
231
|
+
|
|
224
232
|
logger.debug("datadog_lambda_wrapper initialized")
|
|
225
233
|
except Exception as e:
|
|
226
234
|
logger.error(format_err_with_traceback(e))
|
|
@@ -366,13 +374,16 @@ class _LambdaDecorator(object):
|
|
|
366
374
|
logger.debug("Failed to create cold start spans. %s", e)
|
|
367
375
|
|
|
368
376
|
if not self.flush_to_log or should_use_extension:
|
|
369
|
-
flush_stats()
|
|
377
|
+
flush_stats(context)
|
|
370
378
|
if should_use_extension and self.local_testing_mode:
|
|
371
379
|
# when testing locally, the extension does not know when an
|
|
372
380
|
# invocation completes because it does not have access to the
|
|
373
381
|
# logs api
|
|
374
382
|
flush_extension()
|
|
375
383
|
|
|
384
|
+
if llmobs_env_var:
|
|
385
|
+
LLMObs.flush()
|
|
386
|
+
|
|
376
387
|
if self.encode_authorizer_context and is_authorizer_response(self.response):
|
|
377
388
|
self._inject_authorizer_span_headers(
|
|
378
389
|
event.get("requestContext", {}).get("requestId")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "datadog_lambda"
|
|
3
|
-
version = "6.
|
|
3
|
+
version = "6.98.0"
|
|
4
4
|
description = "The Datadog AWS Lambda Library"
|
|
5
5
|
authors = ["Datadog, Inc. <dev@datadoghq.com>"]
|
|
6
6
|
license = "Apache-2.0"
|
|
@@ -27,19 +27,14 @@ classifiers = [
|
|
|
27
27
|
python = ">=3.8.0,<4"
|
|
28
28
|
datadog = ">=0.41.0,<1.0.0"
|
|
29
29
|
wrapt = "^1.11.2"
|
|
30
|
-
ddtrace = ">=2.
|
|
30
|
+
ddtrace = ">=2.10.0"
|
|
31
31
|
ujson = ">=5.9.0"
|
|
32
|
-
|
|
33
|
-
{version = "<2.0.0", python = "<3.11", optional = true},
|
|
34
|
-
{version = "<2.1.0", python = ">=3.11", optional = true},
|
|
35
|
-
]
|
|
36
|
-
boto3 = { version = "^1.28.0", optional = true }
|
|
32
|
+
boto3 = { version = "^1.34.0", optional = true }
|
|
37
33
|
requests = { version ="^2.22.0", optional = true }
|
|
38
34
|
pytest = { version= "^8.0.0", optional = true }
|
|
39
35
|
pytest-benchmark = { version = "^4.0", optional = true }
|
|
40
36
|
flake8 = { version = "^5.0.4", optional = true }
|
|
41
37
|
|
|
42
|
-
|
|
43
38
|
[tool.poetry.extras]
|
|
44
39
|
dev = [
|
|
45
40
|
"boto3",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "6.96.0"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|