(ctx *context, err error)
| 1603 | } |
| 1604 | |
| 1605 | func (p *Proxy) errorResponse(ctx *context, err error) { |
| 1606 | responseStopWatch := newStopWatch() |
| 1607 | responseStopWatch.Start() |
| 1608 | defer func() { |
| 1609 | responseStopWatch.Stop() |
| 1610 | ctx.proxyResponseElapsed = responseStopWatch.Elapsed() |
| 1611 | }() |
| 1612 | |
| 1613 | perr, ok := err.(*proxyError) |
| 1614 | if ok && perr.handled { |
| 1615 | return |
| 1616 | } |
| 1617 | |
| 1618 | flowIDLog := "" |
| 1619 | flowID := ctx.Request().Header.Get(flowidFilter.HeaderName) |
| 1620 | if flowID != "" { |
| 1621 | flowIDLog = fmt.Sprintf(", flow id %s", flowID) |
| 1622 | } |
| 1623 | id := unknownRouteID |
| 1624 | backendType := unknownRouteBackendType |
| 1625 | backend := unknownRouteBackend |
| 1626 | if ctx.route != nil { |
| 1627 | id = ctx.route.Id |
| 1628 | backendType = ctx.route.BackendType.String() |
| 1629 | backend = fmt.Sprintf("%s://%s", ctx.request.URL.Scheme, ctx.request.URL.Host) |
| 1630 | } |
| 1631 | |
| 1632 | if err == errRouteLookupFailed { |
| 1633 | ctx.initialSpan.LogKV("event", "error", "message", errRouteLookup.Error()) |
| 1634 | } |
| 1635 | |
| 1636 | p.tracing.setTag(ctx.initialSpan, ErrorTag, true) |
| 1637 | p.tracing.setTag(ctx.initialSpan, HTTPStatusCodeTag, ctx.response.StatusCode) |
| 1638 | |
| 1639 | if p.flags.Debug() { |
| 1640 | di := &debugInfo{ |
| 1641 | incoming: ctx.originalRequest, |
| 1642 | outgoing: ctx.outgoingDebugRequest, |
| 1643 | response: ctx.response, |
| 1644 | err: err, |
| 1645 | } |
| 1646 | |
| 1647 | if ctx.route != nil { |
| 1648 | di.route = &ctx.route.Route |
| 1649 | } |
| 1650 | |
| 1651 | dbgResponse(ctx.responseWriter, di) |
| 1652 | return |
| 1653 | } |
| 1654 | |
| 1655 | msgPrefix := "error while proxying" |
| 1656 | logFunc := ctx.Logger().Errorf |
| 1657 | if ctx.response.StatusCode == 499 { |
| 1658 | msgPrefix = "client canceled" |
| 1659 | logFunc = ctx.Logger().Infof |
| 1660 | if p.accessLogDisabled { |
| 1661 | logFunc = ctx.Logger().Debugf |
| 1662 | } |
no test coverage detected