client

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

Overview

Package client は pprotein の HTTP API を読む。 CLI と、自分自身の API から材料を読むサーバー側の集計(analysis / trend)が使う。

Index

Constants

This section is empty.

Variables

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

Types は pprotein の収集タイプ。

Functions

func GroupIDs

func GroupIDs(entries []Entry) []string

GroupIDs は新しい順の GroupId 一覧を返す。

func Latest

func Latest(entries []Entry) (string, error)

Latest は最新の収集の GroupId を返す。収集中・失敗したものも含める。 1つ前の走行を指すと、走行直後の収集中や新しい走行の失敗が前の走行の結果で隠れ、取り違えに気づけない。 GroupId の形でないもの(API に手で送ったスコアやメモ)は時刻の順に並ばないので除く。

func Warning

func Warning(e Entry) string

Warning は確定していない(収集中・失敗の)エントリを警告文にする。確定していれば空。 黙って飛ばすと、収集中の走行がリクエスト 0 件として読まれてしまう。

Types

type Client

type Client struct {
	BaseURL string
	HTTP    *http.Client
}

Client は pprotein の HTTP API クライアント。

func New

func New(baseURL string) *Client

func (*Client) AllEntries

func (c *Client) AllEntries() ([]Entry, error)

AllEntries は全タイプのエントリをまとめて取る。 収集タイプが存在しない(古い pprotein)場合はそのタイプを黙って飛ばす。

func (*Client) Config

func (c *Client) Config(typ string) ([]byte, error)

Config は収集タイプの設定ファイル(alp.yml など)を返す。

func (*Client) Content

func (c *Client) Content(typ, id string) (string, error)

Content は処理済みの結果(alp の TSV、resource の要約テキストなど)を返す。

func (*Client) Entries

func (c *Client) Entries(typ string) ([]Entry, error)

Entries は指定した収集タイプのエントリ一覧を返す。

func (*Client) GetQuery

func (c *Client) GetQuery(path string, query url.Values) ([]byte, error)

GetQuery は path にクエリ文字列を付けて GET する(path に ? を含めると JoinPath でエスケープされるため)。

func (*Client) RawData

func (c *Client) RawData(typ, id string) ([]byte, error)

RawData は生のスナップショット(pprof のプロファイルなど)を返す。

func (*Client) Score

func (c *Client) Score(id string) (*score.Value, error)

Score は収集に紐づいたスコアを返す。無ければ nil。

func (*Client) StartCollect

func (c *Client) StartCollect() error

StartCollect は収集を開始する。

type Entry

type Entry struct {
	Snapshot struct {
		Type       string
		ID         string
		Datetime   time.Time
		Repository *git.RepositoryInfo
		GroupId    string
		Label      string
		Duration   int
	}
	Status  string
	Message string
}

Entry は /api/<type> が返すエントリ。

func Newest

func Newest(entries []Entry, typ, groupId string) *Entry

Newest は収集 groupId の typ のエントリのうち、確定した(ok の)いちばん新しいものを返す。無ければ nil。 ベンチを回し直してスコアや dbquery を送り直すと、同じ収集に複数できる。

func (Entry) Name

func (e Entry) Name() string

Name は警告などに出すエントリの名前(「httplog isu1」)。

Jump to

Keyboard shortcuts

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