Skip to content

Commit e83aa70

Browse files
Merge remote-tracking branch 'origin/master' into zach.montoya/metrics-optimizations
2 parents 50a0696 + c14d19f commit e83aa70

27 files changed

+483
-104
lines changed

.azure-pipelines/ultimate-pipeline.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2777,6 +2777,7 @@ stages:
27772777
useNativeSdkVersion: $(useNativeSdkVersion)
27782778
command: "BuildProfilerSamples"
27792779
apiKey: $(DD_LOGGER_DD_API_KEY)
2780+
retryCountForRunCommand: 3
27802781

27812782
- template: steps/run-in-docker.yml
27822783
parameters:
@@ -2785,6 +2786,7 @@ stages:
27852786
command: "BuildAndRunProfilerCpuLimitTests"
27862787
extraArgs: "--cpus 2 --env CONTAINER_CPUS=1"
27872788
apiKey: $(DD_LOGGER_DD_API_KEY)
2789+
retryCountForRunCommand: 3
27882790

27892791
- template: steps/run-in-docker.yml
27902792
parameters:
@@ -2793,6 +2795,7 @@ stages:
27932795
command: "BuildAndRunProfilerCpuLimitTests"
27942796
extraArgs: "--cpus 0.5 --env CONTAINER_CPUS=0.5"
27952797
apiKey: $(DD_LOGGER_DD_API_KEY)
2798+
retryCountForRunCommand: 3
27962799

27972800
- script: |
27982801
docker-compose -f docker-compose.yml -p $(DockerComposeProjectName) \
@@ -4238,6 +4241,10 @@ stages:
42384241
echo "Label 'docker_image_artifacts' not found in PR — skipping Docker image build"
42394242
exit 0
42404243
fi
4244+
if ! [[ $BRANCH_NAME =~ ^[A-Za-z0-9._/-]+$ ]]; then
4245+
echo "Exiting - Manages branches only if they contain letters, numbers and the following special characters: . - _ /"
4246+
exit 1
4247+
fi
42414248
fi
42424249
42434250
echo "Creating dispatch event for https://github.com/DataDog/dd-trace-dotnet/actions/workflows/create-system-test-docker-base-images.yml with ref=$REF and azdo_build_id=$(Build.BuildId) and is_release_version=False"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
issuer: https://gitlab.ddbuild.io
2+
3+
subject_pattern: "project_path:DataDog/apm-reliability/dd-trace-dotnet:ref_type:(branch|tag):ref:.*"
4+
5+
permissions:
6+
contents: read

.gitlab/benchmarks/macrobenchmarks.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,13 @@ profiler_cpu_timer_create-arm64:
467467
- platform/artifacts/
468468
expire_in: 3 months
469469
variables:
470+
AWS_REGION: "us-east-1"
471+
472+
# Branch containing 1. scripts to launch Windows benchmarks on ephemeral
473+
# instances (to be used by GitLab CI runners) and 2. scripts to run Windows
474+
# benchmarks (to be used by the ephemeral instances).
475+
BP_INFRA_BENCHMARKING_PLATFORM_BRANCH: "dd-trace-dotnet/macro"
476+
470477
# Whether to cleanup ephemeral instances after benchmarks are run
471478
CLEANUP: "true"
472479

