Skip to content

Commit

Permalink
fix getConsumerNameFromFileName to work with a longer file path
Browse files Browse the repository at this point in the history
  • Loading branch information
Blackbaud-KevinHutson committed Oct 9, 2018
1 parent 7d9d9b7 commit 3965857
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/parse_lag.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ function extract_header_fields(line) {
// In order to easily resolve the consumer's name, we are using the filename as an identifier
// Otherwise, you could use CLIENT_ID from the consumer lag report.
// However, in our case, we attach a UUID and instance to every consumer making it very difficult to parse out the base consumer name.
// Example: Expected input: "some_directory/consumerName~sometimestamp.txt"
// Example: Expected input: "/opt/some_directory/consumerName~sometimestamp.txt"
// Returns consumerName
function getConsumerNameFromFileName(file_path) {
let directory_and_file = file_path.split('~')[0];
// grab the second element, the filename to get the consumer's name
return directory_and_file.split('/')[1];
// grab the last element, the filename to get the consumer's name
let elements = directory_and_file.split('/');
return elements[elements.length-1];
}

// Parses a file. filename is assumed to contain the Consumer's name.
Expand Down

0 comments on commit 3965857

Please sign in to comment.