Skip to content

Commit

Permalink
Merge pull request #38 from krakend/add_multierrors_check
Browse files Browse the repository at this point in the history
add extra checks for multiError
  • Loading branch information
kpacha authored Oct 30, 2024
2 parents fc4107f + 25c2482 commit 1b34722
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions lura/proxy_meter.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,31 @@ func newMiddlewareMeter(s state.OTEL, stageName string, attrs []attribute.KeyVal
}, nil
}

// multiError is an interface that is implemented by lura at the
// proxy level to gather errors for each of the backends
type multiError interface {
error
Errors() []error
}

func (m *middlewareMeter) report(ctx context.Context, secs float64, resp *proxy.Response, err error) {
isErr := false
isCanceled := false
if err != nil {
if errors.Is(err, context.Canceled) {
if errors.Is(err, context.Canceled) || errors.Is(ctx.Err(), context.Canceled) {
isCanceled = true
} else {
}
if mErr, ok := err.(multiError); ok {
errs := mErr.Errors()
for _, e := range errs {
if errors.Is(e, context.Canceled) {
isCanceled = true
} else {
isErr = true
}
}
}
if !isCanceled {
isErr = true
}
}
Expand Down

0 comments on commit 1b34722

Please sign in to comment.