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

Add yaml for FaaS trace attributes #1054

Merged
merged 7 commits into from
Oct 19, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
184 changes: 184 additions & 0 deletions semantic_conventions/trace/faas.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
groups:
- id: faas_span
prefix: faas
brief: >
This document defines how to describe an instance of a function that
Copy link
Member

Choose a reason for hiding this comment

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

IMHO we should not talk about "this document" in the YAML, as it may become javadoc or something else.

Oberon00 marked this conversation as resolved.
Show resolved Hide resolved
runs without provisioning or managing of servers (also known as
serverless) with spans.
thisthat marked this conversation as resolved.
Show resolved Hide resolved
attributes:
- id: trigger
required: always
brief: 'Type of the trigger on which the function is executed.'
type:
allow_custom_values: false
members:
- id: datasource
value: 'datasource'
brief: 'A response to some data source operation such as a database or filesystem read/write.'
- id: http
value: 'http'
brief: 'To provide an answer to an inbound HTTP request'
- id: pubsub
value: 'pubsub'
brief: 'A function is set to be executed when messages are sent to a messaging system.'
- id: timer
value: 'timer'
brief: 'A function is scheduled to be executed regularly.'
- id: other
value: 'other'
brief: 'If none of the other applies'
thisthat marked this conversation as resolved.
Show resolved Hide resolved
- id: execution
type: string
brief: "The execution id of the current function execution."
thisthat marked this conversation as resolved.
Show resolved Hide resolved
examples: 'af9d5aa4-a685-4c5f-a22b-444f80b3cc28'

