observability

package
v1.47.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package observability provides logging and metrics instrumentation using GitLab LabKit.

This package initializes structured logging and exposes Prometheus metrics for monitoring cache hits, misses, upstream requests, and request coalescing.

Index

Constants

View Source
const (
	// FetchResultHit is a request served directly from the cache.
	FetchResultHit = "hit"
	// FetchResultMiss is a request that fetched from upstream and cached the result.
	FetchResultMiss = "miss"
	// FetchResultCoalesce is a request that coalesced onto an in-flight upstream fetch.
	FetchResultCoalesce = "coalesce"
	// FetchResultBypass is a cacheable-path request that was proxied without caching.
	FetchResultBypass = "bypass"
)

Fetch result label values for ObserveFetchDuration.

View Source
const (
	// EvictionReasonTTL is a sliding-TTL expiration.
	EvictionReasonTTL = "ttl"
	// EvictionReasonSize is an LFU-driven eviction under size/cost pressure.
	EvictionReasonSize = "size"
	// EvictionReasonReject is an admission-policy rejection on Set.
	EvictionReasonReject = "reject"
)

Eviction reason label values for IncCacheEvictions.

View Source
const (
	// ErrorTypeUpstream is a failure talking to the upstream Git server.
	ErrorTypeUpstream = "upstream"
	// ErrorTypeCache is a failure reading from or writing to the cache.
	ErrorTypeCache = "cache"
	// ErrorTypeInternal is a failure parsing, decompressing, or serializing a request.
	ErrorTypeInternal = "internal"
	// ErrorTypeUpstreamInBand is an upstream response that returned HTTP 200 but
	// carried an in-band git error or a truncated packfile, so it was served to
	// the client but not cached.
	ErrorTypeUpstreamInBand = "upstream_in_band"
)

Error type label values for IncErrors.

View Source
const RepositoryLabelDisabled = "_disabled"

RepositoryLabelDisabled is the sentinel repository label value used when the allowlist is disabled, so that per-repository cache metrics stay bounded in cardinality (all traffic collapses into one series) while totals remain visible.

Variables

This section is empty.

Functions

func InitializeLogging

func InitializeLogging(level string, format string) *slog.Logger

InitializeLogging sets up LabKit v2 structured logging and returns the configured logger. It also sets the logger as the default slog logger so package-level slog calls work.

Types

type AppMetrics

