function extractPathForTransaction(
  req,
  options = {},
) {
  const method = req.method && req.method.toUpperCase();

  let path = '';
  let source = 'url';

  // Check to see if there's a parameterized route we can use (as there is in Express)
  if (options.customRoute || req.route) {
    path = options.customRoute || `${req.baseUrl || ''}${req.route && req.route.path}`;
    source = 'route';
  }

  // Otherwise, just take the original URL
  else if (req.originalUrl || req.url) {
    path = url.stripUrlQueryAndFragment(req.originalUrl || req.url || '');
  }

  let name = '';
  if (options.method && method) {
    name += method;
  }
  if (options.method && options.path) {
    name += ' ';
  }
  if (options.path && path) {
    name += path;
  }

  return [name, source];
}
Extracts a complete and parameterized path from the request object and uses it to construct transaction name.
If the parameterized transaction name cannot be extracted, we fall back to the raw URL.

Additionally, this function determines and returns the transaction name source

eg. GET /mountpoint/user/:id

@param req A request object
@param options What to include in the transaction name (method, path, or a custom route name to be
               used instead of the request's route)

@returns A tuple of the fully constructed transaction name [0] and its source [1] (can be either 'route' or 'url')