Skip to content

Commit c916c79

Browse files
authored
Update metadata spec for Azure Functions (#712)
1 parent 43f59d8 commit c916c79

File tree

2 files changed

+92
-0
lines changed

2 files changed

+92
-0
lines changed

specs/agents/metadata.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,28 @@ to each agent to determine whether it is useful to implement
308308
for their language ecosystem. See [azure_app_service_metadata specs](../../tests/agents/gherkin-specs/azure_app_service_metadata.feature)
309309
for scenarios and expected outcomes.
310310

311+
##### Azure Functions
312+
313+
Azure Functions running within a consumption/premium plan (see [Azure Functions hosting options](https://learn.microsoft.com/en-us/azure/azure-functions/functions-scale)) are a FaaS offering within Azure that do not have access
314+
to the internal [Azure metadata endpoint](#azure-vms). Metadata about an Azure Function can however be
315+
retrieved from environment variables.
316+
**Note:** These environment variables slightly differ from those available to [Azure App Services](#azure_app_service-optional).
317+
318+
| Cloud metadata field | Environment variable |
319+
| -------------------- | ------------------- |
320+
| `account.id` | Token `{subscription id}` from `WEBSITE_OWNER_NAME` |
321+
| `instance.name` | `WEBSITE_SITE_NAME` |
322+
| `project.name` | `WEBSITE_RESOURCE_GROUP` (fallback: `{resource group}` from `WEBSITE_OWNER_NAME`) |
323+
| `provider` | azure |
324+
| `region` | `REGION_NAME` (fallback: `{region}` from `WEBSITE_OWNER_NAME`) |
325+
| `service.name` | `functions` see the [ECS fields doc](https://www.elastic.co/guide/en/ecs/current/ecs-cloud.html#field-cloud-service-name). |
326+
327+
The environment variable `WEBSITE_OWNER_NAME` has the following form:
328+
329+
`{subscription id}+{resource group}-{region}webspace{.*}`
330+
331+
Example: `d2cd53b3-acdc-4964-9563-3f5201556a81+wolfgangfaas_group-CentralUSwebspace-Linux`
332+
311333
### Global labels
312334

313335
Events sent by the agents can have labels associated, which may be useful for custom aggregations, or document-level access control. It is possible to add "global labels" to the metadata, which are labels that will be applied to all events sent by an agent. These are only understood by APM Server 7.2 or greater.
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
Feature: Extracting Metadata for Azure Function Apps
2+
3+
Background:
4+
Given an agent configured with
5+
| setting | value |
6+
| cloud_provider | azure |
7+
8+
Scenario Outline: Azure Function App with minimum set of environment variables present in expected format
9+
Given the following environment variables are present
10+
| name | value |
11+
| FUNCTIONS_EXTENSION_VERSION | version |
12+
| WEBSITE_OWNER_NAME | d2cd53b3-acdc-4964-9563-3f5201556a81+faas_group-CentralUSwebspace-Linux |
13+
| WEBSITE_SITE_NAME | site_name |
14+
When cloud metadata is collected
15+
Then cloud metadata is not null
16+
And cloud metadata 'account.id' is 'd2cd53b3-acdc-4964-9563-3f5201556a81'
17+
And cloud metadata 'provider' is 'azure'
18+
And cloud metadata 'service.name' is 'functions'
19+
And cloud metadata 'instance.name' is 'site_name'
20+
And cloud metadata 'project.name' is 'faas_group'
21+
And cloud metadata 'region' is 'CentralUS'
22+
23+
Scenario Outline: Azure Function App with typical set of environment variables present in expected format
24+
Given the following environment variables are present
25+
| name | value |
26+
| FUNCTIONS_EXTENSION_VERSION | version |
27+
| WEBSITE_OWNER_NAME | d2cd53b3-acdc-4964-9563-3f5201556a81+faas_group-CentralUSwebspace-Linux |
28+
| WEBSITE_SITE_NAME | site_name |
29+
| REGION_NAME | Central US |
30+
| WEBSITE_RESOURCE_GROUP | faas_group_from_env |
31+
When cloud metadata is collected
32+
Then cloud metadata is not null
33+
And cloud metadata 'account.id' is 'd2cd53b3-acdc-4964-9563-3f5201556a81'
34+
And cloud metadata 'provider' is 'azure'
35+
And cloud metadata 'service.name' is 'functions'
36+
And cloud metadata 'instance.name' is 'site_name'
37+
And cloud metadata 'project.name' is 'faas_group_from_env'
38+
And cloud metadata 'region' is 'Central US'
39+
40+
Scenario: WEBSITE_OWNER_NAME environment variable not expected format
41+
Given the following environment variables are present
42+
| name | value |
43+
| WEBSITE_OWNER_NAME | d2cd53b3-acdc-4964-9563-3f5201556a81-faas_group-CentralUSwebspace-Linux |
44+
| WEBSITE_SITE_NAME | site_name |
45+
When cloud metadata is collected
46+
Then cloud metadata is null
47+
48+
Scenario: Missing FUNCTIONS_EXTENSION_VERSION environment variable
49+
Given the following environment variables are present
50+
| name | value |
51+
| WEBSITE_OWNER_NAME | d2cd53b3-acdc-4964-9563-3f5201556a81+faas_group-CentralUSwebspace-Linux |
52+
| WEBSITE_SITE_NAME | site_name |
53+
When cloud metadata is collected
54+
Then cloud metadata is null
55+
56+
Scenario: Missing WEBSITE_OWNER_NAME environment variable
57+
Given the following environment variables are present
58+
| name | value |
59+
| FUNCTIONS_EXTENSION_VERSION | version |
60+
| WEBSITE_SITE_NAME | site_name |
61+
When cloud metadata is collected
62+
Then cloud metadata is null
63+
64+
Scenario: Missing WEBSITE_SITE_NAME environment variable
65+
Given the following environment variables are present
66+
| name | value |
67+
| FUNCTIONS_EXTENSION_VERSION | version |
68+
| WEBSITE_OWNER_NAME | d2cd53b3-acdc-4964-9563-3f5201556a81+faas_group-CentralUSwebspace-Linux |
69+
When cloud metadata is collected
70+
Then cloud metadata is null

0 commit comments

Comments
 (0)