type AppMetrics interface {
	// IncCacheHits increments the cache hits counter for the given repository.
	IncCacheHits(repository string)

	// IncCacheMisses increments the cache misses counter for the given repository.
	IncCacheMisses(repository string)

	// IncCoalescedRequests increments the counter of requests served by coalescing
	// onto an in-flight upstream fetch, for the given repository.
	IncCoalescedRequests(repository string)

	// IncCacheEntryMissing increments the counter of serve-time cache misses for
	// the given repository: a fetch that stored or coalesced successfully but
	// found its entry gone when it went to serve it, and had to re-fetch.
	IncCacheEntryMissing(repository string)

	// IncCacheRebuilds increments the counter of local cache entries rebuilt from
	// the pack in object storage, for the given repository. It counts downloads, so
	// requests coalesced onto one rebuild record a single increment between them.
	IncCacheRebuilds(repository string)

	// IncNonCacheableRequests increments the non-cacheable requests counter for the given reason.
	IncNonCacheableRequests(reason string)

	// IncCacheEvictions increments the cache-evictions counter for the given reason
	// (ttl, size, reject). Reason distinguishes sliding-TTL expiration from
	// size-driven LFU eviction from admission-policy rejection.
	IncCacheEvictions(reason string)

	// ObserveFetchDuration records the end-to-end duration of a cacheable fetch,
	// labelled by result (hit, miss, coalesce, bypass).
	ObserveFetchDuration(result string, seconds float64)

	// IncErrors increments the error counter for the given type (upstream, cache, internal).
	IncErrors(errorType string)

	// IncDryRunWouldHit records that a dry-run request would have been served
	// from the cache (its key is already tracked in the shadow store).
	IncDryRunWouldHit(repository string)

	// IncDryRunWouldMiss records that a dry-run request would have been a
	// fresh upstream fetch (no shadow entry, no coalescing).
	IncDryRunWouldMiss(repository string)

	// IncDryRunWouldCoalesce records that a dry-run request would have
	// coalesced onto an in-flight fetch for the same key.
	IncDryRunWouldCoalesce(repository string)

	// IncDryRunNonCacheable records a dry-run request whose command shape
	// makes it ineligible for caching (empty key from the parser).
	IncDryRunNonCacheable(repository, reason string)

	// IncDryRunEvictions records a shadow-store eviction, labelled by reason
	// (ttl or size).
	IncDryRunEvictions(reason string)

	// ObserveDryRunWouldCacheBytes records the response size of a would-miss
	// request: the bytes that would have been admitted to the cache had
	// caching been on. Only observed on the leader (would-miss), since only
	// the leader would have populated the cache; followers ride on it.
	ObserveDryRunWouldCacheBytes(repository string, bytes float64)

	// AddDryRunShadowSizeBytes increases the per-repository shadow-store
	// size gauge, called on every would-miss admission.
	AddDryRunShadowSizeBytes(repository string, bytes float64)

	// SubDryRunShadowSizeBytes decreases the per-repository shadow-store
	// size gauge, called from the shadow's OnEvictSize callback on every
	// eviction so the gauge stays balanced with admissions.
	SubDryRunShadowSizeBytes(repository string, bytes int64)

	// IncPackfileURICacheHits increments the counter of URI-capable client
	// requests served as a `packfile-uri` (signed URL to the bucket), for the
	// given repository.
	IncPackfileURICacheHits(repository string)

	// IncPackfileURICacheMisses increments the counter of URI-capable client
	// requests that could not be served as a `packfile-uri` (no local cache
	// entry, no bucket-side pack yet), for the given repository.
	IncPackfileURICacheMisses(repository string)

	// IncPackfileURIOffloads increments the counter of successful background
	// pack uploads to object storage, for the given repository.
	IncPackfileURIOffloads(repository string)

	// IncPackfileURIOffloadFailures increments the counter of failed background
	// pack uploads to object storage, for the given repository.
	IncPackfileURIOffloadFailures(repository string)

	// ObservePackfileURIOffloadDuration records the wall-clock duration of one
	// background pack upload to object storage. Emitted regardless of success or
	// failure, so slow failures show up in the tail.
	ObservePackfileURIOffloadDuration(seconds float64)

	// AddPackfileURIBytesServed adds `bytes` to the cumulative pack bytes handed
	// off to clients as signed URLs (i.e. bytes that did NOT traverse Packhorse's
	// pod egress). This is the load-bearing benefit signal: divided by
	// http_response_size_bytes it gives the share of client-facing bytes moved
	// off Packhorse.
	AddPackfileURIBytesServed(repository string, bytes float64)

	// AddPackfileURIOffloadBytes adds `bytes` to the cumulative pack bytes
	// written to object storage on a successful background upload.
	AddPackfileURIOffloadBytes(repository string, bytes float64)
}

AppMetrics defines the interface for recording Packhorse application metrics. This abstraction allows for different implementations (e.g., Prometheus, mock for testing, null object). A single collector wraps every observability method; splitting would push the composition (and mocking) burden out to every call site for no readability gain.

type CacheCollector added in v1.25.0

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

CacheCollector is a prometheus.Collector that reports cache storage gauges by reading on-disk state at scrape time. Reading on scrape keeps them accurate without in-memory counters that would drift as entries are evicted.

func NewCacheCollector added in v1.25.0

func NewCacheCollector(manager *cache.Manager) *CacheCollector

NewCacheCollector creates a CacheCollector for the given cache manager.

func (*CacheCollector) Collect added in v1.25.0

func (c *CacheCollector) Collect(ch chan<- prometheus.Metric)

Collect implements prometheus.Collector.

func (*CacheCollector) Describe added in v1.25.0

func (c *CacheCollector) Describe(ch chan<- *prometheus.Desc)

Describe implements prometheus.Collector.

type MockAppMetrics

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

MockAppMetrics is a thread-safe mock implementation of the AppMetrics interface for testing.

func NewMockAppMetrics

func NewMockAppMetrics() *MockAppMetrics

NewMockAppMetrics creates a new MockAppMetrics instance.

func (*MockAppMetrics) AddDryRunShadowSizeBytes added in v1.46.0