- id: faas_span.datasource
prefix: faas.document
extends: faas_span
brief: >
Semantic Convention for FaaS triggered as a response to some data
source operation such as a database or filesystem read/write.
attributes:
- id: collection
type: string
required: always
brief: 'The name of the source on which the triggering operation was performed.'
note: >
For example, in Cloud Storage or S3 corresponds to the bucket name,
and in Cosmos DB to the database name.
examples: ['myBucketName', 'myDbName']
- id: operation
required: always
type:
allow_custom_values: true
members:
- id: insert
value: 'insert'
brief: 'When a new object is created.'
- id: edit
value: 'edit'
brief: 'When an object is modified.'
- id: delete
value: 'delete'
brief: 'When an object is deleted.'
brief: 'Describes the type of the operation that was performed on the data.'
- id: time
type: string
required: always
brief: >
A string containing the time when the data was accessed in the
[ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html)
format expressed in [UTC](https://www.w3.org/TR/NOTE-datetime).
examples: "2020-01-23T13:47:06Z"
- id: name
type: string
brief: 'The document name/table subjected to the operation.'
note: >
For example, in Cloud Storage or S3 is the name of
the file, and in Cosmos DB the table name.
examples: ["myFile.txt", "myTableName"]

- id: faas_span.http
extends: faas_span
brief: >
Semantic Convention for FaaS triggered as a response to some data
source operation such as a database or filesystem read/write.
constraints:
- include: http.server

- id: faas_span.pubsub
extends: faas_span
brief: >
Semantic Convention for FaaS set to be executed when messages are
sent to a messaging system.
constraints:
- include: messaging

- id: faas_span.timer
extends: faas_span
prefix: faas
brief: >
Semantic Convention for FaaS scheduled to be executed regularly.
attributes:
- id: time
type: string
required: always
brief: >
A string containing the function invocation time in the
[ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html)
format expressed in [UTC](https://www.w3.org/TR/NOTE-datetime).
examples: "2020-01-23T13:47:06Z"
- id: cron
type: string
brief: >
A string containing the schedule period as
[Cron Expression](https://docs.oracle.com/cd/E12058_01/doc/doc.1014/e12030/cron_expressions.htm).
examples: "0/5 * * * ? *"

- id: faas_span.in
extends: faas_span
span_kind: server
prefix: faas
brief: >
Contains additional attributes for incoming FaaS spans.
attributes:
- id: coldstart
type: boolean
brief: >
A boolean that is true if the serverless function is executed for the
first time (aka cold-start).
examples: 'true'
thisthat marked this conversation as resolved.
Show resolved Hide resolved

- id: faas_span.out
extends: faas_span
span_kind: client
prefix: faas
brief: >
Contains additional attributes for outgoing FaaS spans.
attributes:
- id: invoked_name
type: string
required: always
brief: >
The name of the invoked function.
note: >
SHOULD be equal to the `faas.name` resource attribute of the
invoked function.
examples: 'my-function'
- id: invoked_provider
type:
allow_custom_values: true
members:
- id: AWS
value: 'aws'
brief: 'Amazon Web Services'
- id: Azure
value: 'azure'
brief: 'Amazon Web Services'
- id: GCP
value: 'gcp'
brief: 'Google Cloud Platform'
required: always
brief: >
The cloud provider of the invoked function.
note: >
SHOULD be equal to the `cloud.provider` resource attribute of the
invoked function.
examples: 'aws'
- id: invoked_region
type: string
required:
conditional: >
For some cloud providers, like AWS or GCP, the region in which a
function is hosted is essential to uniquely identify the function
and also part of its endpoint. Since it's part of the endpoint
being called, the region is always known to clients. In these cases,
`faas.invoked_region` MUST be set accordingly. If the region is
unknown to the client or not required for identifying the invoked
function, setting `faas.invoked_region` is optional.
brief: >
The cloud region of the invoked function.
note: >
SHOULD be equal to the `cloud.region` resource attribute of the
invoked function.
examples: 'eu-central-1'
96 changes: 70 additions & 26 deletions specification/trace/semantic_conventions/faas.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,22 @@ Span `name` should be set to the function name being executed. Depending on the

If Spans following this convention are produced, a Resource of type `faas` MUST exist following the [Resource semantic convention](../../resource/semantic_conventions/faas.md#function-as-a-service).

| Attribute name | Notes and examples | Required? |
|---|---|--|
| `faas.trigger` | Type of the trigger on which the function is executed. <br > It SHOULD be one of the following strings: "datasource", "http", "pubsub", "timer", or "other". | See below. |
| `faas.execution` | String containing the execution id of the function. E.g. `af9d5aa4-a685-4c5f-a22b-444f80b3cc28` | No |
<!-- semconv faas_span -->
| Attribute | Type | Description | Example | Required |
|---|---|---|---|---|
| `faas.trigger` | string enum | Type of the trigger on which the function is executed. | `datasource` | Yes |
thisthat marked this conversation as resolved.
Show resolved Hide resolved
| `faas.execution` | string | The execution id of the current function execution. | `af9d5aa4-a685-4c5f-a22b-444f80b3cc28` | No |

`faas.trigger` MUST be one of the following:

| Value | Description |
|---|---|
| `datasource` | A response to some data source operation such as a database or filesystem read/write. |
| `http` | To provide an answer to an inbound HTTP request |
| `pubsub` | A function is set to be executed when messages are sent to a messaging system. |
| `timer` | A function is scheduled to be executed regularly. |
| `other` | If none of the other applies |
Copy link
Member

Choose a reason for hiding this comment

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

Did we have these descriptions in faas.md previously or these are new in this PR?

Copy link
Member

Choose a reason for hiding this comment

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

The descriptions are new but only taken over and paraphrased from the first sentence of the respective section for each trigger type.

<!-- endsemconv -->

On FaaS instances, `faas.trigger` MUST be set on incoming invocations.
Clients invoking FaaS instances MUST set `faas.trigger` on outgoing invocations, if it is known to the client.
Expand Down Expand Up @@ -68,9 +80,11 @@ This section describes incoming FaaS invocations as they are reported by the Faa

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

| Attribute | Type | Description | Required |
|---|---|---|---|
| `faas.coldstart` | boolean | Indicates that the serverless function is executed for the first time (aka cold start). | No |
<!-- semconv faas_span.in -->
| Attribute | Type | Description | Example | Required |
|---|---|---|---|---|
| `faas.coldstart` | boolean | A boolean that is true if the serverless function is executed for the first time (aka cold-start). | `true` | No |
<!-- endsemconv -->

## Outgoing Invocations

Expand All @@ -82,11 +96,29 @@ The values reported by the client for the attributes listed below SHOULD be equa
the corresponding [FaaS resource attributes][] and [Cloud resource attributes][],
which the invoked FaaS instance reports about itself, if it's instrumented.

| Attribute | Corresponding resource attribute | Type | Description | Example | Required |
|---|---|---|---|---|---|
| `faas.invoked_name` | `faas.name` | string | The name of the invoked function. | `my-function` | Yes |
| `faas.invoked_provider` | `cloud.provider` | string | The cloud provider of the invoked function. | `aws` | Yes |
| `faas.invoked_region` | `cloud.region` | string | The cloud region of the invoked function. | `eu-central-1` | See below |
<!-- semconv faas_span.out -->
| Attribute | Type | Description | Example | Required |
|---|---|---|---|---|
| `faas.invoked_name` | string | The name of the invoked function. [1] | `my-function` | Yes |
| `faas.invoked_provider` | string | The cloud provider of the invoked function. [2] | `aws` | Yes |
| `faas.invoked_region` | string | The cloud region of the invoked function. [3] | `eu-central-1` | Conditional [4] |

**[1]:** SHOULD be equal to the `faas.name` resource attribute of the invoked function.

**[2]:** SHOULD be equal to the `cloud.provider` resource attribute of the invoked function.

**[3]:** SHOULD be equal to the `cloud.region` resource attribute of the invoked function.

**[4]:** For some cloud providers, like AWS or GCP, the region in which a function is hosted is essential to uniquely identify the function and also part of its endpoint. Since it's part of the endpoint being called, the region is always known to clients. In these cases, `faas.invoked_region` MUST be set accordingly. If the region is unknown to the client or not required for identifying the invoked function, setting `faas.invoked_region` is optional.
thisthat marked this conversation as resolved.
Show resolved Hide resolved

`faas.invoked_provider` MUST be one of the following or, if none of the listed values apply, a custom value:

| Value | Description |
|---|---|
| `aws` | Amazon Web Services |
| `azure` | Amazon Web Services |
| `gcp` | Google Cloud Platform |
<!-- endsemconv -->

For some cloud providers, like AWS or GCP, the region in which a function is hosted is essential
to uniquely identify the function and also part of its endpoint.
Expand All @@ -107,12 +139,26 @@ This section describes how to handle the span creation and additional attributes
A datasource function is triggered as a response to some data source operation such as a database or filesystem read/write.
For `faas` spans with trigger `datasource`, it is recommended to set the following attributes.

| Attribute name | Notes and examples | Required? |
|---|---|--|
| `faas.document.collection` | The name of the source on which the operation was perfomed. For example, in Cloud Storage or S3 corresponds to the bucket name, and in Cosmos DB to the database name. | Yes |
| `faas.document.operation` | Describes the type of the operation that was performed on the data.<br /> It SHOULD be one of the following strings: "insert", "edit", "delete". | Yes |
| `faas.document.time` | A string containing the time when the data was accessed in the [ISO 8601] format expressed in [UTC]. E.g. `"2020-01-23T13:47:06Z"` | Yes |
| `faas.document.name` | The document name/table subjected to the operation.<br /> For example, in Cloud Storage or S3 is the name of the file, and in Cosmos DB the table name. | No |
<!-- semconv faas_span.datasource -->
| Attribute | Type | Description | Example | Required |
|---|---|---|---|---|
| `faas.document.collection` | string | The name of the source on which the triggering operation was performed. [1] | `myBucketName`<br>`myDbName` | Yes |
| `faas.document.operation` | string | Describes the type of the operation that was performed on the data. | `insert` | Yes |
| `faas.document.time` | string | A string containing the time when the data was accessed in the [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format expressed in [UTC](https://www.w3.org/TR/NOTE-datetime). | `2020-01-23T13:47:06Z` | Yes |
| `faas.document.name` | string | The document name/table subjected to the operation. [2] | `myFile.txt`<br>`myTableName` | No |

**[1]:** For example, in Cloud Storage or S3 corresponds to the bucket name, and in Cosmos DB to the database name.

**[2]:** For example, in Cloud Storage or S3 is the name of the file, and in Cosmos DB the table name.
thisthat marked this conversation as resolved.
Show resolved Hide resolved

`faas.document.operation` MUST be one of the following or, if none of the listed values apply, a custom value:

| Value | Description |
|---|---|
| `insert` | When a new object is created. |
| `edit` | When an object is modified. |
| `delete` | When an object is deleted. |
<!-- endsemconv -->

### HTTP

Expand All @@ -129,14 +175,12 @@ This way, it is possible to correlate each individual message with its execution

A function is scheduled to be executed regularly. The following additional attributes are recommended.

| Attribute name | Notes and examples | Required? |
|---|---|--|
| `faas.time` | A string containing the function invocation time in the [ISO 8601] format expressed in [UTC]. E.g. `"2020-01-23T13:47:06Z"`| Yes |
| `faas.cron` | A string containing the schedule period as [Cron Expression]. E.g. `"0/5 * * * ? *"`| No |

[Cron Expression]: https://docs.oracle.com/cd/E12058_01/doc/doc.1014/e12030/cron_expressions.htm
[ISO 8601]: https://www.iso.org/iso-8601-date-and-time-format.html
[UTC]: https://www.w3.org/TR/NOTE-datetime
<!-- semconv faas_span.timer -->
| Attribute | Type | Description | Example | Required |
|---|---|---|---|---|
| `faas.time` | string | A string containing the function invocation time in the [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format expressed in [UTC](https://www.w3.org/TR/NOTE-datetime). | `2020-01-23T13:47:06Z` | Yes |
| `faas.cron` | string | A string containing the schedule period as [Cron Expression](https://docs.oracle.com/cd/E12058_01/doc/doc.1014/e12030/cron_expressions.htm). | `0/5 * * * ? *` | No |
<!-- endsemconv -->

### Other

Expand Down