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

summary

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Types = []string{"score", "httplog", "slowlog", "resource", "pprof", "memo"}

Types は Group に節がある収集タイプ。ptqd / dbquery は読まない(警告も出さない)。

Functions

This section is empty.

Types

type Diff

type Diff struct {
	// Before / After は比べた収集の GroupId。
	Before, After string
	Score         *score.Diff `json:",omitempty"`
	Commit        *git.Diff   `json:",omitempty"`
	// Warnings は比較の前提が崩れているもの(片方の収集中・失敗のエントリなど)。
	Warnings  []string `json:",omitempty"`
	Endpoints []EndpointDiff
	Queries   []QueryDiff
}

Diff は2つの収集の差分。

func Compare

func Compare(before, after *Group, topN int) *Diff

Compare は before -> after のエンドポイント / クエリ単位の増減を出す。 片方にしか無いもの(label ごと無いものも)は追加 / 削除として残す。

func (*Diff) Markdown

func (d *Diff) Markdown() string

type Endpoint

type Endpoint struct {
	Method string
	Uri    string
	Count  float64
	Sum    float64 `json:"SumSec"`
	Avg    float64 `json:"AvgSec"`
	P99    float64 `json:"P99Sec"`
	Max    float64 `json:"MaxSec"`
}

Endpoint は alp の1行。列は alp の設定で変わるので、ヘッダ名で引く。

func ParseEndpoints

func ParseEndpoints(tsv string) []Endpoint

ParseEndpoints は alp の TSV を読む。SUM の大きい順に並べる。

func (Endpoint) Key

func (e Endpoint) Key() string

type EndpointDiff

type EndpointDiff = RowDiff[Endpoint]

type Func

type Func struct {
	Name string
	Flat float64
	Cum  float64
	Unit string
	// FlatShare は全サンプルの flat に占める割合(0〜1)。
	FlatShare float64
}

Func は pprof の1関数。Flat / Cum の単位は Unit(時間のプロファイルなら seconds)。

func ParseProfile

func ParseProfile(raw []byte) ([]Func, error)

ParseProfile は pprof のプロファイルから関数ごとの flat / cum を出す。

type Group

type Group struct {
	GroupId  string
	Datetime time.Time
	Score    *score.Brief `json:",omitempty"`
	Commit   *git.Commit  `json:",omitempty"`
	// Warnings は集計に含めていないエントリ(収集中・失敗・中身を読めなかったもの)。
	Warnings []string `json:",omitempty"`

	HTTPLog  []LabeledEndpoints `json:",omitempty"`
	SlowLog  []LabeledQueries   `json:",omitempty"`
	Profiles []LabeledFuncs     `json:",omitempty"`
	Resource []LabeledText      `json:",omitempty"`
	Memo     []LabeledText      `json:",omitempty"`
}

Group は1回の収集(GroupId)の中身をまとめたもの。

func Load

func Load(c *client.Client, groupID string, topN int, types ...string) (*Group, error)

Load は GroupId の収集の中身を集めて Group にする。 types を渡すと、その収集タイプだけを読む(diff に pprof のプロファイルは要らない)。既定は Types。

func (*Group) Markdown

func (g *Group) Markdown() string

Markdown は Group を Markdown にする。 そのままエージェントの文脈に貼れることを狙って、表と最小限の見出しだけで書く。

type LabeledEndpoints

type LabeledEndpoints struct {
	Label     string
	Endpoints []Endpoint
}

type LabeledFuncs

type LabeledFuncs struct {
	Label string
	Funcs []Func
}

type LabeledQueries

type LabeledQueries struct {
	Label   string
	Queries []Query
}

type LabeledText

type LabeledText struct {
	Label string
	Text  string
}

type Query

type Query struct {
	Query string
	Count float64
	Sum   float64 `json:"SumSec"`
	Avg   float64 `json:"AvgSec"`
	Max   float64 `json:"MaxSec"`
	// RowsExamined は1回あたりの走査行数の平均。インデックスの当たり外れが出る。
	RowsExamined float64 `json:"RowsExaminedAvg"`
}

Query は slp の1行。

func ParseQueries

func ParseQueries(tsv string) []Query

ParseQueries は slp の TSV を読む。合計クエリ時間の大きい順に並べる。

func (Query) Key

func (q Query) Key() string

type QueryDiff

type QueryDiff = RowDiff[Query]

type RowDiff added in v0.6.0

type RowDiff[T any] struct {
	Label string
	// Key は JSON に出さない(Before / After が持っている。SQL を何度も繰り返さない)
	Key    string `json:"-"`
	Before *T     `json:",omitempty"`
	After  *T     `json:",omitempty"`
	// Impact は件数を揃えたときの合計時間の増減。impact を参照。
	Impact float64 `json:"ImpactSec"`
}

RowDiff は before / after の同じ行(同じ label・同じキー)の組。 片方にしか無い行(追加・削除)は、もう片方が nil。

Jump to

Keyboard shortcuts

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