groups:
  - id: attributes.db.client.minimal
    type: attribute_group
    brief: 'Database Client attributes'
    stability: experimental
    attributes:
      - ref: server.address
        brief: >
          Name of the database host.
      - ref: server.port
        requirement_level:
          conditionally_required: If using a port other than the default port for this DBMS and if `server.address` is set.
      - ref: db.response.status_code
        requirement_level:
          conditionally_required: If the operation failed and status code is available.
      - ref: error.type
        requirement_level:
          conditionally_required: If and only if the operation failed.
        note: >
          The `error.type` SHOULD match the `db.response.status_code` returned by the database or the client library,
          or the canonical name of exception that occurred.

          When using canonical exception type name, instrumentation SHOULD do the best effort to
          report the most relevant type. For example, if the original exception is wrapped into a
          generic one, the original exception SHOULD be preferred.

          Instrumentations SHOULD document how `error.type` is populated.

  - id: attributes.azure.cosmosdb.minimal
    type: attribute_group
    brief: 'Azure Cosmos DB Client attributes'
    stability: development
    extends: attributes.db.client.minimal
    attributes:
      # TODO: add db.system once https://github.com/open-telemetry/build-tools/issues/192 is possible
      # - ref: db.system.name
      #   requirement_level:
      #     conditionally_required: if available
      - ref: db.operation.name
        requirement_level:  # TODO (trask) simplify
          conditionally_required: >
            If readily available and if there is a single operation name that describes the
            database call. The operation name MAY be parsed from the query text,
            in which case it SHOULD be the single operation name found in the query.
      - ref: db.collection.name
        brief: Cosmos DB container name.
        requirement_level:
          conditionally_required: If available.
      - ref: db.namespace
        requirement_level:
          conditionally_required: If available.
        note: ""  # overriding the base note
      - ref: azure.cosmosdb.response.sub_status_code
        requirement_level:
          conditionally_required: when response was received and contained sub-code.
      - ref: azure.cosmosdb.consistency.level
        requirement_level:
          conditionally_required: If available.

  - id: attributes.db.client.with_query
    extends: attributes.db.client.minimal
    type: attribute_group
    stability: experimental
    brief: This group defines the attributes describing database operations that
      may have queries.
    attributes:
      - ref: db.query.text
      - ref: db.query.summary
        requirement_level:
          recommended: if readily available or if instrumentation supports query summarization.

  - id: attributes.db.client.with_query_and_collection
    extends: attributes.db.client.with_query
    type: attribute_group
    stability: experimental
    brief: This group defines the attributes describing database operations that
      have operation name, collection name and query.
    attributes:
      - ref: db.operation.name
        requirement_level:  # TODO (trask) simplify
          conditionally_required: >
            If readily available and if there is a single operation name that describes the
            database call. The operation name MAY be parsed from the query text,
            in which case it SHOULD be the single operation name found in the query.
      - ref: db.collection.name
        requirement_level:  # TODO (trask) simplify
          conditionally_required: >
            If readily available and if a database call is performed on a single collection.
            The collection name MAY be parsed from the query text,
            in which case it SHOULD be the single collection name in the query.
