Documentation
¶
Overview ¶
Package probelog writes down the requests magpie sends a provider on its own behalf, outside any agent's turn: the provider editor's Test, its Detect APIs and per-model detection, and a model list's refresh (neiko and gys619 on Discord: a test left no trace in the request log). Each such request is one row of the request log, marked as magpie's own test (usage.SourceProbe) and never counted in a usage or cost total; a model list that was answered is left out there (usage's quietProbe), as magpie asks for lists by itself all day.
The provider package marks a context with the kind of test (With); every request sent under it is written down once, by the provider's Do or by the transport the HTTP client goes through (Transport), whichever sends it first. Package usage sets Sink.
Index ¶
- Constants
- Variables
- func Kind(ctx context.Context) string
- func Note(ctx context.Context, u, method string, start time.Time, status int, err error)
- func NoteResult(ctx context.Context, endpoint string, start time.Time, status int, ...)
- func Pending(ctx context.Context) bool
- func Taken(ctx context.Context) context.Context
- func Transport(next http.RoundTripper) http.RoundTripper
- func With(ctx context.Context, kind, provider, account string) context.Context
- func WithModel(ctx context.Context, model string) context.Context
- type Row
Constants ¶
const ( KindTest = "provider_test" // the editor's Test, a model's test KindDetect = "api_detect" // Detect APIs, a model's API detection KindList = "model_list" // a model list asked for, refreshed )
The kinds a row is written under, as the request log's "Called for" names them (usage.purposeKinds).
Variables ¶
var Sink func(Row)
Sink takes each row; nil writes nothing. usage sets it to its log.
Functions ¶
func Note ¶
Note writes down one request under ctx's mark, sent to u (a URL; only its host and path are kept) at start, answered status or failed with err. Nothing is written for a ctx with no mark.
func NoteResult ¶
NoteResult writes down one request that isn't sent through an HTTP client of magpie's (Claude Code run for a test, the gateway's translated test), from what came of it.
func Pending ¶
Pending is whether a request sent under ctx is still to be written down: ctx is marked and no caller has taken it.
func Taken ¶
Taken is ctx with its requests already written down by its caller, so the transport under it doesn't write them again.
func Transport ¶
func Transport(next http.RoundTripper) http.RoundTripper
Transport writes down each request sent through next under a marked context no caller took. Every request the HTTP client sends goes through it (netproxy.Install), so a model list asked through the client of any package is written as the provider's own requests are.