func (m *MockAppMetrics) AddDryRunShadowSizeBytes(repository string, bytes float64)

AddDryRunShadowSizeBytes increases the shadow-store size gauge for the repository.

func (*MockAppMetrics) AddPackfileURIBytesServed added in v1.45.0

func (m *MockAppMetrics) AddPackfileURIBytesServed(repository string, bytes float64)

AddPackfileURIBytesServed adds bytes to the URI-served counter for the given repository.

func (*MockAppMetrics) AddPackfileURIOffloadBytes added in v1.45.0

func (m *MockAppMetrics) AddPackfileURIOffloadBytes(repository string, bytes float64)

AddPackfileURIOffloadBytes adds bytes to the offloaded-bytes counter for the given repository.

func (*MockAppMetrics) GetCacheEntryMissing added in v1.28.2

func (m *MockAppMetrics) GetCacheEntryMissing() int64

GetCacheEntryMissing returns the total serve-time cache-miss count.

func (*MockAppMetrics) GetCacheEntryMissingByRepo added in v1.28.2

func (m *MockAppMetrics) GetCacheEntryMissingByRepo(repository string) int64

GetCacheEntryMissingByRepo returns the serve-time cache-miss count for the given repository.

func (*MockAppMetrics) GetCacheEvictions added in v1.38.0

func (m *MockAppMetrics) GetCacheEvictions() int64

GetCacheEvictions returns the total cache-evictions count.

func (*MockAppMetrics) GetCacheEvictionsByReason added in v1.38.0

func (m *MockAppMetrics) GetCacheEvictionsByReason(reason string) int64

GetCacheEvictionsByReason returns the cache-evictions count for the given reason.

func (*MockAppMetrics) GetCacheHits

func (m *MockAppMetrics) GetCacheHits() int64

GetCacheHits returns the total cache hits count.

func (*MockAppMetrics) GetCacheHitsByRepo added in v1.25.0

func (m *MockAppMetrics) GetCacheHitsByRepo(repository string) int64

GetCacheHitsByRepo returns the cache hits count for the given repository.

func (*MockAppMetrics) GetCacheMisses

func (m *MockAppMetrics) GetCacheMisses() int64

GetCacheMisses returns the total cache misses count.

func (*MockAppMetrics) GetCacheMissesByRepo added in v1.25.0

func (m *MockAppMetrics) GetCacheMissesByRepo(repository string) int64

GetCacheMissesByRepo returns the cache misses count for the given repository.

func (*MockAppMetrics) GetCacheRebuilds added in v1.43.0

func (m *MockAppMetrics) GetCacheRebuilds() int64

GetCacheRebuilds returns the total count of entries rebuilt from object storage.

func (*MockAppMetrics) GetCacheRebuildsByRepo added in v1.43.0

func (m *MockAppMetrics) GetCacheRebuildsByRepo(repository string) int64

GetCacheRebuildsByRepo returns the object-storage rebuild count for the given repository.

func (*MockAppMetrics) GetCoalescedRequests added in v1.25.0

func (m *MockAppMetrics) GetCoalescedRequests() int64

GetCoalescedRequests returns the total coalesced requests count.

func (*MockAppMetrics) GetCoalescedRequestsByRepo added in v1.25.0

func (m *MockAppMetrics) GetCoalescedRequestsByRepo(repository string) int64

GetCoalescedRequestsByRepo returns the coalesced requests count for the given repository.

func (*MockAppMetrics) GetDryRunEvictionsByReason added in v1.41.0

func (m *MockAppMetrics) GetDryRunEvictionsByReason(reason string) int64

GetDryRunEvictionsByReason returns the shadow-store eviction count for the reason.

func (*MockAppMetrics) GetDryRunNonCacheableByRepo added in v1.41.0

func (m *MockAppMetrics) GetDryRunNonCacheableByRepo(repository string) int64

GetDryRunNonCacheableByRepo returns the dry-run non-cacheable count for the repository summed across every reason. Use it to assert that a request emitted no non-cacheable observation at all, where naming a specific reason would not.

func (*MockAppMetrics) GetDryRunNonCacheableByRepoReason added in v1.44.0

func (m *MockAppMetrics) GetDryRunNonCacheableByRepoReason(repository, reason string) int64

