Skip to content

Commit

Permalink
optimize: filter shortConnErr in tracer
Browse files Browse the repository at this point in the history
  • Loading branch information
li-jin-gou committed Jan 27, 2024
1 parent 0d25abe commit f581345
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions pkg/protocol/http1/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,18 @@ func (s Server) Serve(c context.Context, conn network.Conn) (err error) {

defer func() {
if s.EnableTrace {
if shouldRecordInTraceError(err) {
ctx.GetTraceInfo().Stats().SetError(err)
}
// in case of error, we need to trigger all events
if eventsToTrigger != nil {
for last := eventsToTrigger.pop(); last != nil; last = eventsToTrigger.pop() {
last(ctx.GetTraceInfo(), err)
}
s.eventStackPool.Put(eventsToTrigger)
}

traceCtl.DoFinish(cc, ctx, err)
if shouldRecordInTraceError(err) {
traceCtl.DoFinish(cc, ctx, err)
} else {
traceCtl.DoFinish(cc, ctx, nil)
}
}

// Hijack may release and close the connection already
Expand Down Expand Up @@ -384,7 +384,11 @@ func (s Server) Serve(c context.Context, conn network.Conn) (err error) {
}
// general case
if s.EnableTrace {
traceCtl.DoFinish(cc, ctx, err)
if shouldRecordInTraceError(err) {
traceCtl.DoFinish(cc, ctx, err)
} else {
traceCtl.DoFinish(cc, ctx, nil)

Check warning on line 390 in pkg/protocol/http1/server.go

View check run for this annotation

Codecov / codecov/patch

pkg/protocol/http1/server.go#L387-L390

Added lines #L387 - L390 were not covered by tests
}
}

ctx.ResetWithoutConn()
Expand Down

0 comments on commit f581345

Please sign in to comment.