Documentation
¶
Overview ¶
Package respspan times what the controller does after a handler has its answer, as two spans of their own under the request: response.encode, the encode of the answer as JSON, and response.write, the write of it to the client, which waits on the network. The code that oapi-codegen generates encodes after every middleware has returned, so no middleware can open a span around the encode. Three marks time them instead: Handled, when the handler has its answer; echo's Response.Before, when the status line goes out, after the encode; and echo's Response.After, the last write.
Index ¶
Constants ¶
const ( // SpanEncode is the encode of the answer as JSON. SpanEncode = "response.encode" // SpanWrite is the write of the body to the client. It waits on the // network, so a slow client makes it long, not the controller. SpanWrite = "response.write" )
The spans after a handler has its answer.
const AttrBodySize = attribute.Key("http.response.body.size")
AttrBodySize is the size of the body that the controller wrote, in bytes.
Variables ¶
This section is empty.
Functions ¶
func Handled ¶
Handled marks the time that the handler of c has its answer. What the controller does after it, until the last write, is the encode and the write of the response. ScopeMiddleware calls it for each strict handler; a handler that encodes itself calls it before c.JSON. The first mark wins: a handler that writes its own answer inside ScopeMiddleware has marked already, and the mark after its write would end the span before it starts.
func Middleware ¶
func Middleware( next echo.HandlerFunc, ) echo.HandlerFunc
Middleware opens the response.encode and response.write spans of a request under the span of the request: response.encode from the time Handled marks to the status line, and response.write from there to the last write of the body, with its size. A request without a span, without the mark, or without a body gets neither, and no span ends before it starts. It goes after the middleware that opens the request span.
Types ¶
This section is empty.