function determineStageSpecificObservabilityProvider(observability, app) {
  if (observability === null || observability === undefined) return null

  const knownProviders = {
    axiom: ObservabilityProvider.AXIOM,
    dashboard: ObservabilityProvider.DASHBOARD,
    disabled: ObservabilityProvider.DISABLED,
  }

  let providerName

  if (typeof observability === 'string') {
    providerName = observability.toLowerCase()
  } else if (typeof observability === 'boolean') {
    if (!app) {
      throw new ServerlessError(
        'To instrument your service, you must set the "app" property in your config file.',
        'OBSERVABILITY_APP_NOT_SET',
      )
    }
    if (observability === true) {
      providerName = ObservabilityProvider.DASHBOARD
    } else {
      providerName = ObservabilityProvider.DISABLED
    }
  } else if (
    typeof observability === 'object' &&
    typeof observability.provider === 'string'
  ) {
    providerName = observability.provider.toLowerCase()
  }

  if (providerName) {
    const provider = knownProviders[providerName] || null
    if (!provider) {
      throw new ServerlessError(
        `Unknown observability provider: ${providerName}`,
        'UNKNOWN_OBSERVABILITY_PROVIDER',
      )
    }
    return provider
  }

  throw new ServerlessError(
    `Invalid observability configuration. Expected a boolean, string or an object with a "provider" property. Received: ${yaml.dump(observability)}`,
    'INVALID_OBSERVABILITY_CONFIGURATION',
  )
}
Returns the observability provider based on the observability configuration
@param {boolean|string|Object} observability The observability configuration
@param {Object} app The app name
@returns {string|null} The observability provider