@@ -489,14 +496,17 @@ profiler_cpu_timer_create-arm64:
489496
script:
490497
- source build-id.txt
491498
- echo "Building for the following build https://dev.azure.com/datadoghq/dd-trace-dotnet/_build/results?buildId=$buildId&view=results"
492-
- export BP_INFRA_BENCHMARKING_PLATFORM_BRANCH=dd-trace-dotnet/macro
493499
- git clone --branch $BP_INFRA_BENCHMARKING_PLATFORM_BRANCH https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.ddbuild.io/DataDog/benchmarking-platform platform && cd platform
494500
- ./ephemeral-infra/run-windows-benchmarks.sh
495501
after_script:
496502
- |
497-
bp-infra cleanup --provision ./platform/ephemeral-infra/provisions/macrobenchmark-ephemeral-instance.yaml \
498-
--region "${AWS_REGION}" \
499-
--bypass-stack-destroy
503+
if [ "$CLEANUP" == "true" ]; then
504+
bp-infra cleanup --provision ./platform/ephemeral-infra/provisions/macrobenchmark-ephemeral-instance.yaml \
505+
--region "${AWS_REGION}" \
506+
--bypass-stack-destroy
507+
else
508+
echo "'CLEANUP' is set to 'false'. Will not cleanup."
509+
fi
500510
501511
baseline-win:
502512
extends: .benchmarks-win
Lines changed: 102 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,129 @@
1-
.setup:
2-
script:
3-
- mkdir -p ~/.aws
4-
- /app/bp-infra/tools/fetch-ssm-parameter.sh $AWS_EPHEMERAL_INFRA_PROFILE_SSM_PARAMETER > ~/.aws/config || exit $?
5-
- export AWS_PROFILE=ephemeral-infra-ci
6-
- export BP_INFRA_KEY_PAIR_NAME=$(cat ~/.aws/key-pair-name.txt)
7-
- export BP_INFRA_KEY_PAIR_PRIVATE_KEY_PATH=~/.aws/key-pair-private-key.pem
1+
.dd-octo-sts-setup:
2+
before_script:
3+
- |
4+
set +e
5+
echo "Attempting to retrieve a GitHub token for scope '$DDOCTOSTS_SCOPE' with policy '$DDOCTOSTS_POLICY' with dd-octo-sts..."
6+
error_output=$({ dd-octo-sts token --scope $DDOCTOSTS_SCOPE --policy $DDOCTOSTS_POLICY > "/tmp/github-token"; } 2>&1)
7+
exit_code=$?
8+
if [ $exit_code -ne 0 ]; then
9+
echo "ERROR: Failed to retrieve GitHub token."
10+
echo "Original error: $error_output"
11+
echo "Continuing execution anyway..."
12+
fi
13+
set -e
814
915
stages:
10-
- infra-update
16+
- build
1117
- benchmarks
1218

13-
update-bp-infra:
14-
stage: infra-update
19+
build-dd-trace-dotnet-microbenchmarks-ami:
20+
stage: build
21+
tags: ["arch:amd64"]
1522
timeout: 3h
16-
tags: ["arch:amd64"]
1723
allow_failure: true
18-
# Image created in the following job https://gitlab.ddbuild.io/DataDog/benchmarking-platform-tools/-/jobs/869830045
24+
when: manual
1925
image: registry.ddbuild.io/images/benchmarking-platform-tools-ubuntu:dd-trace-dotnet-micro
26+
id_tokens:
27+
DDOCTOSTS_ID_TOKEN:
28+
aud: dd-octo-sts
29+
variables:
30+
# Allows ephemeral instances to read content from dd-trace-dotnet
31+
# This is not strictly necessary in the current AMI build
32+
DDOCTOSTS_SCOPE: "DataDog/dd-trace-dotnet"
33+
DDOCTOSTS_POLICY: "gitlab.github-access.read-contents"
34+
35+
AWS_REGION: "us-east-1"
36+
37+
# TODO: Point to dd-trace-dotnet/micro after the branch below is merged
38+
# to it
39+
# Branch containing a provision for building the AMI
40+
BP_INFRA_BENCHMARKING_PLATFORM_BRANCH: "augusto/dd-trace-dotnet-micro-bp-ui"
41+
42+
PROVISION_FILE: "platform/ephemeral-infra/ami.yaml"
43+
44+
# Where AMI creation artifacts will be stored
45+
BP_INFRA_ARTIFACTS_BUCKET_NAME: "windows-benchmarking-results-us-east-1"
2046