GetDryRunNonCacheableByRepoReason returns the dry-run non-cacheable count for the repository and reason.

func (*MockAppMetrics) GetDryRunShadowSizeByRepo added in v1.46.0

func (m *MockAppMetrics) GetDryRunShadowSizeByRepo(repository string) float64

GetDryRunShadowSizeByRepo returns the current shadow-store size gauge value for the repository.

func (*MockAppMetrics) GetDryRunWouldCacheBytesByRepo added in v1.46.0

func (m *MockAppMetrics) GetDryRunWouldCacheBytesByRepo(repository string) []float64

GetDryRunWouldCacheBytesByRepo returns the recorded would-cache byte observations for the repository.

func (*MockAppMetrics) GetDryRunWouldCoalesceByRepo added in v1.41.0

func (m *MockAppMetrics) GetDryRunWouldCoalesceByRepo(repository string) int64

GetDryRunWouldCoalesceByRepo returns the dry-run would-coalesce count for the repository.

func (*MockAppMetrics) GetDryRunWouldHitByRepo added in v1.41.0

func (m *MockAppMetrics) GetDryRunWouldHitByRepo(repository string) int64

GetDryRunWouldHitByRepo returns the dry-run would-hit count for the repository.

func (*MockAppMetrics) GetDryRunWouldMissByRepo added in v1.41.0

func (m *MockAppMetrics) GetDryRunWouldMissByRepo(repository string) int64

GetDryRunWouldMissByRepo returns the dry-run would-miss count for the repository.

func (*MockAppMetrics) GetErrors added in v1.25.0

func (m *MockAppMetrics) GetErrors(errorType string) int64

GetErrors returns the error count for the given type.

func (*MockAppMetrics) GetFetchDurations added in v1.25.0

func (m *MockAppMetrics) GetFetchDurations(result string) []float64

GetFetchDurations returns the recorded fetch duration observations for the given result.

func (*MockAppMetrics) GetNonCacheableRequests

func (m *MockAppMetrics) GetNonCacheableRequests() int64

GetNonCacheableRequests returns the current non-cacheable requests count.

func (*MockAppMetrics) GetPackfileURIBytesServedByRepo added in v1.45.0

func (m *MockAppMetrics) GetPackfileURIBytesServedByRepo(repository string) float64

GetPackfileURIBytesServedByRepo returns the URI-served bytes for the given repository.

func (*MockAppMetrics) GetPackfileURICacheHitsByRepo added in v1.45.0

func (m *MockAppMetrics) GetPackfileURICacheHitsByRepo(repository string) int64

GetPackfileURICacheHitsByRepo returns the packfile-uri hit count for the given repository.

func (*MockAppMetrics) GetPackfileURICacheMissesByRepo added in v1.45.0

func (m *MockAppMetrics) GetPackfileURICacheMissesByRepo(repository string) int64

GetPackfileURICacheMissesByRepo returns the packfile-uri miss count for the given repository.

func (*MockAppMetrics) GetPackfileURIOffloadBytesByRepo added in v1.45.0

func (m *MockAppMetrics) GetPackfileURIOffloadBytesByRepo(repository string) float64

GetPackfileURIOffloadBytesByRepo returns the offloaded-bytes for the given repository.

func (*MockAppMetrics) GetPackfileURIOffloadFailuresByRepo added in v1.45.0

func (m *MockAppMetrics) GetPackfileURIOffloadFailuresByRepo(repository string) int64

GetPackfileURIOffloadFailuresByRepo returns the failed offload count for the given repository.

func (*MockAppMetrics) GetPackfileURIOffloadsByRepo added in v1.45.0

func (m *MockAppMetrics) GetPackfileURIOffloadsByRepo(repository string) int64

GetPackfileURIOffloadsByRepo returns the successful offload count for the given repository.

func (*MockAppMetrics) IncCacheEntryMissing added in v1.28.2

func (m *MockAppMetrics) IncCacheEntryMissing(repository string)

IncCacheEntryMissing increments the serve-time cache-miss counter for the given repository.

func (*MockAppMetrics) IncCacheEvictions added in v1.38.0

func (m *MockAppMetrics) IncCacheEvictions(reason string)

IncCacheEvictions increments the cache-evictions counter for the given reason.

func (*MockAppMetrics) IncCacheHits

func (m *MockAppMetrics) IncCacheHits(repository string)

IncCacheHits increments the cache hits counter for the given repository.

func (*MockAppMetrics) IncCacheMisses

func (m *MockAppMetrics) IncCacheMisses(repository string)

IncCacheMisses increments the cache misses counter for the given repository.

func (*MockAppMetrics) IncCacheRebuilds added in v1.43.0

func (m *MockAppMetrics) IncCacheRebuilds(repository string)

IncCacheRebuilds increments the object-storage rebuild counter for the given repository.

func (*MockAppMetrics) IncCoalescedRequests added in v1.25.0

func (m *MockAppMetrics) IncCoalescedRequests(repository string)

IncCoalescedRequests increments the coalesced requests counter for the given repository.

func (*MockAppMetrics) IncDryRunEvictions added in v1.41.0

func (m *MockAppMetrics) IncDryRunEvictions(reason string)

IncDryRunEvictions records a shadow-store eviction.

func (*MockAppMetrics) IncDryRunNonCacheable added in v1.41.0

func (m *MockAppMetrics) IncDryRunNonCacheable(repository, reason string)

IncDryRunNonCacheable records a dry-run non-cacheable request with a reason.

func (*MockAppMetrics) IncDryRunWouldCoalesce added in v1.41.0

func (m *MockAppMetrics) IncDryRunWouldCoalesce(repository string)

IncDryRunWouldCoalesce records a dry-run would-be coalesced request.

func (*MockAppMetrics) IncDryRunWouldHit added in v1.41.0

func (m *MockAppMetrics) IncDryRunWouldHit(repository string)

IncDryRunWouldHit records a dry-run would-be hit.

func (*MockAppMetrics) IncDryRunWouldMiss added in v1.41.0

func (m *MockAppMetrics) IncDryRunWouldMiss(repository string)

IncDryRunWouldMiss records a dry-run would-be miss.

func (*MockAppMetrics) IncErrors added in v1.25.0

func (m *MockAppMetrics) IncErrors(errorType string)

IncErrors increments the error counter for the given type.

func (*MockAppMetrics) IncNonCacheableRequests

func (m *MockAppMetrics) IncNonCacheableRequests(reason string)

IncNonCacheableRequests increments the non-cacheable requests counter.

func (*MockAppMetrics) IncPackfileURICacheHits added in v1.45.0

func (m *MockAppMetrics) IncPackfileURICacheHits(repository string)

IncPackfileURICacheHits records a packfile-uri hit for the given repository.

func (*MockAppMetrics) IncPackfileURICacheMisses added in v1.45.0

func (m *MockAppMetrics) IncPackfileURICacheMisses(repository string)

IncPackfileURICacheMisses records a packfile-uri miss for the given repository.

func (*MockAppMetrics) IncPackfileURIOffloadFailures added in v1.45.0

func (m *MockAppMetrics) IncPackfileURIOffloadFailures(repository string)

IncPackfileURIOffloadFailures records a failed pack offload for the given repository.

func (*MockAppMetrics) IncPackfileURIOffloads added in v1.45.0

func (m *MockAppMetrics) IncPackfileURIOffloads(repository string)

IncPackfileURIOffloads records a successful pack offload for the given repository.

func (*MockAppMetrics) ObserveDryRunWouldCacheBytes added in v1.46.0

func (m *MockAppMetrics) ObserveDryRunWouldCacheBytes(repository string, bytes float64)

ObserveDryRunWouldCacheBytes records the response size of a would-miss request.

func (*MockAppMetrics) ObserveFetchDuration added in v1.25.0

func (m *MockAppMetrics) ObserveFetchDuration(result string, seconds float64)

ObserveFetchDuration records a fetch duration observation by result.

func (*MockAppMetrics) ObservePackfileURIOffloadDuration added in v1.45.0

func (m *MockAppMetrics) ObservePackfileURIOffloadDuration(seconds float64)

ObservePackfileURIOffloadDuration records one offload duration observation.

func (*MockAppMetrics) Reset

func (m *MockAppMetrics) Reset()

Reset resets all counters to zero.

func (*MockAppMetrics) SubDryRunShadowSizeBytes added in v1.46.0

