Skip to content

Commit dba8e5b

Browse files
committed
Merge branch 'main' into aj/drop37-from-build
2 parents 3a11383 + 5d90a9a commit dba8e5b

19 files changed

+3487
-149
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
strategy:
4242
max-parallel: 4
4343
matrix:
44-
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
44+
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
4545

4646
steps:
4747
- name: Checkout
@@ -68,7 +68,7 @@ jobs:
6868
runs-on: ubuntu-latest
6969
strategy:
7070
matrix:
71-
runtime-param: ['3.7', '3.8', '3.9', '3.10', '3.11']
71+
runtime-param: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
7272
steps:
7373
- name: Checkout
7474
uses: actions/checkout@v3

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[![Slack](https://chat.datadoghq.com/badge.svg?bg=632CA6)](https://chat.datadoghq.com/)
77
[![License](https://img.shields.io/badge/license-Apache--2.0-blue)](https://github.com/DataDog/datadog-lambda-python/blob/main/LICENSE)
88

9-
Datadog Lambda Library for Python (3.7, 3.8, 3.9, 3.10, and 3.11) 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.7, 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.
1010

1111
## Installation
1212

datadog_lambda/tracing.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ def extract_context_from_sqs_or_sns_event_or_context(event, lambda_context):
266266
"Datadog Lambda Python only supports extracting trace"
267267
"context from String or Binary SQS/SNS message attributes"
268268
)
269+
return extract_context_from_lambda_context(lambda_context)
269270
dd_data = json.loads(dd_json_data)
270271
return propagator.extract(dd_data)
271272
except Exception as e:
@@ -568,9 +569,8 @@ def inject_correlation_ids():
568569
# Override the log format of the AWS provided LambdaLoggerHandler
569570
root_logger = logging.getLogger()
570571
for handler in root_logger.handlers:
571-
if (
572-
handler.__class__.__name__ == "LambdaLoggerHandler"
573-
and type(handler.formatter) == logging.Formatter
572+
if handler.__class__.__name__ == "LambdaLoggerHandler" and isinstance(
573+
handler.formatter, logging.Formatter
574574
):
575575
handler.setFormatter(
576576
logging.Formatter(
@@ -603,7 +603,7 @@ def set_dd_trace_py_root(trace_context_source, merge_xray_traces):
603603
)
604604
if merge_xray_traces:
605605
xray_context = _get_xray_trace_context()
606-
if xray_context.span_id:
606+
if xray_context and xray_context.span_id:
607607
context.span_id = xray_context.span_id
608608

609609
tracer.context_provider.activate(context)

datadog_lambda/wrapper.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,12 @@ def _before(self, event, context):
281281
# Create a Datadog X-Ray subsegment with the trace context
282282
if dd_context and trace_context_source == TraceContextSource.EVENT:
283283
create_dd_dummy_metadata_subsegment(
284-
dd_context, XraySubsegment.TRACE_KEY
284+
{
285+
"trace-id": str(dd_context.trace_id),
286+
"parent-id": str(dd_context.span_id),
287+
"sampling-priority": str(dd_context.sampling_priority),
288+
},
289+
XraySubsegment.TRACE_KEY,
285290
)
286291

287292
if dd_tracing_enabled:

poetry.lock

Lines changed: 75 additions & 75 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "datadog_lambda"
3-
version = "4.82.0"
3+
version = "5.85.0"
44
description = "The Datadog AWS Lambda Library"
55
authors = ["Datadog, Inc. <dev@datadoghq.com>"]
66
license = "Apache-2.0"
@@ -21,13 +21,14 @@ classifiers = [
2121
"Programming Language :: Python :: 3.9",
2222
"Programming Language :: Python :: 3.10",
2323
"Programming Language :: Python :: 3.11",
24+
"Programming Language :: Python :: 3.12",
2425
]
2526

2627
[tool.poetry.dependencies]
2728
python = ">=3.7.0,<4"
2829
datadog = ">=0.41.0,<1.0.0"
2930
wrapt = "^1.11.2"
30-
ddtrace = ">=2.3.0"
31+
ddtrace = ">=2.3.1"
3132
urllib3 = [
3233
{version = "<2.0.0", python = "<3.11", optional = true},
3334
{version = "<2.1.0", python = ">=3.11", optional = true},
@@ -37,8 +38,7 @@ boto3 = { version = "^1.28.0", optional = true }
3738
typing_extensions = {version = "^4.0", python = "<3.8"}
3839
requests = { version ="^2.22.0", optional = true }
3940
nose2 = { version= "^0.9.1", optional = true }
40-
flake8 = { version = "^3.7.9", optional = true }
41-
httpretty = {version = "^0.9.7", optional = true }
41+
flake8 = { version = "^5.0.4", optional = true }
4242

4343

4444
[tool.poetry.extras]
@@ -47,7 +47,6 @@ dev = [
4747
"requests",
4848
"nose2",
4949
"flake8",
50-
"httpretty",
5150
]
5251

5352
[build-system]

scripts/add_new_region.sh

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,32 @@ set -e
1212

1313
OLD_REGION='us-east-1'
1414

15-
LAYER_NAMES=("Datadog-Python37" "Datadog-Python38" "Datadog-Python38-ARM" "Datadog-Python39" "Datadog-Python39-ARM" "Datadog-Python310" "Datadog-Python310-ARM" "Datadog-Python311" "Datadog-Python311-ARM")
16-
PYTHON_VERSIONS_FOR_AWS_CLI=("python3.7" "python3.8" "python3.8" "python3.9" "python3.9" "python3.10" "python3.10" "python3.11" "python3.11")
15+
LAYER_NAMES=(
16+
"Datadog-Python37"
17+
"Datadog-Python38"
18+
"Datadog-Python38-ARM"
19+
"Datadog-Python39"
20+
"Datadog-Python39-ARM"
21+
"Datadog-Python310"
22+
"Datadog-Python310-ARM"
23+
"Datadog-Python311"
24+
"Datadog-Python311-ARM"
25+
"Datadog-Python312"
26+
"Datadog-Python312-ARM"
27+
)
28+
PYTHON_VERSIONS_FOR_AWS_CLI=(
29+
"python3.7"
30+
"python3.8"
31+
"python3.8"
32+
"python3.9"
33+
"python3.9"
34+
"python3.10"
35+
"python3.10"
36+
"python3.11"
37+
"python3.11"
38+
"python3.12"
39+
"python3.12"
40+
)
1741
NEW_REGION=$1
1842

1943
publish_layer() {

scripts/build_layers.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ set -e
1414

1515
LAYER_DIR=".layers"
1616
LAYER_FILES_PREFIX="datadog_lambda_py"
17-
AVAILABLE_PYTHON_VERSIONS=("3.8" "3.9" "3.10" "3.11")
17+
AVAILABLE_PYTHON_VERSIONS=("3.8" "3.9" "3.10" "3.11" "3.12")
1818

1919
# Determine which Python versions to build layers for
2020
if [ -z "$PYTHON_VERSION" ]; then

scripts/check_layer_size.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ MAX_LAYER_UNCOMPRESSED_SIZE_KB=$(expr 24 \* 1024)
1414

1515
LAYER_FILES_PREFIX="datadog_lambda_py"
1616
LAYER_DIR=".layers"
17-
VERSIONS=("3.7" "3.8" "3.9" "3.10" "3.11")
17+
VERSIONS=("3.7" "3.8" "3.9" "3.10" "3.11" "3.12")
1818

1919
for version in "${VERSIONS[@]}"
2020
do

scripts/list_layers.sh

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,19 @@
1010

1111
set -e
1212

13-
LAYER_NAMES=("Datadog-Python37" "Datadog-Python38" "Datadog-Python38-ARM" "Datadog-Python39" "Datadog-Python39-ARM" "Datadog-Python310" "Datadog-Python310-ARM" "Datadog-Python311" "Datadog-Python311-ARM")
13+
LAYER_NAMES=(
14+
"Datadog-Python37"
15+
"Datadog-Python38"
16+
"Datadog-Python38-ARM"
17+
"Datadog-Python39"
18+
"Datadog-Python39-ARM"
19+
"Datadog-Python310"
20+
"Datadog-Python310-ARM"
21+
"Datadog-Python311"
22+
"Datadog-Python311-ARM"
23+
"Datadog-Python312"
24+
"Datadog-Python312-ARM"
25+
)
1426
AVAILABLE_REGIONS=$(aws ec2 describe-regions | jq -r '.[] | .[] | .RegionName')
1527
LAYERS_MISSING_REGIONS=()
1628

scripts/publish_layers.sh

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,45 @@ set -e
1313
# Makes sure any subprocesses will be terminated with this process
1414
trap "pkill -P $$; exit 1;" INT
1515

16-
PYTHON_VERSIONS_FOR_AWS_CLI=("python3.7" "python3.8" "python3.8" "python3.9" "python3.9" "python3.10" "python3.10" "python3.11" "python3.11")
17-
LAYER_PATHS=(".layers/datadog_lambda_py-amd64-3.7.zip" ".layers/datadog_lambda_py-amd64-3.8.zip" ".layers/datadog_lambda_py-arm64-3.8.zip" ".layers/datadog_lambda_py-amd64-3.9.zip" ".layers/datadog_lambda_py-arm64-3.9.zip" ".layers/datadog_lambda_py-amd64-3.10.zip" ".layers/datadog_lambda_py-arm64-3.10.zip" ".layers/datadog_lambda_py-amd64-3.11.zip" ".layers/datadog_lambda_py-arm64-3.11.zip")
18-
AVAILABLE_LAYERS=("Datadog-Python37" "Datadog-Python38" "Datadog-Python38-ARM" "Datadog-Python39" "Datadog-Python39-ARM" "Datadog-Python310" "Datadog-Python310-ARM" "Datadog-Python311" "Datadog-Python311-ARM")
19-
ARCHS=("amd64" "amd64" "amd64""amd64" "amd64" "arm64" "amd64" "arm64" "amd64" "arm64")
16+
PYTHON_VERSIONS_FOR_AWS_CLI=(
17+
"python3.7"
18+
"python3.8"
19+
"python3.8"
20+
"python3.9"
21+
"python3.9"
22+
"python3.10"
23+
"python3.10"
24+
"python3.11"
25+
"python3.11"
26+
"python3.12"
27+
"python3.12"
28+
)
29+
LAYER_PATHS=(
30+
".layers/datadog_lambda_py-amd64-3.7.zip"
31+
".layers/datadog_lambda_py-amd64-3.8.zip"
32+
".layers/datadog_lambda_py-arm64-3.8.zip"
33+
".layers/datadog_lambda_py-amd64-3.9.zip"
34+
".layers/datadog_lambda_py-arm64-3.9.zip"
35+
".layers/datadog_lambda_py-amd64-3.10.zip"
36+
".layers/datadog_lambda_py-arm64-3.10.zip"
37+
".layers/datadog_lambda_py-amd64-3.11.zip"
38+
".layers/datadog_lambda_py-arm64-3.11.zip"
39+
".layers/datadog_lambda_py-amd64-3.12.zip"
40+
".layers/datadog_lambda_py-arm64-3.12.zip"
41+
)
42+
AVAILABLE_LAYERS=(
43+
"Datadog-Python37"
44+
"Datadog-Python38"
45+
"Datadog-Python38-ARM"
46+
"Datadog-Python39"
47+
"Datadog-Python39-ARM"
48+
"Datadog-Python310"
49+
"Datadog-Python310-ARM"
50+
"Datadog-Python311"
51+
"Datadog-Python311-ARM"
52+
"Datadog-Python312"
53+
"Datadog-Python312-ARM"
54+
)
2055
AVAILABLE_REGIONS=$(aws ec2 describe-regions | jq -r '.[] | .[] | .RegionName')
2156

2257
BATCH_SIZE=60

scripts/run_integration_tests.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ set -e
1111
# These values need to be in sync with serverless.yml, where there needs to be a function
1212
# defined for every handler_runtime combination
1313
LAMBDA_HANDLERS=("async-metrics" "sync-metrics")
14-
RUNTIMES=("python38" "python39" "python310" "python311")
1514

1615
LOGS_WAIT_SECONDS=20
1716

@@ -32,8 +31,9 @@ python38=("python3.8" "3.8" $(xxd -l 4 -c 4 -p < /dev/random))
3231
python39=("python3.9" "3.9" $(xxd -l 4 -c 4 -p < /dev/random))
3332
python310=("python3.10" "3.10" $(xxd -l 4 -c 4 -p < /dev/random))
3433
python311=("python3.11" "3.11" $(xxd -l 4 -c 4 -p < /dev/random))
34+
python312=("python3.12" "3.12" $(xxd -l 4 -c 4 -p < /dev/random))
3535

36-
PARAMETERS_SETS=("python38" "python39" "python310" "python311")
36+
PARAMETERS_SETS=("python38" "python39" "python310" "python311" "python312")
3737

3838
if [ -z "$RUNTIME_PARAM" ]; then
3939
echo "Python version not specified, running for all python versions."

scripts/run_tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# Run unit tests in Docker
99
set -e
1010

11-
PYTHON_VERSIONS=("3.7" "3.8" "3.9" "3.10" "3.11")
11+
PYTHON_VERSIONS=("3.7" "3.8" "3.9" "3.10" "3.11" "3.12")
1212

1313
for python_version in "${PYTHON_VERSIONS[@]}"
1414
do

scripts/sign_layers.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ LAYER_FILES=(
1717
"datadog_lambda_py-arm64-3.10.zip"
1818
"datadog_lambda_py-amd64-3.11.zip"
1919
"datadog_lambda_py-arm64-3.11.zip"
20+
"datadog_lambda_py-amd64-3.12.zip"
21+
"datadog_lambda_py-arm64-3.12.zip"
2022
)
2123
SIGNING_PROFILE_NAME="DatadogLambdaSigningProfile"
2224

0 commit comments

Comments
 (0)