47+
# Whether to cleanup instances after building the AMI, since the AMI is
48+
# based on an instance that is created in this job
49+
CLEANUP: "true"
50+
before_script:
51+
- !reference [.dd-octo-sts-setup, before_script]
2152
script:
22-
- git clone --branch dd-trace-dotnet/micro https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.ddbuild.io/DataDog/benchmarking-platform platform
23-
- mkdir -p ~/.aws
24-
- /app/bp-infra/tools/fetch-ssm-parameter.sh $AWS_EPHEMERAL_INFRA_PROFILE_SSM_PARAMETER >> ~/.aws/config || exit $?
25-
- aws ssm get-parameter --region "$AWS_REGION" --name "ci.${CI_PROJECT_NAME}.ephemeral-infra-ci.windows-benchmarking-key-pair-name" --with-decryption --query "Parameter.Value" --out text >> ~/.aws/key-pair-name.txt
26-
- aws ssm get-parameter --region "$AWS_REGION" --name "ci.${CI_PROJECT_NAME}.ephemeral-infra-ci.windows-benchmarking-key-private-key" --with-decryption --query "Parameter.Value" --out text >> ~/.aws/key-pair-private-key.pem
27-
- export AWS_PROFILE=ephemeral-infra-ci
28-
- export BP_INFRA_KEY_PAIR_NAME=$(cat ~/.aws/key-pair-name.txt)
29-
- export BP_INFRA_KEY_PAIR_PRIVATE_KEY_PATH=~/.aws/key-pair-private-key.pem
30-
- bp-infra launch --provision ./platform/ephemeral-infra/base-instance.yaml --region "${AWS_REGION}" --bypass-stack-destroy
53+
- git clone --branch $BP_INFRA_BENCHMARKING_PLATFORM_BRANCH https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.ddbuild.io/DataDog/benchmarking-platform platform
54+
- echo "GITHUB_TOKEN=$(cat /tmp/github-token)" > .env
55+
- CLEANUP_ARG=$([[ "$CLEANUP" == "false" ]] && echo "--no-cleanup" || echo "")
56+
- |
57+
bp-infra launch --region "${AWS_REGION}" --os "windows" \
58+
--provision "${PROVISION_FILE}" \
59+
--bypass-stack-destroy \
60+
--env .env \
61+
$CLEANUP_ARG
3162
after_script:
32-
- !reference [.setup, script]
63+
# Makes sure the instance is cleaned up.
64+
# Note: This does not clean up the created AMI.
3365
- |
34-
bp-infra cleanup --provision ./platform/ephemeral-infra/base-instance.yaml \
35-
--region "${AWS_REGION}" \
36-
--bypass-stack-destroy
37-
38-
rules:
39-
- when: manual
40-
variables:
41-
AWS_REGION: "us-east-1"
42-
CLEANUP: "false"
43-
AWS_EPHEMERAL_INFRA_PROFILE_SSM_PARAMETER: "ci.dd-trace-dotnet.ephemeral-infra-ci.dd-trace-dotnet-profile"
44-
AWS_EPHEMERAL_INFRA_PROFILE_NAME: "ephemeral-infra-ci"
45-
AWS_EPHEMERAL_INFRA_ARTIFACTS_BUCKET_URI: "s3://windows-benchmarking-results/$CI_PROJECT_NAME/$CI_COMMIT_REF_NAME/$CI_JOB_ID"
46-
AWS_EPHEMERAL_INFRA_REGION: "us-east-1"
66+
if [ "$CLEANUP" == "true" ]; then
67+
bp-infra cleanup --region "${AWS_REGION}" --os "windows" \
68+
--provision "${PROVISION_FILE}" \
69+
--bypass-stack-destroy
70+
else
71+
echo "'CLEANUP' is set to 'false'. Will not cleanup."
72+
fi
4773
4874
run-benchmarks:
4975
stage: benchmarks
5076
tags: ["arch:amd64"]
5177
timeout: 2h
5278
# Image created in the following job https://gitlab.ddbuild.io/DataDog/benchmarking-platform-tools/-/jobs/869830045
5379
image: registry.ddbuild.io/images/benchmarking-platform-tools-ubuntu:dd-trace-dotnet-micro
54-
55-
script:
56-
- git clone --branch dd-trace-dotnet/micro https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.ddbuild.io/DataDog/benchmarking-platform platform
57-
- AWS_REGION=${AWS_REGION} ./platform/steps/launch-instance.sh
58-
after_script:
59-
- |
60-
bp-infra cleanup --provision ./platform/ephemeral-infra/ephemeral-instance-main.yaml \
61-
--region "${AWS_REGION}" \
62-
--bypass-stack-destroy
63-
- ./platform/steps/post-pr-comment.sh
64-
# Temporarily commented out pending issue resolution with sending files to backend
65-
# - ./platform/steps/upload-to-bp-ui.sh
66-
80+
id_tokens:
81+
DDOCTOSTS_ID_TOKEN:
82+
aud: dd-octo-sts
6783
rules:
6884
- when: on_success
69-
variables:
70-
AWS_REGION: "us-east-1"
71-
72-
upload-to-bp-ui:
73-
stage: benchmarks
74-
tags: ["arch:amd64"]
75-
timeout: 1h
76-
# Image created in the following job https://gitlab.ddbuild.io/DataDog/benchmarking-platform-tools/-/jobs/869830045
77-
image: registry.ddbuild.io/images/benchmarking-platform-tools-ubuntu:dotnet-microbenchmarks
78-
79-
script:
80-
- git clone --branch fayssal/test-micro-delivery https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.ddbuild.io/DataDog/benchmarking-platform platform
81-
# - ./platform/steps/launch-instance.sh
82-
# - ./platform/steps/post-pr-comment.sh
83-
# Temporarely commented out pending issue resolution with sending files to backend
84-
- ./platform/steps/upload-to-bp-ui.sh
85-
8685
artifacts:
8786
name: "artifacts"
8887
when: always
8988
paths:
90-
- candidate-results/
89+
- platform/artifacts
9190
expire_in: 3 months
92-
93-
rules:
94-
- when: manual
9591
variables:
92+
# Allows ephemeral instances to read content from benchmarking-platform
93+
DDOCTOSTS_SCOPE: "DataDog/benchmarking-platform"
94+
DDOCTOSTS_POLICY: "gitlab.github-access.read-contents"
95+
9696
AWS_REGION: "us-east-1"
97-
CLEANUP: "false"
98-
AWS_EPHEMERAL_INFRA_PROFILE_SSM_PARAMETER: "ci.dd-trace-dotnet.ephemeral-infra-ci.dd-trace-dotnet-profile"
99-
AWS_EPHEMERAL_INFRA_PROFILE_NAME: "ephemeral-infra-ci"
100-
AWS_EPHEMERAL_INFRA_ARTIFACTS_BUCKET_URI: "s3://windows-benchmarking-results/$CI_PROJECT_NAME/$CI_COMMIT_REF_NAME/$CI_JOB_ID"
101-
AWS_EPHEMERAL_INFRA_REGION: "us-east-1"
97+
98+
# TODO: Point to dd-trace-dotnet/micro after the branch below is merged
99+
# to it
100+
# Branch containing 1. scripts to launch Windows benchmarks on ephemeral
101+
# instances (to be used by GitLab CI runners) and 2. scripts to run Windows
102+
# benchmarks (to be used by the ephemeral instances).
103+
BP_INFRA_BENCHMARKING_PLATFORM_BRANCH: "augusto/dd-trace-dotnet-micro-bp-ui"
104+
105+
# Where benchmarking results will be stored
106+
BP_INFRA_ARTIFACTS_BUCKET_NAME: "windows-benchmarking-results-us-east-1"
107+
108+
# Whether to cleanup ephemeral instances after benchmarks are run
109+
CLEANUP: "true"
110+
111+
# Where to look for benchmarking artifacts for uploading to the BP UI
112+
ARTIFACTS_DIR: "platform/artifacts"
113+
before_script:
114+
- !reference [.dd-octo-sts-setup, before_script]
115+
script:
116+
- export GITHUB_TOKEN=$(cat /tmp/github-token)
117+
- git clone --branch $BP_INFRA_BENCHMARKING_PLATFORM_BRANCH https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.ddbuild.io/DataDog/benchmarking-platform platform
118+
- ./platform/steps/run-windows-benchmarks.sh
119+
after_script:
120+
- |
121+
if [ "$CLEANUP" == "true" ]; then
122+
bp-infra cleanup --provision ./platform/ephemeral-infra/instance.yaml \
123+
--region "${AWS_REGION}" \
124+
--bypass-stack-destroy
125+
else
126+
echo "'CLEANUP' is set to 'false'. Will not cleanup."
127+
fi
128+
- ./platform/steps/post-pr-comment.sh
129+
- ./platform/steps/upload-to-bp-ui.sh

