-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
replace invalid characters in ids (#106)
It is easy enough to break the spectatord line protocol, if any of the control characters (`:,=`) are inserted in unexpected places. Since metric names and tags are often programmatically generated, we want to only construct id strings which are valid.
- Loading branch information
1 parent
3a8023c
commit 8b9d409
Showing
16 changed files
with
193 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
.idea/ | ||
cmake-build-debug | ||
cmake-build/ | ||
spectator/valid_chars.inc | ||
venv/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// generate the atlas valid charsets | ||
|
||
#include <array> | ||
#include <fstream> | ||
|
||
void dump_array(std::ostream& os, const std::string& name, const std::array<bool, 256>& chars) { | ||
os << "static constexpr std::array<bool, 256> " << name << " = {{"; | ||
|
||
os << chars[0]; | ||
for (auto i = 1u; i < chars.size(); ++i) { | ||
os << ", " << chars[i]; | ||
} | ||
|
||
os << "}};\n"; | ||
} | ||
|
||
int main(int argc, char* argv[]) { | ||
std::ofstream of; | ||
if (argc > 1) { | ||
of.open(argv[1]); | ||
} else { | ||
of.open("/dev/stdout"); | ||
} | ||
|
||
// default false | ||
std::array<bool, 256> charsAllowed{}; | ||
for (int i = 0; i < 256; ++i) { | ||
charsAllowed[i] = false; | ||
} | ||
|
||
// configure allowed characters | ||
charsAllowed['.'] = true; | ||
charsAllowed['-'] = true; | ||
|
||
for (auto ch = '0'; ch <= '9'; ++ch) { | ||
charsAllowed[ch] = true; | ||
} | ||
for (auto ch = 'a'; ch <= 'z'; ++ch) { | ||
charsAllowed[ch] = true; | ||
} | ||
for (auto ch = 'A'; ch <= 'Z'; ++ch) { | ||
charsAllowed[ch] = true; | ||
} | ||
charsAllowed['~'] = true; | ||
charsAllowed['^'] = true; | ||
|
||
dump_array(of, "kAtlasChars", charsAllowed); | ||
} |