function extractAttributeValue({ accountId, attribute, excludeAttributes, span }) {
  const { key, mappings, name, template } = attribute
  let value
  if (key) {
    value = span.attributes[key]
    excludeAttributes.add(key)
  } else if (attribute?.value) {
    value = attribute.value
    excludeAttributes.add(name)
  } else if (template) {
    const rules = buildRuleMappings(mappings)
    value = transformTemplate(template, { ...span?.attributes, accountId }, rules)
  }

  return value
}
Extracts the value of an attribute from a span, based on its key, value, or template.
If the attribute has a key, it will be used to get the value from the span's attributes.
If the attribute has a value, it will be used directly.
If the attribute has a template, it will be transformed using the span's attributes and any provided mappings.
@param {Object} params - The parameters for extracting the attribute value.
@param {string} params.accountId - The value of agent.config.cloud.account_id
@param {Object} params.attribute - The attribute object containing key, value, or template.
@param {Set} params.excludeAttributes - A set to keep track of excluded attributes.
@param {Object} params.span - The span object containing attributes.
@returns {string} - The extracted value of the attribute.