Skip to content

Commit d5c30e2

Browse files
authored
Merge branch 'main' into avara1986/APPSEC-60046_remove_more_iast_files
2 parents 104870b + ed75966 commit d5c30e2

25 files changed

+3755
-46
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
strategy:
4444
max-parallel: 4
4545
matrix:
46-
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
46+
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13', '3.14']
4747

4848
steps:
4949
- name: Checkout

.github/workflows/build_layer.yml

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,80 @@ name: Build Layers for system-Tests
22

33
on:
44
workflow_dispatch:
5+
pull_request:
56
push:
67
branches:
78
- "main"
89

910
jobs:
11+
get-ddtrace-run-id:
12+
runs-on: ubuntu-latest
13+
outputs:
14+
run-id: ${{ steps.get-ddtrace-run-id.outputs.run_id }}
15+
steps:
16+
- name: Resolve Run ID of latest dd-trace-py build
17+
id: get-ddtrace-run-id
18+
env:
19+
GH_TOKEN: ${{ github.token }}
20+
run: |
21+
RUN_ID=$(gh run list \
22+
--repo DataDog/dd-trace-py \
23+
--workflow build_deploy.yml \
24+
--branch main \
25+
--status success \
26+
--limit 1 \
27+
--json databaseId \
28+
--jq '.[0].databaseId')
29+
30+
echo "run_id=$RUN_ID" >> $GITHUB_OUTPUT
31+
1032
build:
1133
runs-on: ${{ matrix.arch == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
1234

35+
needs: get-ddtrace-run-id
36+
1337
strategy:
1438
fail-fast: false
1539
matrix:
1640
arch: [arm64, amd64]
17-
python_version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
41+
python_version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
1842

1943
steps:
2044
- name: Checkout
2145
uses: actions/checkout@v4
2246

47+
- name: Build artifact name
48+
id: build-artifact-name
49+
run: |
50+
if [ "${{ matrix.arch }}" == "amd64" ]; then
51+
ARCH="x86_64"
52+
else
53+
ARCH="aarch64"
54+
fi
55+
56+
VER="${{ matrix.python_version }}"
57+
PY_VERSION_NO_DOT="${VER//./}"
58+
59+
echo "artifact_name=wheels-cp${PY_VERSION_NO_DOT}-manylinux_${ARCH}" >> $GITHUB_OUTPUT
60+
61+
- name: Download ddtrace Wheel
62+
uses: actions/download-artifact@v4
63+
with:
64+
name: ${{ steps.build-artifact-name.outputs.artifact_name }}
65+
repository: DataDog/dd-trace-py
66+
run-id: ${{ needs.get-ddtrace-run-id.outputs.run-id }}
67+
github-token: ${{ secrets.GITHUB_TOKEN }}
68+
path: ./artifacts
69+
70+
- name: Find ddtrace Wheel
71+
id: find-ddtrace-wheel
72+
run: |
73+
echo "wheel_path=$(find ./artifacts -name "*.whl" | head -n 1)" >> $GITHUB_OUTPUT
74+
2375
- name: Patch pyproject.toml
2476
run: |
25-
echo "Patching pyproject.toml to use main branch of dd-trace-py"
26-
sed -i 's|^ddtrace =.*$|ddtrace = { git = "https://github.com/DataDog/dd-trace-py.git" }|' pyproject.toml
77+
echo "Patching pyproject.toml to use latest build of dd-trace-py"
78+
sed -i 's|^ddtrace =.*$|ddtrace = { file = "${{ steps.find-ddtrace-wheel.outputs.wheel_path }}" }|' pyproject.toml
2779
2880
- name: Build layer for Python ${{ matrix.python_version }} on ${{ matrix.arch }}
2981
run: |

.github/workflows/update-snapshots.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
name: update-snapshots
22

33
on:
4-
schedule:
5-
- cron: "0 15 * * *" # every day 11am EST
4+
workflow_dispatch:
65

76
jobs:
87
check:
@@ -47,8 +46,19 @@ jobs:
4746
working-directory: tests/integration
4847
run: yarn install
4948

50-
- name: Update Snapshots
49+
- name: Update Snapshots (amd64)
5150
env:
51+
ARCH: amd64
52+
UPDATE_SNAPSHOTS: true
53+
BUILD_LAYERS: true
54+
DD_API_KEY: ${{ secrets.DD_API_KEY }}
55+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
56+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
57+
run: ./scripts/run_integration_tests.sh
58+
59+
- name: Update Snapshots (arm64)
60+
env:
61+
ARCH: arm64
5262
UPDATE_SNAPSHOTS: true
5363
BUILD_LAYERS: true
5464
DD_API_KEY: ${{ secrets.DD_API_KEY }}

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ RUN set -eux; \
1515
rm gcc && ln -s gcc10-gcc gcc; \
1616
rm g++ && ln -s gcc10-g++ g++; \
1717
rm cc && ln -s gcc10-cc cc; \
18+
rm c++ && ln -s gcc10-c++ c++; \
1819
fi
1920

2021
# Add Rust compiler which is needed to build dd-trace-py from source

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.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.
9+
Datadog Lambda Library for Python (3.8, 3.9, 3.10, 3.11, 3.12, 3.13, and 3.14) 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

ci/datasources/runtimes.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,11 @@ runtimes:
4747
python_version: "3.13"
4848
arch: "arm64"
4949
image: "3.13.0"
50+
- name: "python314"
51+
python_version: "3.14"
52+
arch: "amd64"
53+
image: "3.14.0"
54+
- name: "python314"
55+
python_version: "3.14"
56+
arch: "arm64"
57+
image: "3.14.0"

ci/publish_layers.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ AWS_CLI_PYTHON_VERSIONS=(
2323
"python3.12"
2424
"python3.13"
2525
"python3.13"
26+
"python3.14"
27+
"python3.14"
2628
)
2729
PYTHON_VERSIONS=(
2830
"3.8-amd64"
@@ -37,6 +39,8 @@ PYTHON_VERSIONS=(
3739
"3.12-arm64"
3840
"3.13-amd64"
3941
"3.13-arm64"
42+
"3.14-amd64"
43+
"3.14-arm64"
4044
)
4145
LAYER_PATHS=(
4246
".layers/datadog_lambda_py-amd64-3.8.zip"
@@ -51,6 +55,8 @@ LAYER_PATHS=(
5155
".layers/datadog_lambda_py-arm64-3.12.zip"
5256
".layers/datadog_lambda_py-amd64-3.13.zip"
5357
".layers/datadog_lambda_py-arm64-3.13.zip"
58+
".layers/datadog_lambda_py-amd64-3.14.zip"
59+
".layers/datadog_lambda_py-arm64-3.14.zip"
5460
)
5561
LAYERS=(
5662
"Datadog-Python38"
@@ -65,6 +71,8 @@ LAYERS=(
6571
"Datadog-Python312-ARM"
6672
"Datadog-Python313"
6773
"Datadog-Python313-ARM"
74+
"Datadog-Python314"
75+
"Datadog-Python314-ARM"
6876
)
6977
STAGES=('prod', 'sandbox', 'staging', 'gov-staging', 'gov-prod')
7078

datadog_lambda/api.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
55

66
logger = logging.getLogger(__name__)
77
KMS_ENCRYPTION_CONTEXT_KEY = "LambdaFunctionName"
8+
SSM_FIPS_SUPPORTED_REGIONS = {
9+
"us-east-1",
10+
"us-east-2",
11+
"us-west-1",
12+
"us-west-2",
13+
"ca-central-1",
14+
"ca-west-1",
15+
}
816
api_key = None
917

1018

@@ -92,11 +100,18 @@ def get_api_key() -> str:
92100
)["SecretString"]
93101
elif DD_API_KEY_SSM_NAME:
94102
# SSM endpoints: https://docs.aws.amazon.com/general/latest/gr/ssm.html
95-
fips_endpoint = (
96-
f"https://ssm-fips.{LAMBDA_REGION}.amazonaws.com"
97-
if config.fips_mode_enabled
98-
else None
99-
)
103+
fips_endpoint = None
104+
if config.fips_mode_enabled:
105+
if LAMBDA_REGION in SSM_FIPS_SUPPORTED_REGIONS:
106+
fips_endpoint = f"https://ssm-fips.{LAMBDA_REGION}.amazonaws.com"
107+
else:
108+
# Log warning if SSM FIPS endpoint is not supported for commercial region
109+
if not config.is_gov_region:
110+
logger.warning(
111+
"FIPS mode is enabled, but '%s' does not support SSM FIPS endpoints. "
112+
"Using standard SSM endpoint.",
113+
LAMBDA_REGION,
114+
)
100115
ssm_client = _boto3_client("ssm", endpoint_url=fips_endpoint)
101116
api_key = ssm_client.get_parameter(
102117
Name=DD_API_KEY_SSM_NAME, WithDecryption=True

datadog_lambda/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "8.118.0.dev0"
1+
__version__ = "8.119.0"

datadog_lambda/wrapper.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
extract_http_status_code_tag,
4747
)
4848

49+
logger = logging.getLogger(__name__)
50+
4951
# ddtrace imports are also tested in
5052
# dd-trace-py/tests/internal/test_serverless.py please update those tests when
5153
# making changes to any ddtrace import.
@@ -61,8 +63,12 @@
6163

6264
start()
6365

66+
profiler = None
6467
if config.profiling_enabled:
65-
from ddtrace.profiling import profiler
68+
try:
69+
from ddtrace.profiling import profiler
70+
except Exception as e:
71+
logger.error(f"Failed to initialize profiler: [{e.__class__.__name__})] {e}")
6672

6773
if config.llmobs_enabled:
6874
from ddtrace.llmobs import LLMObs
@@ -75,8 +81,6 @@
7581
except ImportError:
7682
from ddtrace.debugging._uploader import LogsIntakeUploaderV1 as SignalUploader
7783

78-
logger = logging.getLogger(__name__)
79-
8084
DD_REQUESTS_SERVICE_NAME = "DD_REQUESTS_SERVICE_NAME"
8185
DD_SERVICE = "DD_SERVICE"
8286

@@ -141,7 +145,7 @@ def __init__(self, func):
141145
self.response = None
142146
self.blocking_response = None
143147

144-
if config.profiling_enabled:
148+
if config.profiling_enabled and profiler:
145149
self.prof = profiler.Profiler(env=config.env, service=config.service)
146150

147151
if config.trace_extractor:
@@ -283,7 +287,7 @@ def _before(self, event, context):
283287
self.blocking_response = get_asm_blocked_response(self.event_source)
284288
else:
285289
set_correlation_ids()
286-
if config.profiling_enabled and is_new_sandbox():
290+
if config.profiling_enabled and profiler and is_new_sandbox():
287291
self.prof.start(stop_on_exit=False, profile_children=True)
288292
logger.debug("datadog_lambda_wrapper _before() done")
289293
except Exception as e:

0 commit comments

Comments
 (0)