csv

package
v0.0.0-...-deba56b Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2023 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

Package csv implements an output writing metrics in csv format

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsStringInSlice

func IsStringInSlice(slice []string, str string) bool

IsStringInSlice returns whether the string is contained within a string slice

func MakeHeader

func MakeHeader(tags []string) []string

MakeHeader creates list of column names for csv file

func New

func New(params output.Params) (output.Output, error)

New Creates new instance of CSV output

func SampleToRow

func SampleToRow(sample *metrics.Sample, resTags []string, ignoredTags []string, row []string,
	timeFormat TimeFormat,
) []string

SampleToRow converts sample into array of strings

func TimeFormatStrings

func TimeFormatStrings() []string

TimeFormatStrings returns a slice of all String values of the enum

Types

type Config

type Config struct {
	// Samples.
	FileName     null.String        `json:"file_name" envconfig:"K6_CSV_FILENAME"`
	SaveInterval types.NullDuration `json:"save_interval" envconfig:"K6_CSV_SAVE_INTERVAL"`
	TimeFormat   null.String        `json:"time_format" envconfig:"K6_CSV_TIME_FORMAT"`
}

Config is the config for the csv output

func GetConsolidatedConfig

func GetConsolidatedConfig(
	jsonRawConf json.RawMessage, env map[string]string, arg string, logger logrus.FieldLogger,
) (Config, error)

GetConsolidatedConfig combines {default config values + JSON config + environment vars + arg config values}, and returns the final result.

func NewConfig

func NewConfig() Config

NewConfig creates a new Config instance with default values for some fields.

func ParseArg

func ParseArg(arg string, logger logrus.FieldLogger) (Config, error)

ParseArg takes an arg string and converts it to a config

func (Config) Apply

func (c Config) Apply(cfg Config) Config

Apply merges two configs by overwriting properties in the old config

type Output

type Output struct {
	output.SampleBuffer
	// contains filtered or unexported fields
}

Output implements the lib.Output interface for saving to CSV files.

func (*Output) Description

func (o *Output) Description() string

Description returns a human-readable description of the output.

func (*Output) Start

func (o *Output) Start() error

Start writes the csv header and starts a new output.PeriodicFlusher

func (*Output) Stop

func (o *Output) Stop() error

Stop flushes any remaining metrics and stops the goroutine.

type TimeFormat

type TimeFormat uint8

TimeFormat custom enum type

const (
	TimeFormatUnix TimeFormat = iota
	TimeFormatUnixMilli
	TimeFormatUnixMicro
	TimeFormatUnixNano
	TimeFormatRFC3339
	TimeFormatRFC3339Nano
)

valid defined values for TimeFormat

func TimeFormatString

func TimeFormatString(s string) (TimeFormat, error)

TimeFormatString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func TimeFormatValues

func TimeFormatValues() []TimeFormat

TimeFormatValues returns all values of the enum

func (TimeFormat) IsATimeFormat

func (i TimeFormat) IsATimeFormat() bool

IsATimeFormat returns "true" if the value is listed in the enum definition. "false" otherwise

func (TimeFormat) String

func (i TimeFormat) String() string

Jump to

Keyboard shortcuts

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