func (m *MockAppMetrics) SubDryRunShadowSizeBytes(repository string, bytes int64)

SubDryRunShadowSizeBytes decreases the shadow-store size gauge for the repository.

type NullAppMetrics

type NullAppMetrics struct{}

NullAppMetrics is a no-op implementation of the AppMetrics interface. It's used when metrics are not configured, eliminating the need for nil checks.

func NewNullAppMetrics

func NewNullAppMetrics() *NullAppMetrics

NewNullAppMetrics creates a new NullAppMetrics instance.

func (*NullAppMetrics) AddPackfileURIBytesServed added in v1.45.0

func (m *NullAppMetrics) AddPackfileURIBytesServed(repository string, bytes float64)

AddPackfileURIBytesServed is a no-op.

func (*NullAppMetrics) AddPackfileURIOffloadBytes added in v1.45.0

func (m *NullAppMetrics) AddPackfileURIOffloadBytes(repository string, bytes float64)

AddPackfileURIOffloadBytes is a no-op.

func (*NullAppMetrics) IncCacheEntryMissing added in v1.28.2

func (m *NullAppMetrics) IncCacheEntryMissing(repository string)

IncCacheEntryMissing is a no-op.

func (*NullAppMetrics) IncCacheEvictions added in v1.38.0

func (m *NullAppMetrics) IncCacheEvictions(reason string)

IncCacheEvictions is a no-op.

func (*NullAppMetrics) IncCacheHits

func (m *NullAppMetrics) IncCacheHits(repository string)

IncCacheHits is a no-op.

func (*NullAppMetrics) IncCacheMisses

func (m *NullAppMetrics) IncCacheMisses(repository string)

IncCacheMisses is a no-op.

func (*NullAppMetrics) IncCacheRebuilds added in v1.43.0

func (m *NullAppMetrics) IncCacheRebuilds(repository string)

IncCacheRebuilds is a no-op.

func (*NullAppMetrics) IncCoalescedRequests added in v1.25.0

func (m *NullAppMetrics) IncCoalescedRequests(repository string)

IncCoalescedRequests is a no-op.

func (*NullAppMetrics) IncDryRunEvictions added in v1.41.0

func (m *NullAppMetrics) IncDryRunEvictions(reason string)

IncDryRunEvictions is a no-op.

func (*NullAppMetrics) IncDryRunNonCacheable added in v1.41.0

func (m *NullAppMetrics) IncDryRunNonCacheable(repository, reason string)

IncDryRunNonCacheable is a no-op.

func (*NullAppMetrics) IncDryRunWouldCoalesce added in v1.41.0

func (m *NullAppMetrics) IncDryRunWouldCoalesce(repository string)

IncDryRunWouldCoalesce is a no-op.

func (*NullAppMetrics) IncDryRunWouldHit added in v1.41.0

func (m *NullAppMetrics) IncDryRunWouldHit(repository string)

IncDryRunWouldHit is a no-op.

func (*NullAppMetrics) IncDryRunWouldMiss added in v1.41.0

func (m *NullAppMetrics) IncDryRunWouldMiss(repository string)

IncDryRunWouldMiss is a no-op.

func (*NullAppMetrics) IncErrors added in v1.25.0

func (m *NullAppMetrics) IncErrors(errorType string)

IncErrors is a no-op.

func (*NullAppMetrics) IncNonCacheableRequests

func (m *NullAppMetrics) IncNonCacheableRequests(reason string)

IncNonCacheableRequests is a no-op.

func (*NullAppMetrics) IncPackfileURICacheHits added in v1.45.0

func (m *NullAppMetrics) IncPackfileURICacheHits(repository string)

IncPackfileURICacheHits is a no-op.

func (*NullAppMetrics) IncPackfileURICacheMisses added in v1.45.0

func (m *NullAppMetrics) IncPackfileURICacheMisses(repository string)

IncPackfileURICacheMisses is a no-op.

func (*NullAppMetrics) IncPackfileURIOffloadFailures added in v1.45.0

func (m *NullAppMetrics) IncPackfileURIOffloadFailures(repository string)

IncPackfileURIOffloadFailures is a no-op.

func (*NullAppMetrics) IncPackfileURIOffloads added in v1.45.0

func (m *NullAppMetrics) IncPackfileURIOffloads(repository string)

