httpmetrics

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2025 License: Apache-2.0 Imports: 34 Imported by: 9

Documentation

Overview

Copyright 2024 Chainguard, Inc. SPDX-License-Identifier: Apache-2.0

Copyright 2024 Chainguard, Inc. SPDX-License-Identifier: Apache-2.0

Index

Constants

View Source
const (
	DiskUsageScrapeInterval    = 5 * time.Second
	DiskUsageScrapeIntervalEnv = "DISK_USAGE_SCRAPE_INTERVAL"
)
View Source
const (
	CeTypeHeader          string = "ce-type"
	GoogClientTraceHeader string = "googclient_traceparent"
	OriginalTraceHeader   string = "original-traceparent"
)

Variables

Transport is an http.RoundTripper that records metrics for each request.

Functions

func ExtractInnerTransport added in v0.5.156

func ExtractInnerTransport(rt http.RoundTripper) http.RoundTripper

func Handler

func Handler(name string, handler http.Handler) http.Handler

Handler wraps a given http handler in standard metrics handlers.

func HandlerFunc

func HandlerFunc(name string, f func(http.ResponseWriter, *http.Request)) http.HandlerFunc

Handler wraps a given http handler func in standard metrics handlers.

func NewIDTokenClient added in v0.5.156

func NewIDTokenClient(ctx context.Context, audience string, opts ...idtoken.ClientOption) (*http.Client, error)

NewIDTokenClient creates a new http.Client based on idtoken.Client, with metrics.

func ScrapeDiskUsage added in v0.5.156

func ScrapeDiskUsage(ctx context.Context)

func ServeMetrics

func ServeMetrics()

ServeMetrics serves the metrics endpoint if the METRICS_PORT env var is set.

func SetBucketSuffixes

func SetBucketSuffixes(bs map[string]string)

func SetBuckets

func SetBuckets(b map[string]string)

func SetupTracer

func SetupTracer(ctx context.Context) func()

Fractions >= 1 will always sample. Fractions < 0 are treated as zero. To respect the parent trace's `SampledFlag`, the `TraceIDRatioBased` sampler should be used as a delegate of a `Parent` sampler.

Expected usage:

defer metrics.SetupTracer(ctx)()

func WrapTransport

func WrapTransport(t http.RoundTripper, opts ...TransportOption) http.RoundTripper

WrapTransport wraps an http.RoundTripper with instrumentation.

Types

type MetricsTransport added in v0.5.156

type MetricsTransport struct {
	http.RoundTripper
	// contains filtered or unexported fields
}

type TransportOption added in v0.6.168

type TransportOption func(*metricsTransportOptions)

func WithSkipBucketize added in v0.6.168

func WithSkipBucketize(skip bool) TransportOption

WithSkipBucketize is a TransportOption that skips the bucketization of the host. This is useful for transports that talk to an unbounded number of hosts, where bucketization would cause excessive metric cardinality. If true, the host label will be set to "unbucketized".

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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