#include "common/config/well_known_names.h" namespace Envoy { namespace Config { TagNameValues::TagNameValues() { // Note: the default regexes are defined below in the order that they will typically be matched // (see the TagExtractor class definition for an explanation of the iterative matching process). // This ordering is roughly from most specific to least specific. Despite the fact that these // regexes are defined with a particular ordering in mind, users can customize the ordering of the // processing of the default tag extraction regexes and include custom tags with regexes via the // bootstrap configuration. Because of this flexibility, these regexes are designed to not // interfere with one another no matter the ordering. They are tested in forward and reverse // ordering to ensure they will be safe in most ordering configurations. // To give a more user-friendly explanation of the intended behavior of each regex, each is // preceded by a comment with a simplified notation to explain what the regex is designed to // match: // - The text that the regex is intended to capture will be enclosed in (). // - Other default tags that are expected to exist in the name (and may or may not have been // removed before this regex has been applied) are enclosed in []. // - Stand-ins for a variable segment of the name (including inside capture groups) will be // enclosed in <>. // - Typical * notation will be used to denote an arbitrary set of characters. // *_rq(_) addRegex(RESPONSE_CODE, "_rq(_(\\d{3}))$", "_rq_"); // *_rq_()xx addRegex(RESPONSE_CODE_CLASS, "_rq_(\\d)xx$", "_rq_"); // http.[.]dynamodb.table.[.]capacity.[.](__partition_id=) addRegex(DYNAMO_PARTITION_ID, "^http(?=\\.).*?\\.dynamodb\\.table(?=\\.).*?\\." "capacity(?=\\.).*?(\\.__partition_id=(\\w{7}))$", ".dynamodb.table."); // http.[.]dynamodb.operation.(.) or // http.[.]dynamodb.table.[.]capacity.(.)[] addRegex(DYNAMO_OPERATION, "^http(?=\\.).*?\\.dynamodb.(?:operation|table(?=" "\\.).*?\\.capacity)(\\.(.*?))(?:\\.|$)", ".dynamodb."); // mongo.[.]collection.[.]callsite.(.)query. addRegex(MONGO_CALLSITE, R"(^mongo(?=\.).*?\.collection(?=\.).*?\.callsite\.((.*?)\.).*?query.\w+?$)", ".collection."); // http.[.]dynamodb.table.(.) or // http.[.]dynamodb.error.(.)* addRegex(DYNAMO_TABLE, R"(^http(?=\.).*?\.dynamodb.(?:table|error)\.((.*?)\.))", ".dynamodb."); // mongo.[.]collection.(.)query. addRegex(MONGO_COLLECTION, R"(^mongo(?=\.).*?\.collection\.((.*?)\.).*?query.\w+?$)", ".collection."); // mongo.[.]cmd.(.) addRegex(MONGO_CMD, R"(^mongo(?=\.).*?\.cmd\.((.*?)\.)\w+?$)", ".cmd."); // cluster.[.]grpc.[.](.) addRegex(GRPC_BRIDGE_METHOD, R"(^cluster(?=\.).*?\.grpc(?=\.).*\.((.*?)\.)\w+?$)", ".grpc."); // http.[.]user_agent.(.) addRegex(HTTP_USER_AGENT, R"(^http(?=\.).*?\.user_agent\.((.*?)\.)\w+?$)", ".user_agent."); // vhost.[.]vcluster.(.) addRegex(VIRTUAL_CLUSTER, R"(^vhost(?=\.).*?\.vcluster\.((.*?)\.)\w+?$)", ".vcluster."); // http.[.]fault.(.) addRegex(FAULT_DOWNSTREAM_CLUSTER, R"(^http(?=\.).*?\.fault\.((.*?)\.)\w+?$)", ".fault."); // listener.[
.]ssl.cipher.() addRegex(SSL_CIPHER, R"(^listener(?=\.).*?\.ssl\.cipher(\.(.*?))$)"); // cluster.[.]ssl.ciphers.() addRegex(SSL_CIPHER_SUITE, R"(^cluster(?=\.).*?\.ssl\.ciphers(\.(.*?))$)", ".ssl.ciphers."); // cluster.[.]grpc.(.)* addRegex(GRPC_BRIDGE_SERVICE, R"(^cluster(?=\.).*?\.grpc\.((.*?)\.))", ".grpc."); // tcp.(.) addRegex(TCP_PREFIX, R"(^tcp\.((.*?)\.)\w+?$)"); // udp.(.) addRegex(UDP_PREFIX, R"(^udp\.((.*?)\.)\w+?$)"); // auth.clientssl.(.) addRegex(CLIENTSSL_PREFIX, R"(^auth\.clientssl\.((.*?)\.)\w+?$)"); // ratelimit.(.) addRegex(RATELIMIT_PREFIX, R"(^ratelimit\.((.*?)\.)\w+?$)"); // cluster.(.)* addRe2(CLUSTER_NAME, "^cluster\\.(([^\\.]+)\\.).*"); // listener.[
.]http.(.)* addRegex(HTTP_CONN_MANAGER_PREFIX, R"(^listener(?=\.).*?\.http\.((.*?)\.))", ".http."); // http.(.)* addRegex(HTTP_CONN_MANAGER_PREFIX, "^http\\.((.*?)\\.)"); // listener.(
.)* addRegex(LISTENER_ADDRESS, R"(^listener\.(((?:[_.[:digit:]]*|[_\[\]aAbBcCdDeEfF[:digit:]]*))\.))"); // vhost.(.)* addRegex(VIRTUAL_HOST, "^vhost\\.((.*?)\\.)"); // mongo.(.)* addRegex(MONGO_PREFIX, "^mongo\\.((.*?)\\.)"); // http.[.]rds.(.) addRegex(RDS_ROUTE_CONFIG, R"(^http(?=\.).*?\.rds\.((.*?)\.)\w+?$)", ".rds."); // listener_manager.(worker_.)* addRegex(WORKER_ID, R"(^listener_manager\.((worker_\d+)\.))", "listener_manager.worker_"); } void TagNameValues::addRegex(const std::string& name, const std::string& regex, const std::string& substr) { descriptor_vec_.emplace_back(Descriptor{name, regex, substr, Regex::Type::StdRegex}); } void TagNameValues::addRe2(const std::string& name, const std::string& regex, const std::string& substr) { descriptor_vec_.emplace_back(Descriptor{name, regex, substr, Regex::Type::Re2}); } } // namespace Config } // namespace Envoy