metrics

package
v1.0.17 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// APISource is sent for API metrics
	APISource = "api"
	// SuccessStatus command success
	SuccessStatus = "success"
	// FailureStatus command failure
	FailureStatus = "failure"
	// ComposeParseFailureStatus failure while parsing compose file
	ComposeParseFailureStatus = "failure-compose-parse"
	// FileNotFoundFailureStatus failure getting compose file
	FileNotFoundFailureStatus = "failure-file-not-found"
	// CommandSyntaxFailureStatus failure reading command
	CommandSyntaxFailureStatus = "failure-cmd-syntax"
	// BuildFailureStatus failure building imge
	BuildFailureStatus = "failure-build"
	// PullFailureStatus failure pulling imge
	PullFailureStatus = "failure-pull"
	// CanceledStatus command canceled
	CanceledStatus = "canceled"
)

Variables

View Source
var (
	// FileNotFoundFailure failure for compose file not found
	FileNotFoundFailure = FailureCategory{MetricsStatus: FileNotFoundFailureStatus, ExitCode: 14}
	// ComposeParseFailure failure for composefile parse error
	ComposeParseFailure = FailureCategory{MetricsStatus: ComposeParseFailureStatus, ExitCode: 15}
	// CommandSyntaxFailure failure for command line syntax
	CommandSyntaxFailure = FailureCategory{MetricsStatus: CommandSyntaxFailureStatus, ExitCode: 16}
	//BuildFailure failure while building images.
	BuildFailure = FailureCategory{MetricsStatus: BuildFailureStatus, ExitCode: 17}
	// PullFailure failure while pulling image
	PullFailure = FailureCategory{MetricsStatus: PullFailureStatus, ExitCode: 18}
)
View Source
var CLISource = "cli"

CLISource is sent for cli metrics

Functions

func GetCommand

func GetCommand(args []string) string

GetCommand get the invoked command

func HasQuietFlag added in v1.0.13

func HasQuietFlag(args []string) bool

HasQuietFlag returns true if one of the arguments is `--quiet` or `-q`

func Track

func Track(context string, args []string, status string)

Track sends the tracking analytics to Docker Desktop

func WrapCategorisedComposeError added in v1.0.13

func WrapCategorisedComposeError(err error, failure FailureCategory) error

WrapCategorisedComposeError wraps the error if not nil, otherwise returns nil

func WrapComposeError added in v1.0.13

func WrapComposeError(err error) error

WrapComposeError wraps the error if not nil, otherwise returns nil

Types

type Client

type Client interface {
	// Send sends the command to Docker Desktop. Note that the function doesn't
	// return anything, not even an error, this is because we don't really care
	// if the metrics were sent or not. We only fire and forget.
	Send(Command)
}

Client sends metrics to Docker Desktopn

func NewClient

func NewClient() Client

NewClient returns a new metrics client

type Command

type Command struct {
	Command string `json:"command"`
	Context string `json:"context"`
	Source  string `json:"source"`
	Status  string `json:"status"`
}

Command is a command

type ComposeError added in v1.0.13

type ComposeError struct {
	Err      error
	Category *FailureCategory
}

ComposeError error to categorize failures and extract metrics info

func (ComposeError) Error added in v1.0.13

func (e ComposeError) Error() string

func (ComposeError) GetMetricsFailureCategory added in v1.0.13

func (e ComposeError) GetMetricsFailureCategory() FailureCategory

GetMetricsFailureCategory get metrics status and error code corresponding to this error

func (ComposeError) Unwrap added in v1.0.13

func (e ComposeError) Unwrap() error

Unwrap get underlying error

type FailureCategory added in v1.0.13

type FailureCategory struct {
	MetricsStatus string
	ExitCode      int
}

FailureCategory sruct regrouping metrics failure status and specific exit code

func ByExitCode added in v1.0.14

func ByExitCode(exitCode int) FailureCategory

ByExitCode retrieve FailureCategory based on command exit code

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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