prombench

package module
v0.0.0-...-58693dd Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

README

ci

prombench

prombench is a tiny program that sends some load to a prometheus implementations in the form of promql.

Usage

prombench runs provided number of queries in the provided concurrency level and prints stats.

Usage: prombench [options...] <url> <query_file>
Options:
  -c  Number of workers to run concurrently. Total number of requests cannot
      be smaller than the concurrency level. Default is 50.
  -H  Custom HTTP header. You can specify as many as needed by repeating the flag.
      For example, -H "Accept: text/html" -H "Content-Type: application/xml" .
  -cpus                 Number of used cpu cores.
                        (default for current machine is 12 cores)

For Developers

To build,

make prombench

To run tests,

make test-unit

To benchmark against Promscale instance

The following make target would setup promscale instance and ingests sample data to execute benchmark.

make run-benchmark

Sample benchmark result

$ ./prombench "http://localhost:9201" "pkg/parser/testdata/obs-queries.csv"
Summary:
  NumOfQueries: 11
  TotalDuration: 215.426317ms
  Min: 14.703164ms
  Median: 18.428764ms
  Average: 19.58421ms
  Max: 26.788814ms

Status code distribution:
  [200] 11 responses

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Parser

type Parser interface {
	// Runs a parse loop in a blocking mode.
	Parse(ctx context.Context) error
	// Thread safe iterator like construct returns Work item one by one.
	// Return Go channel which ferries Query object.
	Queries() <-chan Query
}

Abstracts bunch of concurrently executable work items.

type Query

type Query struct {
	PromQL string
	// Unix timestamp in milli.
	StartTime int64
	// Unix timestamp in milli.
	EndTime int64
	Step    int64
}

type Report

type Report []Stat

func (Report) Len

func (a Report) Len() int

func (Report) Less

func (a Report) Less(i, j int) bool

func (Report) Swap

func (a Report) Swap(i, j int)

func (Report) ToSummary

func (r Report) ToSummary() Summary

type Reporter

type Reporter interface {
	Report(out io.Writer, s Summary) error
}

Abstracts various type of reporters. e.g. Console, JSON, CSV..

type Stat

type Stat struct {
	Error      error
	Duration   time.Duration
	StatusCode int
}

Execution statistics of works.

type Summary

type Summary struct {
	NumOfQueries   int
	TotalDuration  time.Duration
	Min            time.Duration
	Max            time.Duration
	Avg            time.Duration
	Median         time.Duration
	ErrDist        map[string]int
	StatusCodeDist map[int]int
}

type Worker

type Worker interface {
	Run(ctx context.Context, queries <-chan Query) Report
}

TODO: Check whether github.com/rakyll/hey can be used to replace this worker logic after https://github.com/rakyll/hey/pull/149.

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

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