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 24, 2017
1 parent b2a1f69 commit 9934a9c
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 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,14 @@ func handle(w http.ResponseWriter, r *http.Request) {
return
}

if strings.Contains(event.Message, "stop_youtube") ||
strings.Contains(event.Exception, "stop_youtube") {
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
w.WriteHeader(http.StatusOK)
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,8 +236,8 @@ 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)
}
Expand Down

0 comments on commit 9934a9c

Please sign in to comment.