Help us shape the future of Go! Take the 2026 Go Developer Survey

probelog

package
v0.1.1987 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 4 Imported by: 0

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

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

View Source
var Sink func(Row)

Sink takes each row; nil writes nothing. usage sets it to its log.

Functions

func Kind

func Kind(ctx context.Context) string

Kind is the kind ctx is marked with, "" for none.

func Note

func Note(ctx context.Context, u, method string, start time.Time, status int, err error)

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

func NoteResult(ctx context.Context, endpoint string, start time.Time, status int, errText string)

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

func Pending(ctx context.Context) bool

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

func Taken(ctx context.Context) context.Context

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.

func With

func With(ctx context.Context, kind, provider, account string) context.Context

With marks ctx: the requests sent under it are of kind, for provider (its id) and account. A kind set inside another replaces it, so a model list fetched for a Test is written as a model list. The model set before stays.

func WithModel

func WithModel(ctx context.Context, model string) context.Context

WithModel is ctx with the model the requests under it ask, for a ctx With marked; any other ctx is returned as it is.

Types

type Row

type Row struct {
	Time     time.Time
	Kind     string
	Provider string // the provider's id, or the host for one not yet saved
	Account  string
	Model    string
	Host     string
	Endpoint string
	Status   int
	Millis   int64
	Error    string
}

Row is one request written down.

Jump to

Keyboard shortcuts

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