metric

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2025 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Method string = "method"
	Status string = "status"
	Path   string = "path"
)

List of metric labels

View Source
const (
	Unary        grpcType = "unary"
	ClientStream grpcType = "client_stream"
	ServerStream grpcType = "server_stream"
	BidiStream   grpcType = "bidi_stream"
)

Variables

This section is empty.

Functions

func NewPrometheusMetrics

func NewPrometheusMetrics(config *MetricsConfig) (*prometheusMetrics, error)

func NewTmpPrometheusMetrics

func NewTmpPrometheusMetrics() *prometheusMetrics

func SetMetric

func SetMetric(metric Metrics)

Types

type Metric

type Metric struct {
	Name        string
	Type        MetricType
	Subsystem   Subsystem
	Description string
	Labels      []string
	Buckets     []float64
}
var Grpc_server_handled_total *Metric = &Metric{
	Name:        "server_handled_total",
	Description: "Total number of RPCs completed on the server, regardless of success or failure.",
	Subsystem:   GRPC,
	Type:        Counter,
	Labels:      []string{"grpc_type", "grpc_service", "grpc_method", Status},
}

grpc_server_handled_total is a counter metric that measures the total number of requests.

var Grpc_server_handling_seconds *Metric = &Metric{
	Name:        "server_handling_seconds",
	Description: "Histogram metric that measures the duration of the request in seconds.",
	Subsystem:   GRPC,
	Type:        Histogram,
	Labels:      []string{"grpc_type", "grpc_service", "grpc_method"},
	Buckets:     []float64{.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10},
}

grpc_server_handling_seconds is a histogram metric that measures the duration of the request in seconds.

var Grpc_server_msg_received_total *Metric = &Metric{
	Name:        "server_msg_received_total",
	Description: "Total number of RPC stream messages received on the server.",
	Subsystem:   GRPC,
	Type:        Counter,
	Labels:      []string{"grpc_type", "grpc_service", "grpc_method"},
}

grpc_server_msg_received_total is a counter metric that measures the total number of RPC stream messages received on the server.

var Grpc_server_msg_sent_total *Metric = &Metric{
	Name:        "server_msg_sent_total",
	Description: "Total number of gRPC stream messages sent by the server.",
	Subsystem:   GRPC,
	Type:        Counter,
	Labels:      []string{"grpc_type", "grpc_service", "grpc_method"},
}

grpc_server_msg_sent_total is a counter metric that measures the total number of gRPC stream messages sent by the server.

var Grpc_server_started_total *Metric = &Metric{
	Name:        "server_started_total",
	Description: "Total number of RPCs started on the server.",
	Subsystem:   GRPC,
	Type:        Counter,
	Labels:      []string{"grpc_type", "grpc_service", "grpc_method"},
}

grpc_server_started_total is a gauge metric that measures the number of requests currently in progress.

var Http_request_duration_seconds *Metric = &Metric{
	Name:        "request_duration_seconds",
	Subsystem:   HTTP,
	Description: "Histogram metric that measures the duration of the request in seconds.",
	Type:        Histogram,
	Labels:      []string{Path},
	Buckets:     []float64{.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10},
}

http_request_duration_seconds is a histogram metric that measures the duration of the request in seconds.

var Http_request_inflight *Metric = &Metric{
	Name:        "request_inflight",
	Description: "Gauge metric that measures the number of requests currently in progress.",
	Subsystem:   HTTP,
	Type:        Gauge,
	Labels:      []string{Path},
}

http_request_inflight is a gauge metric that measures the number of requests currently in progress.

var Http_request_size_bytes *Metric = &Metric{
	Name:        "request_size_bytes",
	Description: "Histogram metric that measures the size of the request in bytes.",
	Subsystem:   HTTP,
	Type:        Histogram,
	Labels:      []string{Path},
	Buckets:     sizeBuckets,
}

http_request_size_bytes is a histogram metric that measures the size of the request in bytes.

var Http_request_total *Metric = &Metric{
	Name:        "request_total",
	Description: "Counter metric that measures the total number of requests.",
	Subsystem:   HTTP,
	Type:        Counter,
	Labels:      []string{Path, Status},
}

http_request_total is a counter metric that measures the total number of requests.

var Http_response_size_bytes *Metric = &Metric{
	Name:        "response_size_bytes",
	Description: "Histogram metric that measures the size of the response in bytes.",
	Subsystem:   HTTP,
	Type:        Histogram,
	Labels:      []string{Path},
	Buckets:     sizeBuckets,
}

http_response_size_bytes is a histogram metric that measures the size of the response in bytes.

type MetricType

type MetricType string
const (
	Counter   MetricType = "COUNTER"
	Gauge     MetricType = "GAUGE"
	Histogram MetricType = "HISTOGRAM"
)

type Metrics

type Metrics interface {
	RunHTTPMetricsServer(ctx context.Context, address string)
	Counter(metric *Metric, value float64, labelValues ...string) error
	AddGauge(metric *Metric, value float64, labelValues ...string) error
	SetGauge(metric *Metric, value float64, labelValues ...string) error
	Histogram(metric *Metric, value float64, labelValues ...string) error
	IsMetricExist(name string) bool
}

func GetMetric

func GetMetric() Metrics

func MetricFactory

func MetricFactory(opts ...Option) (Metrics, error)

type MetricsConfig

type MetricsConfig struct {
	Provider                  Provider
	Metrics                   []*Metric
	PrometheusNativeHistogram bool
}

TracerConfig is the configuration for the tracer

type Option

type Option func(f *MetricsConfig)

func WithMetrics

func WithMetrics(metrics ...*Metric) Option

func WithPrometheusNativeHistogram

func WithPrometheusNativeHistogram(prometheusNativeHistogram bool) Option

func WithProvider

func WithProvider(provider Provider) Option

type Provider

type Provider string
const (
	Datadog    Provider = "DATADOG"
	Prometheus Provider = "PROMETHEUS"
)

type Subsystem

type Subsystem string
const (
	HTTP Subsystem = "http"
	GRPC Subsystem = "grpc"
)

Jump to

Keyboard shortcuts

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