quickstore

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2019 License: Apache-2.0 Imports: 12 Imported by: 31

Documentation

Overview

Package quickstore offers a way to utilize Mako storage, downsampling, aggregation and analyzers in a simple way. This is most helpful when you have a pre-existing benchmarking tool which exports data that you would like to save in Mako.

To use: Understand and create a Mako benchmark to hold your data. See

go/mako-help?tmpl=storage#bench for more information about benchmarks.
Watch 'Chart' videos at go/mako-videos for demos of the Mako
dashboard.

Basic usage:

 // Store data, metric and run aggregates will be calculated automatically.
	q := quickstore.Quickstore{BenchmarkKey: myBenchmarkKey}
 for _, data := range []float64{4, 6, 40, 3.2} {
   q.AddSamplePoint(timestampMs, data)
 output, err = q.Store()
 if err != nil {
		if output.GetStatus() == qpb.QuickstoreOutput_ANALYSIS_FAIL {
			// handle analysis failure
		} else {
			// handle error
		}
 }

See more examples inside https://github.com/google/mako/blob/master/go/quickstore/quickstore_example_test.go

Struct is not concurrent safe

More information about quickstore: go/mako-quickstore

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Quickstore

type Quickstore struct {
	// BenchmarkKey to where your data will be stored to.
	BenchmarkKey string
	// Allows more information to be passed about the Mako Run that will be
	// created.
	Input qpb.QuickstoreInput
	// contains filtered or unexported fields
}

Quickstore allows saving of data passed via Add* methods to Mako. Zero struct is usable but before calling Store() you must populate:

  • BenchmarkKey to the Mako benchmark you'd like your data saved to. OR
  • Input (with Input.BenchmarkKey set) to define more information about the Mako run where you data will be stored. See QuickstoreInput for more information.

func NewAtAddress

func NewAtAddress(ctx context.Context, input *qpb.QuickstoreInput, address string) (*Quickstore, func(context.Context), error)

NewAtAddress creates a new Quickstore that connects to a Quickstore microservice at the provided gRPC address.

Along with the Quickstore instance, it returns a function that can be called to request the microsevice terminate itself. This function can be ignored in order to leave the microservice running.

func NewAtHostWithSidecar

func NewAtHostWithSidecar(ctx context.Context, input *qpb.QuickstoreInput, makoHostAddress string, sidecarAddress string) (*Quickstore, func(context.Context), error)

NewAtHostWithSidecar creates a new Quickstore that connects to a Quickstore sidecar (aka microservice) at the provided gRPC address. The sidecar will be configured to connect to the Mako server at the provided address.

Along with the Quickstore instance, it returns a function that can be called to request the microsevice terminate itself. This function can be ignored in order to leave the microservice running.

makoHostAddress may be empty, in which case the sidecar will use the default Mako host ("https://mako.dev") or the one configured with the MAKO_SERVER_ADDRESS environment variable.

func (*Quickstore) AddError

func (q *Quickstore) AddError(xval float64, errorMessage string) error

AddError add an error at the specified xval.

When adding errors via this function, the aggregate error count will be set automatically.

An error is returned if there was a problem adding data.

func (*Quickstore) AddMetricAggregate

func (q *Quickstore) AddMetricAggregate(valueKey string, aggregateType string, value float64) error

AddMetricAggregate adds an aggregate for a specific metric. If value_key is:

The value_key can also represent a percentile see https://github.com/google/mako/blob/master/spec/proto/mako.proto

For example "p98000" would be interpreted as the 98th percentile. These need to correspond to the percentiles that your benchmark has set. It is an error to supply an percentile that is not part of your benchmark. If any percentiles are provided, the automatically calculated percentiles will be cleared to 0.

If any aggregate_types (eg. "min") are set for a value_key it will overwrite the entire MetricAggregate for that value_key. If no aggregate_types are provided for a value_key metric aggregates (including percentiles) will be calculated automatically based on data provided via calls to AddSamplePoint.

An error is returned if there was a problem adding data.

func (*Quickstore) AddRunAggregate

func (q *Quickstore) AddRunAggregate(valueKey string, value float64) error

AddRunAggregate adds an aggregate value over the entire run. If value_key is:

  • "~ignore_sample_count"
  • "~usable_sample_count"
  • "~error_sample_count"
  • "~benchmark_score" The corresponding value will be overwritten inside https://github.com/google/mako/blob/master/spec/proto/mako.proto of these values are provided, they will be calculated automatically by the framework based on SamplePoints/Errors provided before Store() is called.

Otherwise the value_key will be set to a custom aggregate (See https://github.com/google/mako/blob/master/spec/proto/mako.proto

If no run aggregates are manully set with this method, values are automatically calculated.

An error is returned if there was a problem adding data.

func (*Quickstore) AddSamplePoint

func (q *Quickstore) AddSamplePoint(xval float64, valueKeyToYVals map[string]float64) error

AddSamplePoint adds a sample at the specified x-value.

How the x-value is interpreted depends on your benchmark configuration. See BenchmarkInfo.input_value_info for more information.

The map represents a mapping from metric to value. It is more efficient for Mako to store multiple metrics collected at the same xval together, but it is optional.

When adding data via this function, calling the Add*Aggregate() functions is optional, as the aggregates will get computed by this class.

An error is returned if there was a problem adding data.

func (*Quickstore) Store

func (q *Quickstore) Store() (qpb.QuickstoreOutput, error)

Store all the values that you have added. You cannot save if no Add*() functions have been called.

Each call to Store() will create a new unique Mako Run and store all Aggregate and SamplePoint data registered using the Add* methods since the last call to Store() as a part of that new Run.

Data can be added via Add* calls in any order.

An error is returned if the Store call encountered an error. See the QuickstoreOutput proto buffer also returned for more information about the failure.

Jump to

Keyboard shortcuts

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