Skip to content

[Azure Functions] Add Nuke targets to build local nuget for testing#7537

Merged
lucaspimentel merged 9 commits intomasterfrom
lpimentel/azure-functions/build-local-nuget-1
Sep 22, 2025
Merged

[Azure Functions] Add Nuke targets to build local nuget for testing#7537
lucaspimentel merged 9 commits intomasterfrom
lpimentel/azure-functions/build-local-nuget-1

Conversation

@lucaspimentel
Copy link
Member

@lucaspimentel lucaspimentel commented Sep 18, 2025

Summary of changes

Adds a Nuke target to download Datadog.Trace.Bundle and extract it into the local bundle home directory.

Reason for change

This is useful for building Datadog.Trace.Bundle or Datadog.AzureFunctions nupkg packages locally for testing, and I do it manually too often. Automate all the things?

Implementation details

Add Nuke target DownloadBundleNugetFromBuild:

  • download Datadog.Trace.Bundle from an Azure DevOps build
  • extracts the files into tracer/src/Datadog.Trace.Bundle/home

Usage:

# download a fresh copy of the bundle files from Azure DevOps
.\tracer\build.ps1 DownloadBundleNugetFromBuild --BuildId 187203

Test coverage

Tested locally. Not used in production builds.

Other details

@lucaspimentel
Copy link
Member Author

@codex review

@github-actions github-actions bot added area:builds project files, build scripts, pipelines, versioning, releases, packages area:serverless labels Sep 18, 2025
@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. Another round soon, please!

About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback".

@dd-trace-dotnet-ci-bot
Copy link

dd-trace-dotnet-ci-bot bot commented Sep 18, 2025

Execution-Time Benchmarks Report ⏱️

Execution-time results for samples comparing the following branches/commits:

Execution-time benchmarks measure the whole time it takes to execute a program. And are intended to measure the one-off costs. Cases where the execution time results for the PR are worse than latest master results are shown in red. The following thresholds were used for comparing the execution times:

  • Welch test with statistical test for significance of 5%
  • Only results indicating a difference greater than 5% and 5 ms are considered.

Note that these results are based on a single point-in-time result for each branch. For full results, see the dashboard.

Graphs show the p99 interval based on the mean and StdDev of the test run, as well as the mean value of the run (shown as a diamond below the graph).

gantt
    title Execution time (ms) FakeDbCommand (.NET Framework 4.8) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Bailout
    This PR (7537) - mean (72ms)  : 71, 73
     .   : milestone, 72,
    master - mean (92ms)  : 79, 105
     .   : milestone, 92,

    section Baseline
    This PR (7537) - mean (68ms)  : 66, 70
     .   : milestone, 68,
    master - mean (85ms)  : 73, 98
     .   : milestone, 85,

    section CallTarget+Inlining+NGEN
    This PR (7537) - mean (1,006ms)  : 981, 1032
     .   : milestone, 1006,
    master - mean (1,132ms)  : 1042, 1222
     .   : milestone, 1132,

Loading
gantt
    title Execution time (ms) FakeDbCommand (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Bailout
    This PR (7537) - mean (107ms)  : 105, 108
     .   : milestone, 107,
    master - mean (136ms)  : 121, 152
     .   : milestone, 136,

    section Baseline
    This PR (7537) - mean (106ms)  : 103, 109
     .   : milestone, 106,
    master - mean (132ms)  : 114, 150
     .   : milestone, 132,

    section CallTarget+Inlining+NGEN
    This PR (7537) - mean (710ms)  : 693, 726
     .   : milestone, 710,
    master - mean (827ms)  : 763, 892
     .   : milestone, 827,

Loading
gantt
    title Execution time (ms) FakeDbCommand (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Bailout
    This PR (7537) - mean (94ms)  : 93, 96
     .   : milestone, 94,
    master - mean (122ms)  : 99, 144
     .   : milestone, 122,

    section Baseline
    This PR (7537) - mean (93ms)  : 91, 96
     .   : milestone, 93,
    master - mean (119ms)  : 98, 140
     .   : milestone, 119,

    section CallTarget+Inlining+NGEN
    This PR (7537) - mean (664ms)  : 645, 683
     .   : milestone, 664,
    master - mean (780ms)  : 714, 847
     .   : milestone, 780,

Loading
gantt
    title Execution time (ms) FakeDbCommand (.NET 8) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Bailout
    This PR (7537) - mean (93ms)  : 92, 94
     .   : milestone, 93,
    master - mean (117ms)  : 102, 131
     .   : milestone, 117,

    section Baseline
    This PR (7537) - mean (92ms)  : 89, 94
     .   : milestone, 92,
    master - mean (115ms)  : 102, 129
     .   : milestone, 115,

    section CallTarget+Inlining+NGEN
    This PR (7537) - mean (597ms)  : 583, 611
     .   : milestone, 597,
    master - mean (714ms)  : 652, 776
     .   : milestone, 714,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Framework 4.8) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Bailout
    This PR (7537) - mean (215ms)  : 209, 221
     .   : milestone, 215,
    master - mean (213ms)  : 203, 222
     .   : milestone, 213,

    section Baseline
    This PR (7537) - mean (208ms)  : 202, 214
     .   : milestone, 208,
    master - mean (209ms)  : 193, 225
     .   : milestone, 209,

    section CallTarget+Inlining+NGEN
    This PR (7537) - mean (1,188ms)  : 1128, 1248
     .   : milestone, 1188,
    master - mean (1,177ms)  : 1130, 1224
     .   : milestone, 1177,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Bailout
    This PR (7537) - mean (306ms)  : 295, 317
     .   : milestone, 306,
    master - mean (302ms)  : 288, 316
     .   : milestone, 302,

    section Baseline
    This PR (7537) - mean (303ms)  : 293, 314
     .   : milestone, 303,
    master - mean (299ms)  : 289, 310
     .   : milestone, 299,

    section CallTarget+Inlining+NGEN
    This PR (7537) - mean (963ms)  : 931, 996
     .   : milestone, 963,
    master - mean (951ms)  : 916, 986
     .   : milestone, 951,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Bailout
    This PR (7537) - mean (301ms)  : 288, 314
     .   : milestone, 301,
    master - mean (292ms)  : 279, 305
     .   : milestone, 292,

    section Baseline
    This PR (7537) - mean (296ms)  : 288, 304
     .   : milestone, 296,
    master - mean (295ms)  : 280, 311
     .   : milestone, 295,

    section CallTarget+Inlining+NGEN
    This PR (7537) - mean (948ms)  : 900, 995
     .   : milestone, 948,
    master - mean (941ms)  : 882, 1001
     .   : milestone, 941,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET 8) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Bailout
    This PR (7537) - mean (297ms)  : 284, 309
     .   : milestone, 297,
    master - mean (292ms)  : 278, 307
     .   : milestone, 292,

    section Baseline
    This PR (7537) - mean (292ms)  : 278, 306
     .   : milestone, 292,
    master - mean (297ms)  : 287, 307
     .   : milestone, 297,

    section CallTarget+Inlining+NGEN
    This PR (7537) - mean (870ms)  : 763, 976
     .   : milestone, 870,
    master - mean (868ms)  : 774, 962
     .   : milestone, 868,

