Skip to content

[SVLS-9015] Use consts and instance resolution logic from libdd-common#134

Draft
kathiehuang wants to merge 6 commits into
mainfrom
kathie.huang/move-env-var-logic-to-libddcommon
Draft

[SVLS-9015] Use consts and instance resolution logic from libdd-common#134
kathiehuang wants to merge 6 commits into
mainfrom
kathie.huang/move-env-var-logic-to-libddcommon

Conversation

@kathiehuang

@kathiehuang kathiehuang commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

With DataDog/libdatadog#2077 we moved the instance name resolution logic and any consts gathered from environment variables to libdd-common. This PR updates the libdatadog rev and uses the libdd-common logic and public consts.

Motivation

https://datadoghq.atlassian.net/browse/SVLS-9015

Additional Notes

Describe how to test/QA your changes

Deployed an Azure Function and confirmed that the instance tag in the instance enhanced metric is the same. See DataDog/libdatadog#2077 for testing the instance_name span attribute with screenshots.

@kathiehuang kathiehuang changed the title [SVLS-8931] Use consts and instance resolution logic from libdd-common [SVLS-9015] Use consts and instance resolution logic from libdd-common Jun 3, 2026
gh-worker-dd-mergequeue-cf854d Bot pushed a commit to DataDog/libdatadog that referenced this pull request Jun 15, 2026
…nstance name [SVLS-8931] (#2077)

# What does this PR do?
- Moves logic for resolving Azure Functions instance name from [serverless-components](https://github.com/DataDog/serverless-components/blob/da82dd574ac4eae73afc7201b9781e057643c2d6/crates/datadog-metrics-collector/src/azure_instance.rs#L21) to libdd-common.
- Logic for resolving instance name: `COMPUTERNAME` -> `WEBSITE_POD_NAME` -> `CONTAINER_NAME`
  - This matches the `instance` tag of `azure.functions.function_execution_count` integration metric
  - Before, we only checked `COMPUTERNAME`. The investigation to determine which env vars should be used is in the Instance tab of [Enhanced Metrics in the Serverless Compatibility Layer](https://docs.google.com/document/d/1uMT4fphW7C31JLmf5KY1CdrXGPkn2QLfIvHZK3CJD40/edit?usp=sharing)
- This has the added benefit of populating the instance name span attribute `aas.environment.instance_name` in hosting plans where the attribute was `unknown` before
  - Before, we only looked at `COMPUTERNAME` for instance name, which was empty for Linux Flex Consumption and Consumption functions
- This PR also makes some consts public so that they can be used by serverless-components; see DataDog/serverless-components#134 for usage

# Motivation
https://datadoghq.atlassian.net/browse/SVLS-8931
https://datadoghq.atlassian.net/browse/SVLS-9015

# Additional Notes

Once this PR is merged, we plan to make a new PR in serverless-components to update the libdatadog commit hash and remove the redundant consts and instance name logic. Draft PR: DataDog/serverless-components#134

# How to test the change?

Unit tests: Run `cargo test -p libdd-common azure_app_services`

1. Use git log to find this PR's most recent commit hash
2. Clone [serverless-components](https://github.com/DataDog/serverless-components/tree/main) and update the commit hash in [datadog-trace-agent/Cargo.toml](https://github.com/DataDog/serverless-components/blob/main/crates/datadog-trace-agent/Cargo.toml) everywhere that libdatadog is used
3. Follow the instructions in the [Serverless Compatibility Layer docs](https://datadoghq.atlassian.net/wiki/spaces/SLS/pages/2977497119/Serverless+Compatibility+Layer) to deploy sample apps

Flex Consumption function with fix:
<img width="956" height="568" alt="image" src="https://github.com/user-attachments/assets/b11585cf-7e1c-4d89-a60d-490bfe6bf45e" />

Flex Consumption function without fix:
<img width="1267" height="504" alt="Screenshot 2026-06-03 at 4 33 58 PM" src="https://github.com/user-attachments/assets/252c9ffa-3918-457f-95b5-adc1b794aa2b" />

Consumption function with fix:
<img width="974" height="564" alt="image" src="https://github.com/user-attachments/assets/2d92d604-be97-4eb1-8e6a-9d048420c715" />

Consumption function without fix:
<img width="1276" height="534" alt="image" src="https://github.com/user-attachments/assets/b9918da9-c177-45df-8432-92f7eee001eb" />

I tested by deploying with [serverless-compat-self-monitoring](https://github.com/DataDog/serverless-compat-self-monitoring):
- FC1 and Y1 linux functions get the `aas.environment.instance_name` span attribute populated 
- The span attributes for all other functions still look the same (same shape and casing)

Co-authored-by: kathie.huang <kathie.huang@datadoghq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant