metrics

package
v0.0.0-...-6fa6ba7 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package metrics implements the metrics used for recording information when monitoring a storage system.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ProbeOpName maps ProbeOperation constants to their metric label string equivalent.
	ProbeOpName = map[ProbeOperation]string{
		TotalProbeRun:      "total_probe_run",
		CheckNil:           "check_nil",
		ReadFile:           "read_file",
		VerifyFileContents: "verify_file_contents",
		DeleteFile:         "delete_file",
		CreateFile:         "create_file",
	}
	// APICallName maps ApiCall constants to their metric label string equivalent.
	APICallName = map[APICall]string{
		APIListFiles:  "list_files",
		APICreateFile: "create_file",
		APIDeleteFile: "delete_file",
		APIGetFile:    "get_file",
	}
	// ExitStatusName maps ExitStatus constants to their metric label string equivalent.
	ExitStatusName = map[ExitStatus]string{
		Success:              "success",
		OpTimeout:            "op_timeout",
		ProbeFailed:          "probe_failed",
		APICallFailed:        "api_call_failed",
		FileMissing:          "file_missing",
		BucketMissing:        "bucket_missing",
		FileCorrupted:        "file_corrupted",
		FileReadFailure:      "file_read_failure",
		FileMetadataMismatch: "file_metadata_mismatch",
		UnknownFileFound:     "unknown_file_found",
		AllFilesMissing:      "all_files_missing",
	}
)

Functions

This section is empty.

Types

type APICall

type APICall int

APICall represents a possible API call metric label.

const (
	// APIListFiles is the metric label for the list files API call.
	APIListFiles APICall = iota
	// APICreateFile is the metric label for the create file API call.
	APICreateFile
	// APIDeleteFile is the metric label for the delete file API call.
	APIDeleteFile
	// APIGetFile is the metric label for the get file API call.
	APIGetFile
)

type ExitStatus

type ExitStatus int

ExitStatus represents a possible exit status metric label.

const (
	// Success indicates the operation/API call was successful.
	Success ExitStatus = iota
	// OpTimeout indicates that the operation/API call timed out.
	OpTimeout
	// ProbeFailed indicates that the probe failed due to an error.
	ProbeFailed
	// APICallFailed indicates that the API call failed due to an error.
	APICallFailed
	// FileMissing indicates that the target file could not be found.
	FileMissing
	// BucketMissing indicates that the target bucket could not be found.
	BucketMissing
	// FileCorrupted indicates that the target file was corrupted and the contents could not be read.
	FileCorrupted
	// FileReadFailure indicates that the target file could not be read.
	FileReadFailure
	// FileMetadataMismatch indicates that the target file did not match the expectation from its metadata
	// TODO(evanSpendlove): Review if we need this? When would we use it?
	FileMetadataMismatch
	// UnknownFileFound indicates that an unknown file, not created by Hermes, was found in the target bucket.
	UnknownFileFound
	// AllFilesMissing indicates that all of the Hermes files were missing.
	AllFilesMissing
)

type Metrics

type Metrics struct {
	// probeOpLatency is used to record latency values with distinct labels
	// per exit status per probe operation per target.
	// Recommended usage: probeOpLatency[ProbeOperation][ExitStatus].Metric("latency").AddFloat64(<val>)
	ProbeOpLatency map[ProbeOperation]map[ExitStatus]*metrics.EventMetrics
	// apiCallLatency is used to record latency values with distinct labels
	// per exit status per API call per target.
	// Recommended usage: apiCallLatency[ApiCall][ExitStatus].Metric("latency").AddFloat64(<val>)
	APICallLatency map[APICall]map[ExitStatus]*metrics.EventMetrics
}

Metrics stores the cumulative metrics for probe runs for a target.

func NewMetrics

func NewMetrics(conf *probepb.HermesProbeDef, target *probepb.Target) (*Metrics, error)

NewMetrics creates a new *Metrics object and initialises the fields inside it. Arguments:

  • conf: pass a HermesProbeDef config
  • target: pass the target for which metrics are to be collected.

Returns:

  • m: returns an initialised *Metrics object.
  • err: returns an error if a latency distribution cannot be created from the config proto.

type ProbeOperation

type ProbeOperation int

ProbeOperation represents a possible probe operation metric label.

const (
	// TotalProbeRun is the metric label for the overall probe run.
	TotalProbeRun ProbeOperation = iota
	// CheckNil is the metric label for the check nil file existence and consistency operation.
	CheckNil
	// ReadFile is the metric label for the read file operation.
	ReadFile
	// VerifyFileContents is the metric label for the verify file contents operation.
	VerifyFileContents
	// DeleteFile is the metric label for the delete file operation.
	DeleteFile
	// CreateFile is the metric label for the create file operation.
	CreateFile
)

Jump to

Keyboard shortcuts

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