AGENTS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,9 @@ The tracer runs in-process with customer applications and must have minimal perf
293293
- `docs/development/AzureFunctions.md` — Azure Functions integration
294294
- `docs/development/Serverless.md` — Serverless instrumentation
295295
- `docs/development/UpdatingTheSdk.md` — SDK updates
296+
297+
**CI & Testing:**
298+
- `docs/development/CI/TroubleshootingCIFailures.md` — Investigating build/test failures in Azure DevOps
296299
- `docs/development/CI/RunSmokeTestsLocally.md` — Running smoke tests locally
297300

298301
## Security & Configuration

docs/development/AzureFunctions.md

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ To correctly flow and parent the state across each request, our integration does
4242
- In-process instrumentation of `FunctionInvocationMiddleware` in `func.exe`.
4343
- This is the same integration we use for normal in-process functions. We need to keep the span generated here as it represents the "real" latencies seen by customers calling the function. This is only created for HTTP requests.
4444
- In-process instrumentation of `FunctionExecutor` in `func.exe`.
45-
- This is the same integration point as for in-process functions, but it serves a slightly different purpose. We don't want to create a span here (this function invocation doesn't represent anything useful), but we _do_ want to enrich the top-level HTTP span with more details about the function invocation.
45+
- This is the same integration point as for in-process functions, but it serves a slightly different purpose. We don't want to create a span here (this function invocation doesn't represent anything useful), but we _do_ want to enrich the top-level HTTP span with more details about the function invocation.
4646
- The "function" being executed here is the "fake" in-process function which mirrors the "real" out-of-process function. Consequently, we don't have real type names, and the function name is prefixed with `Functions.`, e.g. `Functions.MyAppTrigger` instead of `MyAppTrigger`
4747
- Instrumentation of `GrpcMessageConversionExtensions.ToRpcHttp()` in `func.exe`.
4848
- This is a new integration, which hooks into the method that converts the incoming HTTP request into a GRPC message.
@@ -57,7 +57,7 @@ For an HTTP trigger function, the result is something like this:
5757

