in pkg/plugin/cloudtrace/cloudtrace.go [147:212]
func getFilterKeyValue(qTFilter string) (key string, value string, err error) {
// Filter part must be in form [key]:[value] from user
qTFilterParts := strings.SplitN(qTFilter, ":", 2)
if len(qTFilterParts) != 2 {
return "", "", fmt.Errorf("bad filter [%s]. Must be in form [key]:[value]", qTFilter)
}
key = qTFilterParts[0]
value = qTFilterParts[1]
// OR for generic labels filter must be in form LABEL:[key]:[value] from user
if strings.ToLower(key) == "label" {
qTFilterParts := strings.SplitN(value, ":", 2)
if len(qTFilterParts) != 2 {
return "", "", fmt.Errorf("bad filter [%s]. Must be in form LABEL:[key]:[value]", qTFilter)
}
// Cloud Trace API should not have "LABEL:" in filter
key = qTFilterParts[0]
value = qTFilterParts[1]
}
// Convert key to Cloud Trace API expected form if needed
switch key {
case "RootSpan":
key = "root"
case "SpanName":
key = "span"
case "HasLabel":
key = "label"
case "MinLatency":
key = "latency"
case "URL":
key = "url"
case "Method":
key = "method"
// Currently matches the Google Cloud Trace UI filter, but ignores "service.version" matches
case "Version":
key = gaeServiceVersionKey
// Currently matches the Google Cloud Trace UI filter, but ignores "service.name" matches
case "Service":
key = gaeServiceKey
case "Status":
key = "/http/status_code"
}
// If the value has less than 2 chars, no need to check for special filter chars
if len(value) < 2 {
return key, value, nil
}
firstChar := string(value[0])
secondChar := string(value[1])
// Move specials chars from the front of value to key for Google Cloud Trace compatibility
if (secondChar == "^" && firstChar == "+") || (secondChar == "+" && firstChar == "^") {
key = fmt.Sprintf("+^%s", key)
value = value[2:]
} else if firstChar == "+" || firstChar == "^" {
key = fmt.Sprintf("%s%s", firstChar, key)
value = value[1:]
}
return key, value, nil
}