Skip to content

Commit

Permalink
debug: try to understand sentry behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
fritterhoff committed Nov 17, 2024
1 parent b2ecbfc commit ea8bcb3
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions backend/pki-rest-interface/pkg/api/ssl/certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ func (h *Handler) Active(c echo.Context) error {
func (h *Handler) List(c echo.Context) error {
logger := c.Request().Context().Value(logging.LoggingContextKey).(*zap.Logger)

hub := sentryecho.GetHubFromContext(c)
ctx := c.Request().Context()
if hub != nil {
ctx = sentry.SetHubOnContext(ctx, hub)
}

user, err := auth.UserFromRequest(c)
if err != nil {
logger.Error("error getting user from request", zap.Error(err))
Expand All @@ -110,30 +116,25 @@ func (h *Handler) List(c echo.Context) error {
scope.SetExtra("user", user)
})
}
domains, err := h.domain.ListDomains(c.Request().Context(), &pb.ListDomainsRequest{User: user, Approved: true})
domains, err := h.domain.ListDomains(ctx, &pb.ListDomainsRequest{User: user, Approved: true})
if err != nil {
logger.Error("error getting domains", zap.Error(err))
return &echo.HTTPError{Code: http.StatusInternalServerError, Message: "Error while listing certificates"}
}

logger.Debug("fetching certificates", zap.Strings("domains", domains.Domains))

hub := sentry.GetHubFromContext(c.Request().Context())
if hub == nil {
hub2 := sentry.GetHubFromContext(ctx)
if hub2 == nil {
logger.Warn("no hub found")
}

span := sentry.SpanFromContext(c.Request().Context())
span := sentry.SpanFromContext(ctx)
if span == nil {
logger.Warn("no span found")
}

span = sentryecho.GetSpanFromContext(c)
if span == nil {
logger.Warn("no span found in echo context")
}

certs, err := h.ssl.ListCertificates(c.Request().Context(), &pb.ListSslRequest{IncludePartial: false, Domains: domains.Domains})
certs, err := h.ssl.ListCertificates(ctx, &pb.ListSslRequest{IncludePartial: false, Domains: domains.Domains})
if err != nil {
logger.Error("error while listing certificates", zap.Error(err))
return &echo.HTTPError{Code: http.StatusInternalServerError, Message: "Error while listing certificates"}
Expand Down

0 comments on commit ea8bcb3

Please sign in to comment.