k6runner

package
v0.37.1 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2025 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrStacktrace = errors.New("fatal error occurred while running the script")
	ErrThrown     = errors.New("uncaught error occurred while running the script")
)
View Source
var (
	ErrBuggyRunner = errors.New("runner returned buggy response")
	ErrFromRunner  = errors.New("runner reported an error")
)
View Source
var ErrNoTimeout = errors.New("check has no timeout")

ErrNoTimeout is returned by Runner implementations if the supplied script has a timeout of zero.

View Source
var ErrUnexpectedStatus = errors.New("unexpected status code")

Functions

This section is empty.

Types

type CheckInfo added in v0.29.0

type CheckInfo struct {
	// Type is the string representation of the check type this script belongs to (browser, scripted, multihttp, etc.)
	Type string `json:"type"`
	// Metadata is a collection of key/value pairs containing information about this check, such as check and tenant ID.
	// It is loosely typed on purpose: Metadata should only be used for informational properties that will make its way
	// into telemetry, and not for making decision on it.
	Metadata map[string]any `json:"metadata"`
}

CheckInfo holds information about the SM check that triggered this script.

func CheckInfoFromSM added in v0.29.0

func CheckInfoFromSM(smc smmmodel.Check) CheckInfo

CheckInfoFromSM returns a CheckInfo from the information of the given SM check.

func (*CheckInfo) MarshalZerologObject added in v0.32.0

func (ci *CheckInfo) MarshalZerologObject(e *zerolog.Event)

MarshalZerologObject implements zerolog.LogObjectMarshaler so it can be logged in a friendly way.

type HTTPMetrics added in v0.36.0

type HTTPMetrics struct {
	Requests       *prometheus.CounterVec
	RequestsPerRun *prometheus.HistogramVec
}

func NewHTTPMetrics added in v0.36.0

func NewHTTPMetrics(registerer prometheus.Registerer) *HTTPMetrics

type HTTPRunRequest added in v0.28.1

type HTTPRunRequest struct {
	Script      `json:",inline"`
	SecretStore SecretStore `json:",inline"`
	NotAfter    time.Time   `json:"notAfter"`
}

HTTPRunRequest

type HttpRunner

type HttpRunner struct {
	// contains filtered or unexported fields
}

func (HttpRunner) Run

func (r HttpRunner) Run(ctx context.Context, script Script, secretStore SecretStore) (*RunResponse, error)

func (HttpRunner) WithLogger

func (r HttpRunner) WithLogger(logger *zerolog.Logger) Runner

type Local added in v0.28.2

type Local struct {
	// contains filtered or unexported fields
}

func (Local) Run added in v0.28.2

func (r Local) Run(ctx context.Context, script Script, secretStore SecretStore) (*RunResponse, error)

func (Local) WithLogger added in v0.28.2

func (r Local) WithLogger(logger *zerolog.Logger) Runner

type Processor added in v0.24.3

type Processor struct {
	// contains filtered or unexported fields
}

Processor runs a script with a runner and parses the k6 output.

func NewProcessor added in v0.24.3

func NewProcessor(script Script, k6runner Runner) (*Processor, error)

func (Processor) Run added in v0.24.3

func (r Processor) Run(ctx context.Context, registry *prometheus.Registry, logger logger.Logger, internalLogger zerolog.Logger, secretStore SecretStore) (bool, error)

type RunResponse

type RunResponse struct {
	Error     string `json:"error,omitempty"`
	ErrorCode string `json:"errorCode,omitempty"`
	Metrics   []byte `json:"metrics"`
	Logs      []byte `json:"logs"`
}

type Runner

type Runner interface {
	WithLogger(logger *zerolog.Logger) Runner
	Run(ctx context.Context, script Script, secretStore SecretStore) (*RunResponse, error)
}

func New

func New(opts RunnerOpts) Runner

type RunnerOpts added in v0.22.0

type RunnerOpts struct {
	Uri           string
	BlacklistedIP string
	Registerer    prometheus.Registerer
}

type Script

type Script struct {
	// Script is the blob of bytes that is to be run.
	Script []byte `json:"script"`
	// Settings is a common representation of the fields common to all implementation-specific check settings that the
	// runners are interested about.
	Settings Settings `json:"settings"`
	// CheckInfo holds information about the SM check that triggered this script.
	CheckInfo CheckInfo `json:"check"`
}

Script is a k6 script that a runner is able to run, with some added instructions for that runner to act on.

type SecretStore added in v0.35.0

type SecretStore struct {
	Url   string `json:"url"`
	Token string `json:"token"`
}

func (SecretStore) IsConfigured added in v0.35.0

func (s SecretStore) IsConfigured() bool

IsConfigured returns true if the SecretStore has both URL and token configured.

type Settings added in v0.19.0

type Settings struct {
	// Timeout for k6 run, in milliseconds. This value is a configuration value for remote runners, which will instruct
	// them to return an error if the operation takes longer than this time to complete. Clients should expect that
	// requests to remote runners may take longer than this value due to network and other latencies, and thus clients
	// should wait additional time before aborting outgoing requests.
	Timeout int64 `json:"timeout"`
}

Settings is a common representation of the fields common to all implementation-specific check settings that the runners are interested about.

Jump to

Keyboard shortcuts

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