Skip to content

[SVLS-6337] Don't spawn agent process if DD_AZURE_RESOURCE_GROUP not set for Azure flex consumption functions#31

Merged
kathiehuang merged 3 commits intomainfrom
kathie.huang/check-azure-flex-func-without-dd-azure-rg-env-var
Oct 2, 2025
Merged

[SVLS-6337] Don't spawn agent process if DD_AZURE_RESOURCE_GROUP not set for Azure flex consumption functions#31
kathiehuang merged 3 commits intomainfrom
kathie.huang/check-azure-flex-func-without-dd-azure-rg-env-var

Conversation

@kathiehuang
Copy link
Copy Markdown
Contributor

@kathiehuang kathiehuang commented Sep 26, 2025

What does this PR do?

Adds a check to see if we are in an Azure function that is on the flex consumption plan and doesn't have the DD_AZURE_RESOURCE_GROUP env var set. If so, return before the agent process can be spawned.

Motivation

  • Currently the aas.resource.group span attribute for functions on flex consumption plans is set incorrectly in Datadog - they're all set to "flex"
    • This is important to fix because aas.resource.id is built using aas.resource.group, and the resource id is used in billing, which needs to be accurate
    • We had to figure out what to do if a customer who is using Datadog to monitor their Azure function on a flex consumption plan doesn't set the DD_AZURE_RESOURCE_GROUP env var. Rather than handling that in libdatadog, we decided to do it at a higher level in the trace agent to inform the customer of the error while shutting down the trace agent gracefully and preventing any traces from being sent to Datadog, as well as adding this in the serverless-compat layers to have defense in depth

Jira Ticket

Describe how to test/QA your changes

  1. Clone serverless-components and update the commit hash in datadog-trace-agent/Cargo.toml
    everywhere that libdatadog is used to the most recent commit hash of the PR in libdatadog (currently d1b35ef21fff3c4588073504905081c8923bbc4b)
  2. Follow the instructions in the Serverless Compatability Layer docs to build the Rust binary
  3. Deploy an Azure function on flex consumption plan using the terraform tool, setting use_serverless_compat_local_path to true and making sure the built binary is in your python folder
  4. Hit an endpoint in your function or wait a minute for the invoker to invoke your function and check the Datadog traces for your function. Without the DD_AZURE_RESOURCE_GROUP env var, you should see no traces
  5. Go to Settings > Environment Variables in the Azure Portal for your function and add DD_AZURE_RESOURCE_GROUP as an environment variable with your resource group. Repeat step 4, you should see the correct resource group in the resource.group span attribute!
image

…n that doesn't have DD_AZURE_RESOURCE_GROUP set
@kathiehuang kathiehuang changed the title Return early before agent starts if in Azure flex consumption function that doesn't have DD_AZURE_RESOURCE_GROUP set [SVLS-6337] Don't spawn agent process if DD_AZURE_RESOURCE_GROUP not set for Azure flex consumption functions Sep 29, 2025
@kathiehuang kathiehuang marked this pull request as ready for review September 29, 2025 13:37
@kathiehuang
Copy link
Copy Markdown
Contributor Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ 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
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Comment thread src/main/java/com/datadog/ServerlessCompatAgent.java Outdated
Comment thread src/main/java/com/datadog/ServerlessCompatAgent.java Outdated
@kathiehuang
Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

ℹ️ 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
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Copy link
Copy Markdown
Collaborator

@duncanpharvey duncanpharvey left a comment

Choose a reason for hiding this comment

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

Looks good just one nit!

Comment thread src/main/java/com/datadog/ServerlessCompatAgent.java Outdated
@kathiehuang
Copy link
Copy Markdown
Contributor Author

/merge

@dd-devflow-routing-codex
Copy link
Copy Markdown

dd-devflow-routing-codex Bot commented Oct 2, 2025

View all feedbacks in Devflow UI.

2025-10-02 15:05:56 UTC ℹ️ Start processing command /merge


2025-10-02 15:06:02 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in main is approximately 0s (p90).


2025-10-02 15:47:54 UTC ⚠️ MergeQueue: This merge request build was cancelled

kathie.huang@datadoghq.com cancelled this merge request build

@kathiehuang
Copy link
Copy Markdown
Contributor Author

/remove

@dd-devflow-routing-codex
Copy link
Copy Markdown

dd-devflow-routing-codex Bot commented Oct 2, 2025

View all feedbacks in Devflow UI.

2025-10-02 15:47:49 UTC ℹ️ Start processing command /remove


2025-10-02 15:47:52 UTC ℹ️ Devflow: /remove

@kathiehuang kathiehuang merged commit 70ef1ce into main Oct 2, 2025
1 of 2 checks passed
@kathiehuang kathiehuang deleted the kathie.huang/check-azure-flex-func-without-dd-azure-rg-env-var branch October 2, 2025 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants