Skip to content

Commit

Permalink
Generate FaaS metrics from YAML
Browse files Browse the repository at this point in the history
  • Loading branch information
joaopgrassi committed Jul 6, 2023
1 parent ded7a09 commit 14ecb07
Show file tree
Hide file tree
Showing 5 changed files with 650 additions and 124 deletions.
77 changes: 77 additions & 0 deletions semantic_conventions/faas-common.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
groups:
- id: attributes.faas.common
type: attribute_group
brief: "Describes FaaS attributes."
prefix: faas
attributes:
- id: trigger
brief: 'Type of the trigger which caused this function invocation.'
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 others apply'
- id: invoked_name
type: string
requirement_level: required
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: 'alibaba_cloud'
value: 'alibaba_cloud'
brief: 'Alibaba Cloud'
- id: 'aws'
value: 'aws'
brief: 'Amazon Web Services'
- id: 'azure'
value: 'azure'
brief: 'Microsoft Azure'
- id: 'gcp'
value: 'gcp'
brief: 'Google Cloud Platform'
- id: 'tencent_cloud'
value: 'tencent_cloud'
brief: 'Tencent Cloud'
requirement_level: required
brief: >
The cloud provider of the invoked function.
note: >
SHOULD be equal to the `cloud.provider` resource attribute of the
invoked function.
- id: invoked_region
type: string
requirement_level:
conditionally_required: >
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'
108 changes: 108 additions & 0 deletions semantic_conventions/metrics/faas-metrics.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
groups:
- id: metric.faas.invoke_duration
type: metric
metric_name: faas.invoke_duration
brief: "Measures the duration of the invocation"
instrument: histogram
unit: "ms"
attributes:
- ref: faas.trigger
- ref: faas.invoked_name
- ref: faas.invoked_provider
- ref: faas.invoked_region

- id: metric.faas.init_duration
type: metric
metric_name: faas.init_duration
brief: "Measures the duration of the function's initialization, such as a cold start"
instrument: histogram
unit: "ms"
attributes:
- ref: faas.trigger
- ref: faas.invoked_name
- ref: faas.invoked_provider
- ref: faas.invoked_region

- id: metric.faas.coldstarts
type: metric
metric_name: faas.coldstarts
brief: "Number of invocation cold starts"
instrument: counter
unit: "{coldstart}"
attributes:
- ref: faas.trigger
- ref: faas.invoked_name
- ref: faas.invoked_provider
- ref: faas.invoked_region

- id: metric.faas.errors
type: metric
metric_name: faas.errors
brief: "Number of invocation errors"
instrument: counter
unit: "{error}"
attributes:
- ref: faas.trigger
- ref: faas.invoked_name
- ref: faas.invoked_provider
- ref: faas.invoked_region

- id: metric.faas.invocations
type: metric
metric_name: faas.invocations
brief: "Number of successful invocations"
instrument: counter
unit: "{invocation}"
attributes:
- ref: faas.trigger
- ref: faas.invoked_name
- ref: faas.invoked_provider
- ref: faas.invoked_region

- id: metric.faas.timeouts
type: metric
metric_name: faas.timeouts
brief: "Number of invocation timeouts"
instrument: counter
unit: "{timeout}"
attributes:
- ref: faas.trigger
- ref: faas.invoked_name
- ref: faas.invoked_provider
- ref: faas.invoked_region

- id: metric.faas.mem_usage
type: metric
metric_name: faas.mem_usage
brief: "Distribution of max memory usage per invocation"
instrument: histogram
unit: "By"
attributes:
- ref: faas.trigger
- ref: faas.invoked_name
- ref: faas.invoked_provider
- ref: faas.invoked_region

- id: metric.faas.cpu_usage
type: metric
metric_name: faas.cpu_usage
brief: "Distribution of CPU usage per invocation"
instrument: histogram
unit: "ms"
attributes:
- ref: faas.trigger
- ref: faas.invoked_name
- ref: faas.invoked_provider
- ref: faas.invoked_region

- id: metric.faas.net_io
type: metric
metric_name: faas.net_io
brief: "Distribution of net I/O usage per invocation"
instrument: histogram
unit: "By"
attributes:
- ref: faas.trigger
- ref: faas.invoked_name
- ref: faas.invoked_provider
- ref: faas.invoked_region
94 changes: 17 additions & 77 deletions semantic_conventions/trace/faas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ groups:
runs without provisioning or managing of servers (also known as
serverless functions or Function as a Service (FaaS)) with spans.
attributes:
- id: trigger
brief: 'Type of the trigger which caused this function invocation.'
- ref: faas.trigger
note: |
For the server/consumer span on the incoming side,
`faas.trigger` MUST be set.
Expand All @@ -19,33 +18,15 @@ groups:
trigger that corresponding incoming would have (i.e., this has
nothing to do with the underlying transport used to make the API
call to invoke the lambda, which is often HTTP).
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 others apply'
- id: invocation_id
type: string
brief: 'The invocation ID of the current function invocation.'
examples: 'af9d5aa4-a685-4c5f-a22b-444f80b3cc28'
- ref: cloud.resource_id

- id: faas_span.datasource
prefix: faas.document
type: span
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.
Expand Down Expand Up @@ -90,24 +71,23 @@ groups:

- id: faas_span.http
type: span
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: trace.http.server
attributes: []

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

- id: faas_span.timer
extends: faas_span
prefix: faas
type: span
brief: >
Expand All @@ -128,7 +108,6 @@ groups:
examples: "0/5 * * * ? *"

- id: faas_span.in
extends: faas_span
span_kind: server
prefix: faas
type: span
Expand All @@ -142,63 +121,24 @@ groups:
first time (aka cold-start).
- ref: faas.trigger
requirement_level: required
note: |
For the server/consumer span on the incoming side,
`faas.trigger` MUST be set.
Clients invoking FaaS instances usually cannot set `faas.trigger`,
since they would typically need to look in the payload to determine
the event type. If clients set it, it should be the same as the
trigger that corresponding incoming would have (i.e., this has
nothing to do with the underlying transport used to make the API
call to invoke the lambda, which is often HTTP).
- id: faas_span.out
extends: faas_span
span_kind: client
prefix: faas
type: span
brief: >
Contains additional attributes for outgoing FaaS spans.
attributes:
- id: invoked_name
type: string
requirement_level: required
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: 'alibaba_cloud'
value: 'alibaba_cloud'
brief: 'Alibaba Cloud'
- id: 'aws'
value: 'aws'
brief: 'Amazon Web Services'
- id: 'azure'
value: 'azure'
brief: 'Microsoft Azure'
- id: 'gcp'
value: 'gcp'
brief: 'Google Cloud Platform'
- id: 'tencent_cloud'
value: 'tencent_cloud'
brief: 'Tencent Cloud'
requirement_level: required
brief: >
The cloud provider of the invoked function.
note: >
SHOULD be equal to the `cloud.provider` resource attribute of the
invoked function.
- id: invoked_region
type: string
requirement_level:
conditionally_required: >
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'
- ref: faas.invoked_name
- ref: faas.invoked_provider
- ref: faas.invoked_region
Loading

0 comments on commit 14ecb07

Please sign in to comment.