groups:
  - id: faas.attributes
    type: attribute_group
    stability: development
    brief: >
      This span represents a serverless function (FaaS) execution.
    note: |
      Span `name` should be set to the function name being executed.
      Depending on the value of the `faas.trigger` attribute, additional attributes MUST be set.

      For example, an `http` trigger SHOULD follow the [HTTP Server semantic conventions](/docs/http/http-spans.md#http-server-span).
      For more information, refer to the [Function Trigger Type](#function-trigger-type) section.

      If Spans following this convention are produced, a Resource of type `faas` MUST exist following the [Resource semantic convention](/docs/resource/faas.md).
    attributes:
      - ref: faas.trigger
        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).
      - ref: faas.invocation_id
      - ref: cloud.resource_id

  - id: span.faas.datasource.server
    type: span
    span_kind: server
    stability: development
    brief: >
      This span represents server side if the FaaS invocations triggered in response
      response to some data source operation such as a database or filesystem read/write.
    attributes:
      - ref: faas.document.collection
        requirement_level: required
      - ref: faas.document.operation
        requirement_level: required
      - ref: faas.document.time
      - ref: faas.document.name

  - id: span.faas.timer.server
    type: span
    span_kind: server
    stability: development
    brief: >
      This span represents server side if the FaaS invocations triggered by a timer.
    attributes:
      - ref: faas.time
      - ref: faas.cron

  - id: span.faas.server
    span_kind: server
    type: span
    stability: development
    brief: >
      This span represents server (incoming) side of the FaaS invocation.
    attributes:
      - ref: faas.coldstart
      - 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: span.faas.client
    span_kind: client
    type: span
    stability: development
    brief: >
      This span represents an outgoing call to a FaaS service.
    note: |
      The values reported by the client for the attributes listed below SHOULD be equal to
      the corresponding [FaaS resource attributes][] and [Cloud resource attributes][],
      which the invoked FaaS instance reports about itself, if it's instrumented.
    attributes:
      - ref: faas.invoked_name
        requirement_level: required
      - ref: faas.invoked_provider
        requirement_level: required
      - ref: faas.invoked_region
        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.
