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

trend

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: 7 Imported by: 0

Documentation

Overview

Package trend は収集をまたいだ指標の推移を返す。

pprotein の UI は1回の収集のスナップショット表示が中心で、走行をまたいだ比較ができない。 「前回と比べてどのエンドポイントが改善したか / 悪化したか」を人間が目視で突き合わせるのを やめるために、収集を横軸に取れる形のデータを1本の API で返す。

Index

Constants

View Source
const (
	MetricHTTPSum    = "httplog.sum"
	MetricHTTPCount  = "httplog.count"
	MetricSlowSum    = "slowlog.sum"
	MetricSlowCount  = "slowlog.count"
	MetricSlowRows   = "slowlog.rows_examined"
	MetricScoreValue = "score"
)

指標のキー。フロント側と合わせてある。

Variables

This section is empty.

Functions

This section is empty.

Types

type Commit

type Commit struct {
	Hash    string
	Message string
	Ref     string
}

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler は /api/trend を提供する。 集計は summary パッケージ(CLI と同じ経路)を使う。自分自身の API を叩くので、 alp / pt-query-digest の結果はサーバー側のキャッシュがそのまま効く。

func NewHandler

func NewHandler(selfURL string) *Handler

func (*Handler) RegisterHandlers

func (h *Handler) RegisterHandlers(g *echo.Group)

type Point

type Point struct {
	ID       string
	Datetime string

	Commit *Commit
	Score  *Score

	// Metrics はグラフに出す集計値。値が取れなかったものは入らない。
	Metrics map[string]float64

	// Endpoints / Queries はエンドポイント・クエリ単位の推移を引くための明細。
	Endpoints []Series
	Queries   []Series
}

Point は1回の収集。

type Response

type Response struct {
	Groups []Point
}

Response は /api/trend の返り値。Groups は古い順(グラフの左から右)。

type Score

type Score struct {
	Value  int64
	Passed bool
}

type Series

type Series struct {
	Label string
	Key   string
	Count float64
	Sum   float64
	Avg   float64
}

Series はエンドポイント / クエリ1件ぶんの値。Key で系列を束ねる。

Jump to

Keyboard shortcuts

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