Explorar o código

address comments

Ian Edwards %!s(int64=2) %!d(string=hai) anos
pai
achega
04441a3a6a

+ 4 - 0
api/server/handlers/webhook/app_v2_github.go

@@ -117,6 +117,7 @@ func (c *GithubWebhookHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
 	switch event := event.(type) {
 	switch event := event.(type) {
 	case *github.PullRequestEvent:
 	case *github.PullRequestEvent:
 		if event.GetAction() != GithubPRStatus_Closed {
 		if event.GetAction() != GithubPRStatus_Closed {
+			telemetry.WithAttributes(span, telemetry.AttributeKV{Key: "event-processed", Value: false})
 			c.WriteResult(w, r, nil)
 			c.WriteResult(w, r, nil)
 			return
 			return
 		}
 		}
@@ -159,6 +160,9 @@ func (c *GithubWebhookHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
 			c.HandleAPIError(w, r, apierrors.NewErrPassThroughToClient(err, http.StatusInternalServerError))
 			c.HandleAPIError(w, r, apierrors.NewErrPassThroughToClient(err, http.StatusInternalServerError))
 			return
 			return
 		}
 		}
+
+		telemetry.WithAttributes(span, telemetry.AttributeKV{Key: "event-processed", Value: true})
+		telemetry.WithAttributes(span, telemetry.AttributeKV{Key: "pr-id", Value: event.GetPullRequest().GetID()})
 	}
 	}
 
 
 	c.WriteResult(w, r, nil)
 	c.WriteResult(w, r, nil)

+ 3 - 0
internal/porter_app/github.go

@@ -136,6 +136,9 @@ func getGithubClientByRepoID(ctx context.Context, repoID uint, githubAppSecret [
 	if err != nil {
 	if err != nil {
 		return nil, telemetry.Error(ctx, span, err, "could not create github app client")
 		return nil, telemetry.Error(ctx, span, err, "could not create github app client")
 	}
 	}
+	if itr == nil {
+		return nil, telemetry.Error(ctx, span, nil, "github app client is nil")
+	}
 
 
 	return github.NewClient(&http.Client{Transport: itr}), nil
 	return github.NewClient(&http.Client{Transport: itr}), nil
 }
 }