5858
```mermaid
5959
gantt
60-
title HTTP span
60+
title HTTP span
6161
dateFormat X
6262
axisFormat %s
6363
todayMarker off
@@ -70,7 +70,7 @@ For a timer trigger, there's a single span
7070

7171
```mermaid
7272
gantt
73-
title HTTP span
73+
title HTTP span
7474
dateFormat X
7575
axisFormat %s
7676
todayMarker off
@@ -95,6 +95,36 @@ Whether a Functions app uses this new mode is subtle:
9595

9696
and the project will have a reference to [Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore/) package.
9797

98+
## Local Development
99+
100+
### Building the Datadog.AzureFunctions NuGet Package
101+
102+
For rapid iteration when testing changes to `Datadog.Trace` in Azure Functions projects, use the `Build-AzureFunctionsNuget.ps1` helper script:
103+
104+
```powershell
105+
# Build using existing bundle
106+
.\tracer\tools\Build-AzureFunctionsNuget.ps1
107+
108+
# Download bundle from a specific Azure DevOps build first
109+
.\tracer\tools\Build-AzureFunctionsNuget.ps1 -BuildId 12345
110+
111+
# Build and copy package to a specific location
112+
.\tracer\tools\Build-AzureFunctionsNuget.ps1 -CopyTo 'D:\temp\nuget'
113+
114+
# Use -Verbose for detailed progress
115+
.\tracer\tools\Build-AzureFunctionsNuget.ps1 -Verbose
116+
```
117+
118+
This script:
119+
1. Cleans up previous builds
120+
2. Removes the `Datadog.AzureFunctions` package from the local NuGet cache
121+
3. Optionally downloads `Datadog.Trace.Bundle` from a specific build
122+
4. Builds `Datadog.Trace` and publishes to the bundle folder (`net6.0` and `net461` targets)
123+
5. Builds the `Datadog.AzureFunctions` NuGet package
124+
6. Optionally copies the package to a specified path
125+
126+
See `Get-Help .\tracer\tools\Build-AzureFunctionsNuget.ps1 -Full` for complete documentation.
127+
98128
## Debugging
99129

100130
To debug Azure Functions locally ensure that you have the following:

0 commit comments

Comments
 (0)