metrics

package
v4.2.26+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2019 License: Apache-2.0 Imports: 16 Imported by: 1

Documentation

Overview

Package metrics provides functions to collect runtime registry statistics and expose the registered metrics via HTTP.

Index

Constants

This section is empty.

Variables

View Source
var (
	HTTPInFlightRequests = prometheus.NewGauge(prometheus.GaugeOpts{
		Namespace: namespace,
		Subsystem: httpSubsystem,
		Name:      "in_flight_requests",
		Help:      "A gauge of requests currently being served by the registry.",
	})
	HTTPRequestsTotal = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: namespace,
			Subsystem: httpSubsystem,
			Name:      "requests_total",
			Help:      "A counter for requests to the registry.",
		},
		[]string{"code", "method"},
	)
	HTTPRequestDurationSeconds = prometheus.NewSummaryVec(
		prometheus.SummaryOpts{
			Namespace: namespace,
			Subsystem: httpSubsystem,
			Name:      "request_duration_seconds",
			Help:      "A histogram of latencies for requests to the registry.",
		},
		[]string{"method"},
	)
	HTTPRequestSizeBytes = prometheus.NewSummaryVec(
		prometheus.SummaryOpts{
			Namespace: namespace,
			Subsystem: httpSubsystem,
			Name:      "request_size_bytes",
			Help:      "A histogram of sizes of requests to the registry.",
		},
		[]string{},
	)
	HTTPResponseSizeBytes = prometheus.NewSummaryVec(
		prometheus.SummaryOpts{
			Namespace: namespace,
			Subsystem: httpSubsystem,
			Name:      "response_size_bytes",
			Help:      "A histogram of response sizes for requests to the registry.",
		},
		[]string{},
	)
	HTTPTimeToWriteHeaderSeconds = prometheus.NewSummaryVec(
		prometheus.SummaryOpts{
			Namespace: namespace,
			Subsystem: httpSubsystem,
			Name:      "time_to_write_header_seconds",
			Help:      "A histogram of request durations until the response headers are written.",
		},
		[]string{},
	)
)

Functions

func Dispatcher

func Dispatcher(ctx *handlers.Context, r *http.Request) http.Handler

Dispatcher handles the GET requests for metrics endpoint.

Types

type Cache

type Cache interface {
	Request(hit bool)
}

Cache provides generic metrics for caches.

type Core

type Core interface {
	// Repository wraps a distribution.Repository to collect statistics.
	Repository(r distribution.Repository, reponame string) distribution.Repository
}

Core is a set of metrics for the core functionality.

type Counter

type Counter interface {
	Inc()
}

Counter represents a single numerical value that only goes up.

type DigestCache

type DigestCache interface {
	DigestCache() Cache
	DigestCacheScoped() Cache
}

DigestCache is a set of metrics for the digest cache subsystem.

type Metrics

type Metrics interface {
	Core
	Pullthrough
	Storage
	DigestCache
}

Metrics is a set of all metrics that can be provided.

func NewMetrics

func NewMetrics(sink Sink) Metrics

NewMetrics returns a helper that exposes the metrics through sink to instrument the application.

func NewNoopMetrics

func NewNoopMetrics() Metrics

NewNoopMetrics return a helper that implements the Metrics interface, but does nothing.

type Observer

type Observer interface {
	Observe(float64)
}

Observer captures individual observations.

type Pullthrough

type Pullthrough interface {
	// RepositoryRetriever wraps RepositoryRetriever to collect statistics.
	RepositoryRetriever(retriever registryclient.RepositoryRetriever) registryclient.RepositoryRetriever

	// DigestBlobStoreCache() returns an interface to count cache hits/misses
	// for pullthrough blobstores.
	DigestBlobStoreCache() Cache
}

Pullthrough is a set of metrics for the pullthrough subsystem.

type Sink

type Sink interface {
	RequestDuration(funcname string) Observer
	PullthroughBlobstoreCacheRequests(resultType string) Counter
	PullthroughRepositoryDuration(registry, funcname string) Observer
	PullthroughRepositoryErrors(registry, funcname, errcode string) Counter
	StorageDuration(funcname string) Observer
	StorageErrors(funcname, errcode string) Counter
	DigestCacheRequests(resultType string) Counter
	DigestCacheScopedRequests(resultType string) Counter
}

Sink provides an interface for exposing metrics.

func NewPrometheusSink

func NewPrometheusSink() Sink

NewPrometheusSink returns a sink for exposing Prometheus metrics.

type Storage

type Storage interface {
	// StorageDriver wraps distribution/registry/storage/driver.StorageDriver
	// to collect statistics.
	StorageDriver(driver storagedriver.StorageDriver) storagedriver.StorageDriver
}

Storage is a set of metrics for the storage subsystem.

type Timer

type Timer interface {
	// Stop records the duration passed since the Timer was created with NewTimer.
	Stop()
}

Timer is a helper type to time functions.

func NewTimer

func NewTimer(observer Observer) Timer

NewTimer wraps the HistogramVec and used to track amount of time passed since the Timer was created.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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