Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azure FaaS conventions. #2502

Merged
merged 21 commits into from
May 13, 2022
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ release.

### Semantic Conventions

- Add details for FaaS conventions for Azure Functions and allow FaaS/Cloud
resources as span attributes on incoming FaaS spans
([#2502](https://github.com/open-telemetry/opentelemetry-specification/pull/2502))

### Compatibility

### OpenTelemetry Protocol
Expand Down
39 changes: 26 additions & 13 deletions semantic_conventions/resource/faas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,45 @@ groups:
required: always
brief: >
The name of the single function that this runtime instance executes.
note:
note: |
This is the name of the function as configured/deployed on the FaaS
platform and is usually different from the name of the callback
function (which may be stored in the
[`code.namespace`/`code.function`](../../trace/semantic_conventions/span-general.md#source-code-attributes)
span attributes).
examples: ['my-function']

For some cloud providers, the above definision is ambiguous. The following
Oberon00 marked this conversation as resolved.
Show resolved Hide resolved
definition of function name MUST be used for this attribute
(and consequently the span name) for the listed cloud providers/products:

* **Azure:** The full name `<FUNCAPP>/<FUNC>`, i.e., function app name
followed by a forward slash followed by the function name (this form
can also be seen in the resource JSON for the function).
This means that a span attribute MUST be used, as an Azure function
app can host multiple functions that would usually share
a TracerProvider (see also the `faas.id` attribute).
examples: ['my-function', 'myazurefunctionapp/some-function-name']
- id: id
type: string
brief: >
The unique ID of the single function that this runtime instance executes.
note: |
Depending on the cloud provider, use:
On some cloud providers, it may not be possible to determine the full ID at startup,
so consider setting `faas.id` as a span attribute instead.
reyang marked this conversation as resolved.
Show resolved Hide resolved

The exact value to use for `faas.id` depends on the cloud provider:

* **AWS Lambda:** The function [ARN](https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html).
Take care not to use the "invoked ARN" directly but replace any
[alias suffix](https://docs.aws.amazon.com/lambda/latest/dg/configuration-aliases.html) with the resolved function version, as the same runtime instance may be invokable with multiple
different aliases.
Take care not to use the "invoked ARN" directly but replace any
[alias suffix](https://docs.aws.amazon.com/lambda/latest/dg/configuration-aliases.html)
with the resolved function version, as the same runtime instance may be invokable with
Oberon00 marked this conversation as resolved.
Show resolved Hide resolved
multiple different aliases.
* **GCP:** The [URI of the resource](https://cloud.google.com/iam/docs/full-resource-names)
* **Azure:** The [Fully Qualified Resource ID](https://docs.microsoft.com/en-us/rest/api/resources/resources/get-by-id).

On some providers, it may not be possible to determine the full ID at startup,
which is why this field cannot be made required. For example, on AWS the account ID
reyang marked this conversation as resolved.
Show resolved Hide resolved
part of the ARN is not available without calling another AWS API
which may be deemed too slow for a short-running lambda function.
As an alternative, consider setting `faas.id` as a span attribute instead.
* **Azure:** The [Fully Qualified Resource ID](https://docs.microsoft.com/en-us/rest/api/resources/resources/get-by-id) of the invoked function,
*not* the function app, having the form
`/subscriptions/<SUBSCIPTION_GUID>/resourceGroups/<RG>/providers/Microsoft.Web/sites/<FUNCAPP>/functions/<FUNC>`.
This means that a span attribute MUST be used, as an Azure function app can host multiple functions that would usually share
a TracerProvider (see also the paragraph below).
Oberon00 marked this conversation as resolved.
Show resolved Hide resolved
examples: ['arn:aws:lambda:us-west-2:123456789012:function:my-function']
- id: version
type: string
Expand Down
51 changes: 38 additions & 13 deletions specification/resource/semantic_conventions/faas.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,50 @@ See also:
- The [Trace semantic conventions for FaaS](../../trace/semantic_conventions/faas.md)
- The [Cloud resource conventions](cloud.md)

## FaaS resource attributes

<!-- semconv faas_resource -->
| Attribute | Type | Description | Examples | Required |
|---|---|---|---|---|
| `faas.name` | string | The name of the single function that this runtime instance executes. [1] | `my-function` | Yes |
| `faas.name` | string | The name of the single function that this runtime instance executes. [1] | `my-function`; `myazurefunctionapp/some-function-name` | Yes |
| `faas.id` | string | The unique ID of the single function that this runtime instance executes. [2] | `arn:aws:lambda:us-west-2:123456789012:function:my-function` | No |
| `faas.version` | string | The immutable version of the function being executed. [3] | `26`; `pinkfroid-00002` | No |
| `faas.instance` | string | The execution environment ID as a string, that will be potentially reused for other invocations to the same function/function version. [4] | `2021/06/28/[$LATEST]2f399eb14537447da05ab2a2e39309de` | No |
| `faas.max_memory` | int | The amount of memory available to the serverless function in MiB. [5] | `128` | No |

**[1]:** This is the name of the function as configured/deployed on the FaaS platform and is usually different from the name of the callback function (which may be stored in the [`code.namespace`/`code.function`](../../trace/semantic_conventions/span-general.md#source-code-attributes) span attributes).
**[1]:** This is the name of the function as configured/deployed on the FaaS
platform and is usually different from the name of the callback
function (which may be stored in the
[`code.namespace`/`code.function`](../../trace/semantic_conventions/span-general.md#source-code-attributes)
span attributes).

For some cloud providers, the above definision is ambiguous. The following
definition of function name MUST be used for this attribute
(and consequently the span name) for the listed cloud providers/products:

* **Azure:** The full name `<FUNCAPP>/<FUNC>`, i.e., function app name
followed by a forward slash followed by the function name (this form
can also be seen in the resource JSON for the function).
This means that a span attribute MUST be used, as an Azure function
app can host multiple functions that would usually share
a TracerProvider (see also the `faas.id` attribute).

**[2]:** On some cloud providers, it may not be possible to determine the full ID at startup,
so consider setting `faas.id` as a span attribute instead.

**[2]:** Depending on the cloud provider, use:
The exact value to use for `faas.id` depends on the cloud provider:

* **AWS Lambda:** The function [ARN](https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html).
Take care not to use the "invoked ARN" directly but replace any
[alias suffix](https://docs.aws.amazon.com/lambda/latest/dg/configuration-aliases.html) with the resolved function version, as the same runtime instance may be invokable with multiple
different aliases.
Take care not to use the "invoked ARN" directly but replace any
[alias suffix](https://docs.aws.amazon.com/lambda/latest/dg/configuration-aliases.html)
with the resolved function version, as the same runtime instance may be invokable with
multiple different aliases.
* **GCP:** The [URI of the resource](https://cloud.google.com/iam/docs/full-resource-names)
* **Azure:** The [Fully Qualified Resource ID](https://docs.microsoft.com/en-us/rest/api/resources/resources/get-by-id).

On some providers, it may not be possible to determine the full ID at startup,
which is why this field cannot be made required. For example, on AWS the account ID
part of the ARN is not available without calling another AWS API
which may be deemed too slow for a short-running lambda function.
As an alternative, consider setting `faas.id` as a span attribute instead.
* **Azure:** The [Fully Qualified Resource ID](https://docs.microsoft.com/en-us/rest/api/resources/resources/get-by-id) of the invoked function,
*not* the function app, having the form
`/subscriptions/<SUBSCIPTION_GUID>/resourceGroups/<RG>/providers/Microsoft.Web/sites/<FUNCAPP>/functions/<FUNC>`.
This means that a span attribute MUST be used, as an Azure function app can host multiple functions that would usually share
a TracerProvider (see also the paragraph below).

**[3]:** Depending on the cloud provider and platform, use:

Expand All @@ -53,3 +72,9 @@ As an alternative, consider setting `faas.id` as a span attribute instead.
<!-- endsemconv -->

Note: The resource attribute `faas.instance` differs from the span attribute `faas.execution`. For more information see the [Semantic conventions for FaaS spans](../../trace/semantic_conventions/faas.md#difference-between-execution-and-instance).

## Using span attributes instead of resource attributes

There are cases where a FaaS resource attribute is better applied as a span
attribute instead.
See the [FaaS trace conventions](../../trace/semantic_conventions/faas.md) for more.
18 changes: 17 additions & 1 deletion specification/trace/semantic_conventions/faas.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ See also the [additional instructions for instrumenting AWS Lambda](instrumentat
* [Function Name](#function-name)
* [Difference between execution and instance](#difference-between-execution-and-instance)
- [Incoming Invocations](#incoming-invocations)
* [Incoming FaaS Span attributes](#incoming-faas-span-attributes)
* [Resource attributes as incoming FaaS span attributes](#resource-attributes-as-incoming-faas-span-attributes)
- [Outgoing Invocations](#outgoing-invocations)
- [Function Trigger Type](#function-trigger-type)
* [Datasource](#datasource)
Expand Down Expand Up @@ -76,7 +78,7 @@ weaker "SHOULD" requirement). Consumers that needs such guarantee can use
For performance reasons (e.g. [AWS lambda], or [Azure functions]), FaaS providers allocate an execution environment for a single instance of a function that is used to serve multiple requests.
Developers exploit this fact to solve the **cold start** issue, caching expensive resource computations between different function executions.
Furthermore, FaaS providers encourage this behavior, e.g. [Google functions].
This field MAY be set to help correlate function executions that belong to the same execution environment.
The `faas.instance` resource attribute MAY be set to help correlate function executions that belong to the same execution environment.
The span attribute `faas.execution` differs from the [resource attribute][FaaS resource attributes] `faas.instance` in the following:

- `faas.execution` refers to the current request ID handled by the function;
Expand All @@ -92,6 +94,8 @@ This section describes incoming FaaS invocations as they are reported by the Faa

For incoming FaaS spans, the span kind MUST be `Server`.

### Incoming FaaS Span attributes

<!-- semconv faas_span.in -->
| Attribute | Type | Description | Examples | Required |
|---|---|---|---|---|
Expand All @@ -109,6 +113,18 @@ nothing to do with the underlying transport used to make the API
call to invoke the lambda, which is often HTTP).
<!-- endsemconv -->

### Resource attributes as incoming FaaS span attributes

In addition to the attributes listed above, any [FaaS](../../resource/semantic_conventions/faas.md) or [cloud](../../resource/semantic_conventions/cloud.md) resource attributes MAY
instead be set as span attributes on incoming FaaS invocation spans: In some
Oberon00 marked this conversation as resolved.
Show resolved Hide resolved
FaaS environments some of the information required for resource
Oberon00 marked this conversation as resolved.
Show resolved Hide resolved
attributes is only readily available in the context of an invocation (e.g. as part of a "request context" argument)
and while a separate API call to look up the resource information is often possible, it
may be prohibitively expensive due to cold start duration concerns.
The `faas.id` and `cloud.account.id` attributes on AWS are some examples.
In principle, the above considerations apply to any resource attribute that fulfills the criteria above
(not being readily available without some extra effort that could be expensive).

## Outgoing Invocations

This section describes outgoing FaaS invocations as they are reported by a client calling a FaaS instance.
Expand Down