Documentation
¶
Index ¶
- func BandwidthMbpsBuckets() []float64
- func ByteBuckets() []float64
- func CacheSource(ctx context.Context) (string, bool)
- func ContinueArtifactRequest(ctx, request context.Context) context.Context
- func FastLatencyBuckets() []float64
- func HasArtifactRequest(ctx context.Context) bool
- func LatencyBuckets() []float64
- func NewHistogram(meter metric.Meter, path, unit, description string, buckets []float64) metric.Float64Histogram
- func NewMetric[OM any](meter metric.Meter, path, unit, description string) OM
- func ObserveCacheSource(ctx context.Context, backend string)
- func RecordCacheFill(ctx context.Context, result string)
- func RecordCacheWrite(ctx context.Context, backend string, tier int, result string)
- func SmallCountBuckets() []float64
- func WithCachePurpose(ctx context.Context, purpose string) context.Context
- func WithoutArtifactRequest(ctx context.Context) context.Context
- type ArtifactMetrics
- type Client
- type Config
- type OriginTransport
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BandwidthMbpsBuckets ¶
func BandwidthMbpsBuckets() []float64
BandwidthMbpsBuckets is for per-request throughput in MiB/s, covering everything from slow long-tail clients (a few MiB/s) up through saturated 10 GbE workstations (~1.2 GiB/s) and into the ~12 GiB/s range of 100 Gbps server NICs. Top bucket leaves headroom past the theoretical max so we can spot misattribution.
func ByteBuckets ¶
func ByteBuckets() []float64
ByteBuckets covers cachew payload sizes, which range from tiny bundles (a few KiB) to multi-GiB snapshot tarballs.
func CacheSource ¶ added in v0.8.0
CacheSource returns the backend reported by ObserveCacheSource, if any.
func ContinueArtifactRequest ¶ added in v0.8.0
ContinueArtifactRequest retains metric attribution without inheriting a request's cancellation.
func FastLatencyBuckets ¶
func FastLatencyBuckets() []float64
FastLatencyBuckets is for operations expected to complete in well under a minute (spool follower waits, ensure-refs round trips).
func HasArtifactRequest ¶ added in v0.8.0
HasArtifactRequest avoids allocating observation wrappers for unrelated cache operations.
func LatencyBuckets ¶
func LatencyBuckets() []float64
LatencyBuckets covers operations that span sub-millisecond cache hits all the way to multi-minute clone/repack/generation work. The default OTel histogram boundaries (0..10 seconds) compress everything beyond 10s into the +Inf bucket, which makes p50/p90/avg unusable for cachew's git path.
func NewHistogram ¶
func NewHistogram(meter metric.Meter, path, unit, description string, buckets []float64) metric.Float64Histogram
NewHistogram creates a Float64Histogram with explicit bucket boundaries. Prefer this over NewMetric for histograms: the OTel SDK default boundaries only go up to 10 seconds, which is far too narrow for most cachew metrics.
func ObserveCacheSource ¶ added in v0.8.0
ObserveCacheSource reports the backend that answered, after stale and conditional probes are resolved.
func RecordCacheFill ¶ added in v0.8.0
RecordCacheFill records completion rather than assuming an origin 200 was cached.
func RecordCacheWrite ¶ added in v0.8.0
RecordCacheWrite records a terminal outcome for one backend writer.
func SmallCountBuckets ¶
func SmallCountBuckets() []float64
SmallCountBuckets is for low-cardinality integer counts (e.g. number of pack files on a mirror), where the values of interest are mostly in the 1–100 range with a long tail.
func WithCachePurpose ¶ added in v0.8.0
WithCachePurpose distinguishes origin fills from background cache replication.
Types ¶
type ArtifactMetrics ¶ added in v0.8.0
type ArtifactMetrics struct {
// contains filtered or unexported fields
}
ArtifactMetrics separates origin exchanges from cache publication.
func NewArtifactMetrics ¶ added in v0.8.0
func NewArtifactMetrics() *ArtifactMetrics
NewArtifactMetrics uses the same provider as the server's HTTP metrics.
func (*ArtifactMetrics) WithRequest ¶ added in v0.8.0
func (m *ArtifactMetrics) WithRequest(ctx context.Context, strategy, registry string, external bool) context.Context
WithRequest scopes observations to a configured strategy and registry, never an artifact URL.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides OpenTelemetry metrics with configurable exporters.
type Config ¶
type Config struct {
ServiceName string `hcl:"service-name" help:"Service name for metrics." default:"cachew"`
Port int `hcl:"port" help:"Port for Prometheus metrics server." default:"9102"`
EnablePrometheus bool `hcl:"enable-prometheus" help:"Enable Prometheus exporter." default:"true"`
EnableOTLP bool `hcl:"enable-otlp" help:"Enable OTLP exporter." default:"false"`
OTLPEndpoint string `hcl:"otlp-endpoint" help:"OTLP endpoint URL." default:"http://localhost:4318"`
OTLPInsecure bool `hcl:"otlp-insecure" help:"Use insecure connection for OTLP." default:"false"`
OTLPExportInterval int `hcl:"otlp-export-interval" help:"OTLP export interval in seconds." default:"60"`
}
Config holds metrics configuration.
type OriginTransport ¶ added in v0.8.0
type OriginTransport struct {
// contains filtered or unexported fields
}
OriginTransport measures the exchanges of artifact requests that reach base. It must sit below any transport that answers without contacting the origin, such as upstream cooldowns, so that those answers are not counted.
func NewOriginTransport ¶ added in v0.8.0
func NewOriginTransport(base http.RoundTripper) *OriginTransport
NewOriginTransport measures exchanges sent to base.
func (*OriginTransport) CloseIdleConnections ¶ added in v0.8.0
func (t *OriginTransport) CloseIdleConnections()
CloseIdleConnections forwards to base, so http.Client.CloseIdleConnections still works.