replay

package
v0.0.0-...-12b6520 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2018 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RootCmd = &cobra.Command{
	Use:   "replay",
	Short: "Runs a performance testing and collects metrics.",
	Long:  "Multiplatform command line tool to load test and collect metrics from your ElasticSearch deployment.",
	PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
		if numClients < 1 {
			return fmt.Errorf("number of clients must be positive")
		}

		var err error
		r = runner{}
		if resultsPath == "" {
			return fmt.Errorf("results path can not be empty. Please set --results_path flag")
		}

		r.requestsSent = metrics.NewCounter()
		r.errors = metrics.NewCounter()
		r.responseTimes = metrics.NewHistogram()
		r.pauseTimes = metrics.NewHistogram()
		r.clients = make(chan *http.Client, numClients)
		for i := 0; i < numClients; i++ {
			r.clients <- &http.Client{
				Transport: &http.Transport{
					Dial: (&net.Dialer{
						LocalAddr: &net.TCPAddr{IP: defaultLocalAddr.IP, Zone: defaultLocalAddr.Zone},
						KeepAlive: 3 * timeout,
						Timeout:   timeout,
					}).Dial,
					ResponseHeaderTimeout: timeout,
					MaxIdleConnsPerHost:   defaultConnections,
				},
			}
		}

		r.perRequest, err = reporter.NewPerRequestReport(csvFilePath("request", expID, resultsPath))
		if err != nil {
			return err
		}

		collector, err := esmetrics.NewCollector(host, timeout, debug)
		if err != nil {
			return err
		}
		r.report, err = reporter.New(
			cint,
			timeout,
			reporter.MetricToCSV(r.responseTimes, csvFilePath("response.time", expID, resultsPath)),
			reporter.MetricToCSV(r.pauseTimes, csvFilePath("pause.time", expID, resultsPath)),
			reporter.MetricToCSV(r.requestsSent, csvFilePath("requests.sent", expID, resultsPath)),
			reporter.MetricToCSV(r.errors, csvFilePath("errors", expID, resultsPath)),
			reporter.AddCollector(collector),
			reporter.MetricToCSV(collector.Mem.YoungHeapPool, csvFilePath("mem.young", expID, resultsPath)),
			reporter.MetricToCSV(collector.Mem.TenuredHeapPool, csvFilePath("mem.tenured", expID, resultsPath)),
			reporter.MetricToCSV(collector.Mem.SurvivorHeapPool, csvFilePath("mem.survivor", expID, resultsPath)),
			reporter.MetricToCSV(collector.Mem.Heap, csvFilePath("mem.heap", expID, resultsPath)),
			reporter.MetricToCSV(collector.Mem.NonHeap, csvFilePath("mem.nonheap", expID, resultsPath)),
			reporter.MetricToCSV(collector.Mem.OS, csvFilePath("mem.os", expID, resultsPath)),
			reporter.MetricToCSV(collector.Mem.Swap, csvFilePath("mem.swap", expID, resultsPath)),
			reporter.MetricToCSV(collector.CPU, csvFilePath("cpu", expID, resultsPath)),
			reporter.MetricToCSV(collector.GC.Young, csvFilePath("gc.young", expID, resultsPath)),
			reporter.MetricToCSV(collector.GC.Full, csvFilePath("gc.full", expID, resultsPath)),
		)
		if err != nil {
			return err
		}
		return nil
	},
	RunE: func(cmd *cobra.Command, args []string) error {
		if err := r.Run(); err != nil {
			return err
		}
		return nil
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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