tsplot

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultQueryFilter = "resource.type = \"global\" AND metric.type = \"%s\""

DefaultQueryFilter the query filter used if no overrides are given.

Variables

View Source
var (
	DefaultColors_HighContrast = ColorPalette{
		Foreground: colornames.White,
		Background: colornames.Black,
		GridColor:  colornames.Darkgrey,
		LineColors: []color.Color{
			color.RGBA{
				R: 0xe6,
				G: 0x9f,
				B: 0x00,
				A: 0xff,
			},
			color.RGBA{
				R: 0x56,
				G: 0xb4,
				B: 0xe9,
				A: 0xff,
			},
			color.RGBA{
				R: 0x00,
				G: 0x9e,
				B: 0x73,
				A: 0xff,
			},
			color.RGBA{
				R: 0xf0,
				G: 0xe4,
				B: 0x42,
				A: 0xff,
			},
			color.RGBA{
				R: 0x00,
				G: 0x72,
				B: 0xb2,
				A: 0x00,
			},
			color.RGBA{
				R: 0xd5,
				G: 0x5e,
				B: 0x00,
				A: 0xff,
			},
			color.RGBA{
				R: 0xcc,
				G: 0x79,
				B: 0xa7,
				A: 0xff,
			},
		},
	}
)

Functions

func ApplyDefaultHighContrast

func ApplyDefaultHighContrast(p *plot.Plot)

ApplyDefaultHighContrast applies the default high contrast color scheme to the *plot.Plot.

Types

type ColorPalette

type ColorPalette struct {
	Foreground color.Color
	Background color.Color
	GridColor  color.Color
	LineColors []color.Color
}

type MetricQuery

type MetricQuery struct {
	Project          string
	MetricDescriptor string
	StartTime        *time.Time
	EndTime          *time.Time
	// contains filtered or unexported fields
}

MetricQuery is a type that encapsulates the various parts that are used to form a ListTimeSeriesRequest. If EndTime is not provided, it will be defaulted to the current time.

Required Fields: Project MetricDescriptor StartTime

func (*MetricQuery) PerformWithClient

func (mq *MetricQuery) PerformWithClient(client *monitoring.MetricClient) (*monitoring.TimeSeriesIterator, error)

PerformWithClient sends the MetricQuery.ListTimeSeriesRequest to the Google Cloud Monitoring API. If the request has not been built yet, i.e: BuildRequest() has not been called on the MetricQuery, an error will be returned. A Google Cloud Monitoring client is required to be passed in as a parameter if authentication has not been set up on the client, an error will result from the call.

func (*MetricQuery) SetQueryFilter

func (mq *MetricQuery) SetQueryFilter(queryFilter string)

SetQueryFilter provides a hook to modify the metric query filter.

func (*MetricQuery) SetReduce

func (mq *MetricQuery) SetReduce(b bool)

SetReduce sets the boolean reduce value on *MetricQuery structure. This controls whether or not cross series reduction is performed on multiple time series.

type PlotOption

type PlotOption func(p *plot.Plot)

PlotOption defines the type used to configure the underlying *plot.Plot. A function that returns PlotOption can be used to set options on the *plot.Plot.

func WithBackground

func WithBackground(color color.Color) PlotOption

WithBackground sets the background color on the *plot.Plot.

func WithForeground

func WithForeground(color color.Color) PlotOption

WithForeground sets the foreground colors of the *plot.Plot to the provided color.

func WithGrid

func WithGrid(color color.Color) PlotOption

WithGrid adds a grid to the *plot.Plot and sets the color.

func WithLegend

func WithLegend(color color.Color) PlotOption

WithLegend sets the text color of the legend.

func WithTitle

func WithTitle(title string) PlotOption

WithTitle configures the title text of the *plot.Plot.

func WithXAxisName

func WithXAxisName(name string) PlotOption

WithXAxisName sets the name of the X Axis.

func WithXTimeTicks

func WithXTimeTicks(format string) PlotOption

WithXTimeTicks configures the format for the tick marks on the X Axis.

func WithYAxisName

func WithYAxisName(name string) PlotOption

WithYAxisName sets the name of the Y Axis.

type TimeSeries

type TimeSeries map[string][]*monitoringpb.Point

TimeSeries is a map representation of unique names to time series.

func (TimeSeries) Plot

func (ts TimeSeries) Plot(opts ...PlotOption) (*plot.Plot, error)

Plot builds and returns a *plot.Plot. If the TimeSeriesGroup field in TimeSeriesPlot is empty, a nil plot is returned as well as an error. This is also the case if an error is encountered building the line from the XY coordinates.

Jump to

Keyboard shortcuts

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