Documentation
¶
Overview ¶
Package proficiency profiles Go HTTP APIs from an OpenAPI specification.
Index ¶
- Constants
- func WriteReport(path string, report Report) error
- type Comparison
- type ComparisonMetric
- type Config
- type FunctionStat
- type GateError
- type Metadata
- type ProfileAnalysis
- type RegressionMetric
- type RegressionRule
- type Report
- type ReportEndpointStats
- type ReportIdentity
- type ReportLoad
- type ReportProfile
- type ReportRunConfig
- type ThresholdResult
- type ThresholdRule
- type ThresholdViolation
Constants ¶
const ( RegressionUnitMicroseconds = "microseconds" RegressionUnitRPS = "requests-per-second" )
Units used by regression rule noise floors.
const ReportSchemaVersion = "v1"
ReportSchemaVersion identifies the JSON compatibility contract.
Variables ¶
This section is empty.
Functions ¶
func WriteReport ¶
WriteReport writes a report atomically so readers never observe partial JSON.
Types ¶
type Comparison ¶
type Comparison struct {
Baseline ReportIdentity `json:"baseline"`
Current ReportIdentity `json:"current"`
Rules []RegressionRule `json:"rules"`
Passed bool `json:"passed"`
Metrics []ComparisonMetric `json:"metrics"`
Regressions []ComparisonMetric `json:"regressions"`
}
Comparison describes the deterministic difference between two reports.
func CompareReports ¶
func CompareReports(baseline, current Report, rules []RegressionRule) (Comparison, error)
CompareReports compares stable aggregate load metrics and recorded profile bottlenecks. It does not require the raw pprof files to remain available.
type ComparisonMetric ¶
type ComparisonMetric struct {
Metric RegressionMetric `json:"metric"`
Key string `json:"key"`
Baseline float64 `json:"baseline"`
Current float64 `json:"current"`
Change float64 `json:"change"`
Unit string `json:"unit"`
AbsoluteChange float64 `json:"absoluteChange"`
AbsoluteUnit string `json:"absoluteUnit"`
Outcome string `json:"outcome"`
Limit *float64 `json:"limit,omitempty"`
MinimumChange *float64 `json:"minimumChange,omitempty"`
MinimumChangeUnit string `json:"minimumChangeUnit,omitempty"`
WithinLimit *bool `json:"withinLimit,omitempty"`
}
ComparisonMetric is one load or profile measurement delta. Change is positive for degradation and negative for improvement. Outcome is purely directional; WithinLimit records the configured gate result separately.
type Config ¶
type Config struct {
OpenAPIPath string
TargetURL string
PprofURL string
Duration time.Duration
Concurrency int
RPS int
RequestTimeout time.Duration
OutputDir string
CPUDuration time.Duration
SkipLoad bool
FailOn string
SampleInterval time.Duration
SampleCount int
ProfileTypes string
NoProgress bool
ReportPath string
BaselinePath string
FailOnRegression string
TopFunctions int
ToolVersion string
Metadata Metadata
Output io.Writer
ErrorOutput io.Writer
}
Config controls one profiling run.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns the defaults used by the CLI.
type FunctionStat ¶
type FunctionStat struct {
Function string `json:"function"`
Percentage float64 `json:"percentage"`
}
FunctionStat contains a function's flat share of its profile.
type GateError ¶
GateError reports failed profile or regression gates after the report has been written successfully.
type Metadata ¶
type Metadata struct {
Label string `json:"label,omitempty"`
Repository string `json:"repository,omitempty"`
Revision string `json:"revision,omitempty"`
Ref string `json:"ref,omitempty"`
}
Metadata identifies the source revision represented by a report.
type ProfileAnalysis ¶
type ProfileAnalysis struct {
ProfileType string `json:"profileType"`
Functions []FunctionStat `json:"functions"`
}
ProfileAnalysis contains the highest flat-cost functions in one profile.
type RegressionMetric ¶
type RegressionMetric string
RegressionMetric identifies a comparable report measurement.
const ( RegressionLatency RegressionMetric = "latency" RegressionErrorRate RegressionMetric = "error-rate" RegressionThroughput RegressionMetric = "throughput" RegressionCPU RegressionMetric = "cpu" RegressionAlloc RegressionMetric = "alloc" RegressionBlock RegressionMetric = "block" RegressionGoroutine RegressionMetric = "goroutine" )
Supported regression metrics.
type RegressionRule ¶
type RegressionRule struct {
Metric RegressionMetric `json:"metric"`
Limit float64 `json:"limit"`
MinimumChange float64 `json:"minimumChange,omitempty"`
MinimumChangeUnit string `json:"minimumChangeUnit,omitempty"`
}
RegressionRule defines the maximum tolerated degradation for one metric. Latency and throughput also require an absolute noise floor.
func ParseRegressionRules ¶
func ParseRegressionRules(value string) ([]RegressionRule, error)
ParseRegressionRules parses comma-separated rules. Latency and throughput require absolute noise floors:
latency:10:200us,throughput:10:5rps,error-rate:1,cpu:5
type Report ¶
type Report struct {
SchemaVersion string `json:"schemaVersion"`
Timestamp time.Time `json:"timestamp"`
ToolVersion string `json:"toolVersion"`
Metadata Metadata `json:"metadata,omitzero"`
RunConfig ReportRunConfig `json:"runConfig"`
Profiles []ReportProfile `json:"profiles"`
LoadStats *ReportLoad `json:"loadStats,omitempty"`
Analysis []ProfileAnalysis `json:"analysis"`
Thresholds ThresholdResult `json:"thresholds"`
Comparison *Comparison `json:"comparison,omitempty"`
}
Report is the versioned, machine-readable result of a profiling run.
func ReadReport ¶
ReadReport reads and validates a versioned report.
type ReportEndpointStats ¶
type ReportEndpointStats struct {
Endpoint string `json:"endpoint"`
Count int64 `json:"count"`
MinMicros int64 `json:"minMicros"`
MaxMicros int64 `json:"maxMicros"`
AvgMicros int64 `json:"avgMicros"`
TotalMicros int64 `json:"totalMicros"`
}
ReportEndpointStats contains deterministic per-endpoint latency aggregates.
type ReportIdentity ¶
type ReportIdentity struct {
Timestamp string `json:"timestamp"`
ToolVersion string `json:"toolVersion"`
Metadata Metadata `json:"metadata,omitzero"`
}
ReportIdentity is the source metadata needed to identify a compared report.
type ReportLoad ¶
type ReportLoad struct {
TotalRequests int64 `json:"totalRequests"`
SuccessCount int64 `json:"successCount"`
ErrorCount int64 `json:"errorCount"`
ErrorRatePercent float64 `json:"errorRatePercent"`
DurationMS int64 `json:"durationMs"`
RequestsPerSecond float64 `json:"requestsPerSecond"`
Endpoints []ReportEndpointStats `json:"endpoints"`
}
ReportLoad contains aggregate load-generation measurements.
type ReportProfile ¶
type ReportProfile struct {
Type string `json:"type"`
Metric string `json:"metric"`
FilePath string `json:"filePath"`
SizeBytes int64 `json:"sizeBytes"`
DurationMS int64 `json:"durationMs"`
}
ReportProfile identifies one saved pprof artifact.
type ReportRunConfig ¶
type ReportRunConfig struct {
Mode string `json:"mode"`
OpenAPIPath string `json:"openapiPath,omitempty"`
TargetURL string `json:"targetUrl"`
PprofURL string `json:"pprofUrl"`
OutputDir string `json:"outputDir"`
DurationMS int64 `json:"durationMs"`
CPUDurationMS int64 `json:"cpuDurationMs"`
Concurrency int `json:"concurrency"`
RPS int `json:"rps"`
RequestTimeoutMS int64 `json:"requestTimeoutMs"`
SkipLoad bool `json:"skipLoad"`
ProfileTypes string `json:"profileTypes"`
SampleIntervalMS int64 `json:"sampleIntervalMs"`
SampleCount int `json:"sampleCount"`
FailOn string `json:"failOn,omitempty"`
TopFunctions int `json:"topFunctions"`
}
ReportRunConfig records the inputs that materially affect a run.
type ThresholdResult ¶
type ThresholdResult struct {
Configured bool `json:"configured"`
Passed bool `json:"passed"`
Rules []ThresholdRule `json:"rules"`
Violations []ThresholdViolation `json:"violations"`
}
ThresholdResult records configured profile gates and their outcome.
type ThresholdRule ¶
type ThresholdRule struct {
ProfileType string `json:"profileType"`
Percentage float64 `json:"percentage"`
}
ThresholdRule is one configured per-function profile threshold.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
proficiency
command
Package main provides the CLI entry point for the proficiency tool.
|
Package main provides the CLI entry point for the proficiency tool. |
|
internal
|
|
|
load
Package load provides HTTP load generation functionality.
|
Package load provides HTTP load generation functionality. |
|
openapi
Package openapi provides OpenAPI specification parsing functionality.
|
Package openapi provides OpenAPI specification parsing functionality. |
|
profile
Package profile provides pprof profile collection functionality.
|
Package profile provides pprof profile collection functionality. |