groups:
  - id: faas_span
    prefix: faas
    type: span
    brief: >
        This semantic convention describes an instance of a function that
        runs without provisioning or managing of servers (also known as
        serverless functions or Function as a Service (FaaS)) with spans.
    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).
      - 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
    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
        requirement_level: required
        brief: >
          The name of the source on which the triggering operation was performed.
          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
        requirement_level: required
        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
        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.
          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
    type: 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
    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
    prefix: faas
    type: span
    brief: >
      Semantic Convention for FaaS scheduled to be executed regularly.
    attributes:
      - id: time
        type: string
        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
    span_kind: server
    prefix: faas
    type: span
    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).
      - 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
    span_kind: client
    prefix: faas
    type: span
    brief: >
      Contains additional attributes for outgoing FaaS spans.
    attributes:
      - ref: faas.invoked_name
      - ref: faas.invoked_provider
      - ref: faas.invoked_region
