respspan

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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.

View Source
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

func Handled(
	c *echo.Context,
)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL