Ian Edwards 2 лет назад
Родитель
Сommit
04441a3a6a
2 измененных файлов с 7 добавлено и 0 удалено
  1. 4 0
      api/server/handlers/webhook/app_v2_github.go
  2. 3 0
      internal/porter_app/github.go

+ 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) {
 	case *github.PullRequestEvent:
 		if event.GetAction() != GithubPRStatus_Closed {
+			telemetry.WithAttributes(span, telemetry.AttributeKV{Key: "event-processed", Value: false})
 			c.WriteResult(w, r, nil)
 			return
 		}
@@ -159,6 +160,9 @@ func (c *GithubWebhookHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
 			c.HandleAPIError(w, r, apierrors.NewErrPassThroughToClient(err, http.StatusInternalServerError))
 			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)

+ 3 - 0
internal/porter_app/github.go

@@ -136,6 +136,9 @@ func getGithubClientByRepoID(ctx context.Context, repoID uint, githubAppSecret [
 	if err != nil {
 		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
 }