IncPackfileURIOffloads is a no-op.

func (*NullAppMetrics) ObserveFetchDuration added in v1.25.0

func (m *NullAppMetrics) ObserveFetchDuration(result string, seconds float64)

ObserveFetchDuration is a no-op.

func (*NullAppMetrics) ObservePackfileURIOffloadDuration added in v1.45.0

func (m *NullAppMetrics) ObservePackfileURIOffloadDuration(seconds float64)

ObservePackfileURIOffloadDuration is a no-op.

type PrometheusAppMetrics

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

PrometheusAppMetrics holds all Prometheus metrics for Packhorse. It registers metrics with a PrometheusManager's registry.

func NewPrometheusAppMetrics

func NewPrometheusAppMetrics(manager *PrometheusManager) *PrometheusAppMetrics

NewPrometheusAppMetrics creates and registers all Prometheus metrics with a PrometheusManager.

func (*PrometheusAppMetrics) AddDryRunShadowSizeBytes added in v1.46.0

func (m *PrometheusAppMetrics) AddDryRunShadowSizeBytes(repository string, bytes float64)

AddDryRunShadowSizeBytes increases the per-repository shadow-store size gauge by `bytes`, called from the middleware on every leader (would-miss) admission. Pairs with SubDryRunShadowSizeBytes on eviction.

func (*PrometheusAppMetrics) AddPackfileURIBytesServed added in v1.45.0

func (m *PrometheusAppMetrics) AddPackfileURIBytesServed(repository string, bytes float64)

AddPackfileURIBytesServed adds `bytes` to the pack bytes handed off as signed URLs.

func (*PrometheusAppMetrics) AddPackfileURIOffloadBytes added in v1.45.0

func (m *PrometheusAppMetrics) AddPackfileURIOffloadBytes(repository string, bytes float64)

AddPackfileURIOffloadBytes adds `bytes` to the pack bytes written to object storage on success.

func (*PrometheusAppMetrics) IncCacheEntryMissing added in v1.28.2

func (m *PrometheusAppMetrics) IncCacheEntryMissing(repository string)

IncCacheEntryMissing increments the serve-time cache-miss counter for the given repository.

func (*PrometheusAppMetrics) IncCacheEvictions added in v1.38.0

func (m *PrometheusAppMetrics) IncCacheEvictions(reason string)

IncCacheEvictions increments the cache-evictions counter for the given reason.

func (*PrometheusAppMetrics) IncCacheHits

func (m *PrometheusAppMetrics) IncCacheHits(repository string)

IncCacheHits increments the cache hits counter for the given repository.

func (*PrometheusAppMetrics) IncCacheMisses

func (m *PrometheusAppMetrics) IncCacheMisses(repository string)

IncCacheMisses increments the cache misses counter for the given repository.

func (*PrometheusAppMetrics) IncCacheRebuilds added in v1.43.0

func (m *PrometheusAppMetrics) IncCacheRebuilds(repository string)

IncCacheRebuilds increments the object-storage rebuild counter for the given repository.

func (*PrometheusAppMetrics) IncCoalescedRequests added in v1.25.0

func (m *PrometheusAppMetrics) IncCoalescedRequests(repository string)

IncCoalescedRequests increments the coalesced requests counter for the given repository.

func (*PrometheusAppMetrics) IncDryRunEvictions added in v1.41.0

func (m *PrometheusAppMetrics) IncDryRunEvictions(reason string)

IncDryRunEvictions records a shadow-store eviction.

func (*PrometheusAppMetrics) IncDryRunNonCacheable added in v1.41.0

func (m *PrometheusAppMetrics) IncDryRunNonCacheable(repository, reason string)

IncDryRunNonCacheable records a dry-run non-cacheable request with a reason.

func (*PrometheusAppMetrics) IncDryRunWouldCoalesce added in v1.41.0

func (m *PrometheusAppMetrics) IncDryRunWouldCoalesce(repository string)

IncDryRunWouldCoalesce records a dry-run would-be coalesced request.

func (*PrometheusAppMetrics) IncDryRunWouldHit added in v1.41.0

func (m *PrometheusAppMetrics) IncDryRunWouldHit(repository string)

IncDryRunWouldHit records a dry-run would-be cache hit for the repository.

