Skip to content

Commit

Permalink
Merge branch 'feat/otel-tracing' of github.com:go-vela/server into fe…
Browse files Browse the repository at this point in the history
…at/otel-tracing

 the commit.
  • Loading branch information
plyr4 committed Aug 26, 2024
2 parents 33bf135 + fba0da2 commit 50e82aa
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
12 changes: 10 additions & 2 deletions api/log/get_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
package log

import (
"errors"
"fmt"
"net/http"

"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"
"gorm.io/gorm"

"github.com/go-vela/server/database"
"github.com/go-vela/server/router/middleware/build"
Expand Down Expand Up @@ -85,9 +87,15 @@ func GetServiceLog(c *gin.Context) {
// send API call to capture the service logs
sl, err := database.FromContext(c).GetLogForService(ctx, s)
if err != nil {
retErr := fmt.Errorf("unable to get logs for service %s: %w", entry, err)
var status int
if errors.Is(err, gorm.ErrRecordNotFound) {
status = http.StatusNotFound
} else {
status = http.StatusInternalServerError
}

util.HandleError(c, http.StatusInternalServerError, retErr)
retErr := fmt.Errorf("unable to get logs for service %s: %w", entry, err)
util.HandleError(c, status, retErr)

return
}
Expand Down
12 changes: 10 additions & 2 deletions api/log/get_step.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
package log

import (
"errors"
"fmt"
"net/http"

"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"
"gorm.io/gorm"

"github.com/go-vela/server/database"
"github.com/go-vela/server/router/middleware/build"
Expand Down Expand Up @@ -86,9 +88,15 @@ func GetStepLog(c *gin.Context) {
// send API call to capture the step logs
sl, err := database.FromContext(c).GetLogForStep(ctx, s)
if err != nil {
retErr := fmt.Errorf("unable to get logs for step %s: %w", entry, err)
var status int
if errors.Is(err, gorm.ErrRecordNotFound) {
status = http.StatusNotFound
} else {
status = http.StatusInternalServerError
}

util.HandleError(c, http.StatusInternalServerError, retErr)
retErr := fmt.Errorf("unable to get logs for step %s: %w", entry, err)
util.HandleError(c, status, retErr)

return
}
Expand Down

0 comments on commit 50e82aa

Please sign in to comment.