Loading

Copy link
Member

@andrewlock andrewlock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM in general - though I'd rather we didn't provide an entirely separate way of building datadog.trace

Target UpdateAzureFunctionsNugetFromBuild => _ => _
.Description("Updates the bundle home contents with local builds of Datadog.Trace.dll, and rebuilds the Datadog.AzureFunctions package")
.After(DownloadBundleNugetFromBuild)
.Triggers(BuildAzureFunctionsNuget)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We generally try to avoid Triggers because it makes it even harder to understand the already complex web than we currently have 🙁

I would also recommend against having a completely separate way of building Datadog.Trace here. Could this target be rewritten as the following?

Target UpdateAzureFunctionsNugetFromBuild => _ => _
        .Description("Updates the bundle home contents with local builds of Datadog.Trace.dll, and rebuilds the Datadog.AzureFunctions package")
        .After(DownloadBundleNugetFromBuild)
        .DependsOn(Restore, CompileManagedSrc, PublishManagedTracer);

(You would need to make sure DownloadBundleNugetFromBuild has a Before(PublishManagedTracer) to ensure it downloads before the publish)

Copy link
Member Author

@lucaspimentel lucaspimentel Sep 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second thought, I'll only add DownloadBundleNugetFromBuild for now and remove this UpdateAzureFunctionsNugetFromBuild. Downloading the artifact and extracting it is the more annoying part.

I can always add this second target later if needed.

@lucaspimentel lucaspimentel marked this pull request as ready for review September 19, 2025 15:32
@lucaspimentel lucaspimentel requested a review from a team as a code owner September 19, 2025 15:32
@lucaspimentel lucaspimentel force-pushed the lpimentel/azure-functions/build-local-nuget-1 branch from f3c26f7 to a2778a5 Compare September 19, 2025 15:32

Target DownloadBundleNugetFromBuild => _ => _
.Description("Downloads Datadog.Trace.Bundle package from Azure DevOps and extracts it to the local bundle home directory." +
" Useful for building Datadog.Trace.Bundle or Datadog.AzureFunctions nupkg packages locally.")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit I think it changed to just be this?

Suggested change
" Useful for building Datadog.Trace.Bundle or Datadog.AzureFunctions nupkg packages locally.")
" Useful for building the Datadog.AzureFunctions nupkg package locally.")

Copy link
Member Author

@lucaspimentel lucaspimentel Sep 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new target downloads Datadog.Trace.Bundle.nupkg and extracts the files where they are expected to build either of those two nuget packages with BuildBundleNuget or BuildAzureFunctionsNuget.

My focus is building Datadog.AzureFunctions, not the bundle, but I'm trying to keep this target generic enough that it can be used for either one.

Copy link
Member Author

@lucaspimentel lucaspimentel Sep 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in other words, you can use either

# new target added in this PR
.\tracer\build.ps1 DownloadBundleNugetFromBuild --BuildId 187203

...do stuff to replace some bundle files...

# build new bundle nuget
.\tracer\build.ps1 BuildBundleNuget

or

# new target added in this PR
.\tracer\build.ps1 DownloadBundleNugetFromBuild --BuildId 187203

...do stuff to replace some bundle files...

# build new azfunc nuget
.\tracer\build.ps1 BuildAzureFunctionsNuget

Copy link
Member

@andrewlock andrewlock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lucaspimentel lucaspimentel merged commit 8e47328 into master Sep 22, 2025
151 checks passed
@lucaspimentel lucaspimentel deleted the lpimentel/azure-functions/build-local-nuget-1 branch September 22, 2025 23:11
@github-actions github-actions bot added this to the vNext-v3 milestone Sep 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:builds project files, build scripts, pipelines, versioning, releases, packages area:serverless

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants