Documentation
¶
Overview ¶
Package http is the http trace kind: it records the outbound HTTP exchanges commons-db makes for chosen features, one HAR entry per record.
Index ¶
Constants ¶
const ( RequestBody = "request.postData.text" ResponseBody = "response.content.text" )
RequestBody and ResponseBody are where an exchange holds its bodies, as paths WithJSONProcessor takes.
Variables ¶
var HAR = tracing.ExportFormat{Name: "har", Ext: "har", MIME: "application/json"}
HAR is the format an http window downloads in besides NDJSON.
Functions ¶
func Export ¶
Export writes rows in format, which must be HAR: a HAR 1.2 file, streamed one entry at a time. Every kind whose records are exchanges exports so.
func Key ¶
Key identifies an exchange for deduplication: its method, URL, status, and a digest of both bodies.
func Kind ¶
Kind is the http trace kind: exchanges masked, capped at 1MiB a value, their request and response bodies stored as structure when they hold JSON, and deduplicated within the params' window.
func Summarize ¶
Summarize counts the exchanges by method, status and host, and lists the first maxSummaryRequests of them. An exchange that failed, with a 4xx or 5xx or with no response at all, is an error. Status keys are strings, so a CEL assertion reads statuses["200"] as it reads methods["GET"].
Types ¶
type Entry ¶
type Entry struct {
har.Entry
ServerIPAddress string `json:"serverIPAddress,omitempty"`
Comment string `json:"comment,omitempty"`
Tunnelled bool `json:"_tunnelled,omitempty"`
BytesIn int64 `json:"_bytesIn,omitempty"`
BytesOut int64 `json:"_bytesOut,omitempty"`
Encoding string `json:"_encoding,omitempty"`
}
Entry is a HAR entry with what an exchange observed beyond the fields of har.Entry: HAR 1.2's serverIPAddress and comment, and as custom fields, underscore-prefixed as the spec reserves them, a tunnel's byte counts and the encoding of a response body that is not text.
type Exchange ¶
type Exchange struct {
tracing.Truncation
StartedAt time.Time `json:"startedAt" pretty:"label=Started" sort:"startedAt"`
Feature string `json:"feature" filter:"terms"`
Method string `json:"method" filter:"terms"`
Host string `json:"host" filter:"terms"`
URL string `json:"url" pretty:"label=URL" filter:"text"`
Status int `json:"status" filter:"terms"`
DurationMs float64 `json:"durationMs" pretty:"label=Duration,type=duration,unit=ms" sort:"durationMs"`
Request har.Request `json:"request" pretty:"hide"`
Response har.Response `json:"response" pretty:"hide"`
// Error is why the exchange got no response, such as a refused connection.
Error string `json:"error,omitempty" filter:"text"`
// Timings break DurationMs down where the capture measured the phases; a
// phase it did not measure is -1.
Timings har.Timings `json:"timings" pretty:"hide"`
ServerIPAddress string `json:"serverIPAddress,omitempty" pretty:"label=Server IP"`
// Tunnelled marks a CONNECT tunnel a proxy relayed without decrypting it:
// there is no method, path, status or body inside it to record, only the
// bytes that crossed it, in from the server and out from the client.
Tunnelled bool `json:"tunnelled,omitempty"`
BytesIn int64 `json:"bytesIn,omitempty" pretty:"label=Bytes in"`
BytesOut int64 `json:"bytesOut,omitempty" pretty:"label=Bytes out"`
// Encoding is the response content's encoding: base64 for a body that is
// not UTF-8 text.
Encoding string `json:"encoding,omitempty" pretty:"hide"`
// Comment says what the capture left out of the exchange, such as a body
// it cut or an event stream still open when it ended.
Comment string `json:"comment,omitempty" filter:"text"`
}
Exchange is one outbound request and its response.
type Params ¶
type Params struct {
// Features name the transports to observe, as their HAR levels do:
// http, prometheus, loki, opensearch, git, ...
Features []string `json:"features" clicky:"required,title=Features"`
// DedupWindow, a duration such as 1h, stores an exchange only once within
// it: the same method, URL, status and bodies. Empty stores every one.
DedupWindow string `json:"dedupWindow,omitempty" clicky:"title=Dedup window"`
}
Params choose the features whose exchanges a capture records.