datadog_lambda 6.95.0__py3-none-any.whl → 6.97.0__py3-none-any.whl
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/metric.py +21 -2
- datadog_lambda/thread_stats_writer.py +3 -1
- datadog_lambda/version.py +1 -1
- datadog_lambda/wrapper.py +12 -1
- {datadog_lambda-6.95.0.dist-info → datadog_lambda-6.97.0.dist-info}/METADATA +5 -2
- {datadog_lambda-6.95.0.dist-info → datadog_lambda-6.97.0.dist-info}/RECORD +10 -10
- {datadog_lambda-6.95.0.dist-info → datadog_lambda-6.97.0.dist-info}/LICENSE +0 -0
- {datadog_lambda-6.95.0.dist-info → datadog_lambda-6.97.0.dist-info}/LICENSE-3rdparty.csv +0 -0
- {datadog_lambda-6.95.0.dist-info → datadog_lambda-6.97.0.dist-info}/NOTICE +0 -0
- {datadog_lambda-6.95.0.dist-info → datadog_lambda-6.97.0.dist-info}/WHEEL +0 -0
datadog_lambda/metric.py
CHANGED
|
@@ -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,16 @@ 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 timestamp_ceiling > timestamp:
|
|
69
|
+
logger.warning(
|
|
70
|
+
"Timestamp %s is older than 4 hours, not submitting metric %s",
|
|
71
|
+
timestamp,
|
|
72
|
+
metric_name,
|
|
73
|
+
)
|
|
74
|
+
return
|
|
64
75
|
global extension_thread_stats
|
|
65
76
|
if extension_thread_stats is None:
|
|
66
77
|
from datadog_lambda.thread_stats_writer import ThreadStatsWriter
|
|
@@ -108,11 +119,19 @@ def write_metric_point_to_stdout(metric_name, value, timestamp=None, tags=[]):
|
|
|
108
119
|
)
|
|
109
120
|
|
|
110
121
|
|
|
111
|
-
def flush_stats():
|
|
122
|
+
def flush_stats(lambda_context=None):
|
|
112
123
|
lambda_stats.flush()
|
|
113
124
|
|
|
114
125
|
if extension_thread_stats is not None:
|
|
115
|
-
|
|
126
|
+
if lambda_context is not None:
|
|
127
|
+
tags = get_enhanced_metrics_tags(lambda_context)
|
|
128
|
+
split_arn = lambda_context.invoked_function_arn.split(":")
|
|
129
|
+
if len(split_arn) > 7:
|
|
130
|
+
# Get rid of the alias
|
|
131
|
+
split_arn.pop()
|
|
132
|
+
arn = ":".join(split_arn)
|
|
133
|
+
tags.append("function_arn:" + arn)
|
|
134
|
+
extension_thread_stats.flush(tags)
|
|
116
135
|
|
|
117
136
|
|
|
118
137
|
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:
|
datadog_lambda/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "6.
|
|
1
|
+
__version__ = "6.97.0"
|
datadog_lambda/wrapper.py
CHANGED
|
@@ -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
|
Metadata-Version: 2.1
|
|
2
2
|
Name: datadog_lambda
|
|
3
|
-
Version: 6.
|
|
3
|
+
Version: 6.97.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,7 +18,7 @@ Classifier: Programming Language :: Python :: 3.12
|
|
|
18
18
|
Provides-Extra: dev
|
|
19
19
|
Requires-Dist: boto3 (>=1.28.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.9.2)
|
|
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"
|
|
@@ -79,6 +79,9 @@ The Continuous Profiler works by spawning a thread which periodically wakes up a
|
|
|
79
79
|
|
|
80
80
|
## Major Version Notes
|
|
81
81
|
|
|
82
|
+
### 6.x / Layer version 95+
|
|
83
|
+
- The release changed how Lambda's traceID is hashed if the incoming payload contains Step Functions context object. This change only affects those who uses inject Step Functions context object into Lambda payload.
|
|
84
|
+
|
|
82
85
|
### 5.x / Layer version 86+
|
|
83
86
|
- Python3.7 support has been [deprecated](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html) by AWS, and support removed from this library.
|
|
84
87
|
|
|
@@ -6,22 +6,22 @@ datadog_lambda/dogstatsd.py,sha256=HCyl72oQUSF3E4y1ivrHaGTHL9WG1asGjB1Xo2D_Abc,4
|
|
|
6
6
|
datadog_lambda/extension.py,sha256=ZU64QpA2K9K9C0jfqusBgpiWQe0QA2dcJCNk7UgjVfw,621
|
|
7
7
|
datadog_lambda/handler.py,sha256=YuReCUXLyJCNTeRP_VgWzjCqUl6K6IRs_PU6RHm0VeE,1351
|
|
8
8
|
datadog_lambda/logger.py,sha256=nGxNMouF7wcjmoPsgivzzjNLvSy3WbGtKElxOvITZDg,766
|
|
9
|
-
datadog_lambda/metric.py,sha256=
|
|
9
|
+
datadog_lambda/metric.py,sha256=L0fvvE5ZlHEY5etqCFUajMT3Ix-Y8W7n88WPlTqD_a0,6161
|
|
10
10
|
datadog_lambda/module_name.py,sha256=5FmOCjjgjq78b6a83QePZZFmqahAoy9XHdUNWdq2D1Q,139
|
|
11
11
|
datadog_lambda/patch.py,sha256=6a-BqovSRKsU5hTQpzxgY-_bducT-UEVCLvd3fdxeWc,4710
|
|
12
12
|
datadog_lambda/stats_writer.py,sha256=SIac96wu45AxDOZ4GraCbK3r1RKr4AFgXcEPHg1VX0A,243
|
|
13
13
|
datadog_lambda/statsd_writer.py,sha256=F4SCJ6-J6YfvQNh0uQfAkP6QYiAtV3-MCsxz4QnaBBI,403
|
|
14
14
|
datadog_lambda/tag_object.py,sha256=cZ7W9Ae5k3YxLOZzN5Hu8UqvOKtq5AWARele0L18Gjs,2091
|
|
15
15
|
datadog_lambda/tags.py,sha256=wy6uH8eAGMn7cfZEdHpL9uEGoM85bVyyXhYwSQtfHHc,2532
|
|
16
|
-
datadog_lambda/thread_stats_writer.py,sha256=
|
|
16
|
+
datadog_lambda/thread_stats_writer.py,sha256=I_jNCiUFYaZT25d6hOe_uoG2PTw7J-Fqa3xclbRAkAo,2635
|
|
17
17
|
datadog_lambda/tracing.py,sha256=KYDWgxJLNmNoFKMzGnzRMNXEgFah7K5xtMTXfrWY6c8,49651
|
|
18
18
|
datadog_lambda/trigger.py,sha256=JK5am_XmEvueuLKrrF7k08sWnZVDOD6QvQjrsUJx1dM,12177
|
|
19
|
-
datadog_lambda/version.py,sha256=
|
|
20
|
-
datadog_lambda/wrapper.py,sha256
|
|
19
|
+
datadog_lambda/version.py,sha256=j5n_N9_Tuxka8TmlO8Y6CBIUIVWNeC7vrBSsKM0eX98,23
|
|
20
|
+
datadog_lambda/wrapper.py,sha256=-wTyQJe-dQ1tajo7Rl5rjzZTcEK0N6aNrCYBBFjkXoU,15590
|
|
21
21
|
datadog_lambda/xray.py,sha256=jvA4Fk76PLMgsjUoUZ7gp2otv53hFt39Nvso1ZNaivg,3749
|
|
22
|
-
datadog_lambda-6.
|
|
23
|
-
datadog_lambda-6.
|
|
24
|
-
datadog_lambda-6.
|
|
25
|
-
datadog_lambda-6.
|
|
26
|
-
datadog_lambda-6.
|
|
27
|
-
datadog_lambda-6.
|
|
22
|
+
datadog_lambda-6.97.0.dist-info/LICENSE,sha256=4yQmjpKp1MKL7DdRDPVHkKYc2W0aezm5SIDske8oAdM,11379
|
|
23
|
+
datadog_lambda-6.97.0.dist-info/LICENSE-3rdparty.csv,sha256=9CDAR1GKawwTbZkqt1RP0uwEcaRM3RhOeTB5tWXr8Ts,1381
|
|
24
|
+
datadog_lambda-6.97.0.dist-info/METADATA,sha256=bpQEhFt5GCoPLAhxrZolXT-DBSjVQ18KgZvCcBdDuPA,7533
|
|
25
|
+
datadog_lambda-6.97.0.dist-info/NOTICE,sha256=Jue-d8mQ1ENIHDZdYc2-X8mVYtScXb8pzF1pTLN-kRc,141
|
|
26
|
+
datadog_lambda-6.97.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
27
|
+
datadog_lambda-6.97.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|