func (*PrometheusAppMetrics) IncDryRunWouldMiss added in v1.41.0

func (m *PrometheusAppMetrics) IncDryRunWouldMiss(repository string)

IncDryRunWouldMiss records a dry-run would-be cache miss for the repository.

func (*PrometheusAppMetrics) IncErrors added in v1.25.0

func (m *PrometheusAppMetrics) IncErrors(errorType string)

IncErrors increments the error counter for the given type.

func (*PrometheusAppMetrics) IncNonCacheableRequests

func (m *PrometheusAppMetrics) IncNonCacheableRequests(reason string)

IncNonCacheableRequests increments the non-cacheable requests counter for the given reason.

func (*PrometheusAppMetrics) IncPackfileURICacheHits added in v1.45.0

func (m *PrometheusAppMetrics) IncPackfileURICacheHits(repository string)

IncPackfileURICacheHits records a request served as a packfile-uri.

func (*PrometheusAppMetrics) IncPackfileURICacheMisses added in v1.45.0

func (m *PrometheusAppMetrics) IncPackfileURICacheMisses(repository string)

IncPackfileURICacheMisses records a URI-capable request that couldn't be served as a packfile-uri.

func (*PrometheusAppMetrics) IncPackfileURIOffloadFailures added in v1.45.0

func (m *PrometheusAppMetrics) IncPackfileURIOffloadFailures(repository string)

IncPackfileURIOffloadFailures records a failed background pack upload.

func (*PrometheusAppMetrics) IncPackfileURIOffloads added in v1.45.0

func (m *PrometheusAppMetrics) IncPackfileURIOffloads(repository string)

IncPackfileURIOffloads records a successful background pack upload.

func (*PrometheusAppMetrics) ObserveDryRunWouldCacheBytes added in v1.46.0

func (m *PrometheusAppMetrics) ObserveDryRunWouldCacheBytes(repository string, bytes float64)

ObserveDryRunWouldCacheBytes records the response size of a would-miss request, i.e. the bytes that would have been admitted to the cache had caching been on.

func (*PrometheusAppMetrics) ObserveFetchDuration added in v1.25.0

func (m *PrometheusAppMetrics) ObserveFetchDuration(result string, seconds float64)

ObserveFetchDuration records the end-to-end duration of a cacheable fetch by result.

func (*PrometheusAppMetrics) ObservePackfileURIOffloadDuration added in v1.45.0

func (m *PrometheusAppMetrics) ObservePackfileURIOffloadDuration(seconds float64)

ObservePackfileURIOffloadDuration records the duration of one background pack upload.

func (*PrometheusAppMetrics) SubDryRunShadowSizeBytes added in v1.46.0

func (m *PrometheusAppMetrics) SubDryRunShadowSizeBytes(repository string, bytes int64)

SubDryRunShadowSizeBytes decreases the per-repository shadow-store size gauge by `bytes`, called from the shadow store's OnEvictSize callback so TTL and size-driven evictions remove their contribution symmetrically.

type PrometheusManager

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

PrometheusManager manages the Prometheus registry and metrics HTTP server. This is separate from metrics recording, allowing the server to always expose a /metrics endpoint regardless of which AppMetrics implementation is used.

func NewPrometheusManager

func NewPrometheusManager() *PrometheusManager

NewPrometheusManager creates a new PrometheusManager with a new registry. It registers the Go runtime and process collectors so the binary exposes baseline goroutine, memory, GC, file-descriptor, and CPU metrics for itself.

func NewPrometheusManagerWithRegistry

func NewPrometheusManagerWithRegistry(registry *prometheus.Registry) *PrometheusManager

NewPrometheusManagerWithRegistry creates a new PrometheusManager with a custom registry.

func (*PrometheusManager) Handler

func (m *PrometheusManager) Handler() http.Handler

Handler returns an HTTP handler for the /metrics endpoint.

func (*PrometheusManager) Registry

func (m *PrometheusManager) Registry() *prometheus.Registry

Registry returns the Prometheus registry.

func (*PrometheusManager) StartServer

func (m *PrometheusManager) StartServer(addr string)

StartServer starts the Prometheus metrics HTTP server. This is a blocking call and should typically be run in a goroutine.

Jump to

Keyboard shortcuts

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