Commit a820699
authored
fix(libdd-common): Add fallback logic for resolving Azure Functions instance 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>1 parent 1ce0b30 commit a820699
1 file changed
Lines changed: 109 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
20 | 22 | | |
21 | | - | |
| 23 | + | |
| 24 | + | |
22 | 25 | | |
23 | | - | |
| 26 | + | |
24 | 27 | | |
25 | 28 | | |
26 | 29 | | |
| |||
63 | 66 | | |
64 | 67 | | |
65 | 68 | | |
66 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
67 | 72 | | |
68 | 73 | | |
69 | 74 | | |
| |||
223 | 228 | | |
224 | 229 | | |
225 | 230 | | |
| 231 | + | |
| 232 | + | |
226 | 233 | | |
227 | 234 | | |
228 | 235 | | |
229 | 236 | | |
230 | 237 | | |
231 | | - | |
| 238 | + | |
232 | 239 | | |
233 | 240 | | |
234 | 241 | | |
| |||
247 | 254 | | |
248 | 255 | | |
249 | 256 | | |
250 | | - | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
251 | 267 | | |
252 | 268 | | |
253 | 269 | | |
| |||
394 | 410 | | |
395 | 411 | | |
396 | 412 | | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
397 | 429 | | |
398 | 430 | | |
399 | 431 | | |
| |||
636 | 668 | | |
637 | 669 | | |
638 | 670 | | |
639 | | - | |
| 671 | + | |
640 | 672 | | |
641 | 673 | | |
642 | | - | |
| 674 | + | |
643 | 675 | | |
644 | 676 | | |
645 | 677 | | |
| |||
653 | 685 | | |
654 | 686 | | |
655 | 687 | | |
656 | | - | |
| 688 | + | |
657 | 689 | | |
658 | 690 | | |
659 | | - | |
| 691 | + | |
660 | 692 | | |
661 | 693 | | |
662 | 694 | | |
| |||
811 | 843 | | |
812 | 844 | | |
813 | 845 | | |
814 | | - | |
| 846 | + | |
815 | 847 | | |
816 | 848 | | |
817 | 849 | | |
| |||
857 | 889 | | |
858 | 890 | | |
859 | 891 | | |
860 | | - | |
| 892 | + | |
861 | 893 | | |
862 | 894 | | |
863 | 895 | | |
| |||
929 | 961 | | |
930 | 962 | | |
931 | 963 | | |
932 | | - | |
| 964 | + | |
933 | 965 | | |
934 | 966 | | |
935 | 967 | | |
| |||
1002 | 1034 | | |
1003 | 1035 | | |
1004 | 1036 | | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
1005 | 1101 | | |
0 commit comments