Skip to content

Commit

Permalink
ignore any error that has stop_youtube
Browse files Browse the repository at this point in the history
  • Loading branch information
erwinmombay committed Apr 27, 2017
1 parent c3126da commit 9ce1ab5
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 11 deletions.
2 changes: 1 addition & 1 deletion tools/errortracker/app.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
application: amp-error-reporting
version: 15
version: 16
runtime: go
api_version: go1

Expand Down
41 changes: 31 additions & 10 deletions tools/errortracker/errortracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func handle(w http.ResponseWriter, r *http.Request) {
// Fill query params into JSON struct.
line, _ := strconv.Atoi(r.URL.Query().Get("l"))
errorType := "default"
isUserError := false;
isUserError := false
if r.URL.Query().Get("a") == "1" {
errorType = "assert"
isUserError = true
Expand All @@ -116,8 +116,8 @@ func handle(w http.ResponseWriter, r *http.Request) {
// docs) we log as "ERROR".
isCdn := false
if strings.HasPrefix(r.Referer(), "https://cdn.ampproject.org/") ||
strings.Contains(r.Referer(), ".cdn.ampproject.org/") ||
strings.Contains(r.Referer(), ".ampproject.net/") {
strings.Contains(r.Referer(), ".cdn.ampproject.org/") ||
strings.Contains(r.Referer(), ".ampproject.net/") {
severity = "ERROR"
level = logging.Error
errorType += "-cdn"
Expand All @@ -128,7 +128,7 @@ func handle(w http.ResponseWriter, r *http.Request) {
is3p := false
runtime := r.URL.Query().Get("rt")
if runtime != "" {
errorType += "-" + runtime;
errorType += "-" + runtime
if runtime == "inabox" {
severity = "ERROR"
level = logging.Error
Expand All @@ -144,10 +144,10 @@ func handle(w http.ResponseWriter, r *http.Request) {
errorType += "-1p"
}
}
isCanary := false;
isCanary := false
if r.URL.Query().Get("ca") == "1" {
errorType += "-canary"
isCanary = true;
isCanary = true
}
if r.URL.Query().Get("ex") == "1" {
errorType += "-expected"
Expand All @@ -156,15 +156,15 @@ func handle(w http.ResponseWriter, r *http.Request) {
throttleRate := 0.01

if isCanary {
throttleRate = 1.0 // Explicitly log all canary errors.
throttleRate = 1.0 // Explicitly log all canary errors.
} else if is3p {
throttleRate = 0.1
} else if isCdn {
throttleRate = 0.1
}

if isUserError {
throttleRate = throttleRate / 10;
throttleRate = throttleRate / 10
}

if !(sample <= throttleRate) {
Expand Down Expand Up @@ -194,6 +194,13 @@ func handle(w http.ResponseWriter, r *http.Request) {
return
}

if IsFilteredMessageOrException(event) {
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
w.WriteHeader(http.StatusNoContent)
fmt.Fprintln(w, "IGNORE\n")
return
}

// Don't log testing traffic in production
if event.Version == "$internalRuntimeVersion$" {
w.WriteHeader(http.StatusNoContent)
Expand Down Expand Up @@ -228,9 +235,23 @@ func handle(w http.ResponseWriter, r *http.Request) {
if r.URL.Query().Get("debug") == "1" {
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
w.WriteHeader(http.StatusOK)
fmt.Fprintln(w, "OK\n");
fmt.Fprintln(w, event);
fmt.Fprintln(w, "OK\n")
fmt.Fprintln(w, event)
} else {
w.WriteHeader(http.StatusNoContent)
}
}

func IsFilteredMessageOrException(event *ErrorEvent) bool {
filteredMessages := [...]string{
"stop_youtube",
"null%20is%20not%20an%20object%20(evaluating%20%27elt.parentNode%27)",
}
for _, msg := range filteredMessages {
if strings.Contains(event.Message, msg) ||
strings.Contains(event.Exception, msg) {
return true
}
}
return false
}

0 comments on commit 9ce1ab5

Please sign in to comment.