prometheus

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: Apache-2.0, BSD-3-Clause, MIT Imports: 31 Imported by: 0

Documentation

Overview

Package prometheus metrics

Index

Constants

This section is empty.

Variables

View Source
var WithNoSink metrics.Option = func(opts *metrics.Options) {}

WithNoSink option to skip reporting to this sink

Functions

func ClientFilter

func ClientFilter(options ...ClientFilterOption) filter.ClientFilter

ClientFilter with prometheus metric

func IncrSDKPanicTotal

func IncrSDKPanicTotal()

IncrSDKPanicTotal report sdk panic

func MonitorTRPCSDKMeta

func MonitorTRPCSDKMeta()

MonitorTRPCSDKMeta monitor trpc sdk meta

func ObserveExportLogsBytes

func ObserveExportLogsBytes(s int)

ObserveExportLogsBytes observe log bytes

func ObserveExportSpansBytes

func ObserveExportSpansBytes(s int)

ObserveExportSpansBytes observe span bytes

func ObserveRequestBodyBytes

func ObserveRequestBodyBytes(s int)

ObserveRequestBodyBytes observe request body bytes

func ObserveRequestMetaDataBytes

func ObserveRequestMetaDataBytes(s int)

ObserveRequestMetaDataBytes observe request metadata bytes

func ServerFilter

func ServerFilter(options ...ServerFilterOption) filter.ServerFilter

ServerFilter with prometheus metric

func Setup

func Setup(tenantID string, etcdEndpoints []string, opts ...metric.SetupOption)

Setup .

func StreamClientFilter

func StreamClientFilter() client.StreamFilter

StreamClientFilter is a client-side filter that instruments the client side stream rpc metrics

func StreamServerFilter

func StreamServerFilter() server.StreamFilter

StreamServerFilter is a server side stream filter that instruments the server side stream rpc metrics

Types

type ClientFilterOption

type ClientFilterOption func(opt *clientFilterOption)

ClientFilterOption defines the configuration for the various elements of BatchProcessor

func WithClientFilterTraceConfig

func WithClientFilterTraceConfig(enableDeferredSample, deferredSampleError bool,
	deferredSampleSlowDuration time.Duration) ClientFilterOption

WithClientFilterTraceConfig return Option which apply changes to trace configuration

type ServerFilterOption

type ServerFilterOption func(opt *serverFilterOption)

ServerFilterOption defines the configuration for the various elements of BatchProcessor

func WithServerFilterTraceConfig

func WithServerFilterTraceConfig(enableDeferredSample, deferredSampleError bool,
	deferredSampleSlowDuration time.Duration) ServerFilterOption

WithServerFilterTraceConfig return Option which apply changes to trace configuration

type Sink

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

Sink implements metrics.Sink interface, convert trpc metrics API to Prometheus format. convert rules is different from trpc-metrics-prometheus plugin: trpc metric name => save original name in `_name` label, name use converted pinyin name trpc metric type => prometheus `_type` label 2021-09-10 update: as too many trpc metrics name is too long, use pinyin name to replace original name will make prometheus metadata api useless. Change into use same metric name for each type, use label to distinguish. 2021-11-29 update: for multi-dimension metrics, generate a collector for each metric, each collector has its own dimension information to prevent dimension explosion. Add counters and gauges fields to store multi-dimension counter and gauge 2023-03-28 update: the style of trpc metrics api multi-dimension metrics is multi-value, Prometheus is single-value. when mapping to Prometheus, use record.metric[*].name as metric name, not unique. Therefor, use record.name + record.metric[*].name as metric name, but it will break the panel. report case 1: metrics.ReportMultiDimensionMetricsX(

    record_name1,  // record.name
    []*metrics.Dimension{ {Name: "dim_1", Value: "val_11"} }, // labels values
    []*metrics.Metrics{
				metrics.NewMetrics("metric_name1", 1, metrics.PolicySUM), // record.metric[*].name
		},
	)

report case 2: metrics.ReportMultiDimensionMetricsX(

    record_name2,  // record.name
    []*metrics.Dimension{ {Name: "dim_1", Value: "val_11"}, {Name: "dim_2", Value: "val_11"} }, // labels values
    []*metrics.Metrics{
				metrics.NewMetrics("metric_name1", 1, metrics.PolicySUM), // record.metric[*].name
		},
	)

The correct way is to use record.name + record.metric[*].name as the Prometheus metric name, but it will change the metric name and break the panel. So use a compatible way to map without modifying the panel statement: 1. Add a label _name=record.name + record.metric[*].name. report case 1 mapping to metric_name1{_name="record_name1_metric_name1", dim_1="val_11"} report case 2 mapping to metric_name1{_name="record_name2_metric_name1", dim_1="val_11", dim_2="val_11"} 2. Implement a special composeMetricVec type, wrap the collectorVec with these two labels inconsistent. When Prometheus stores metrics, label value is empty and there is no label are equivalent.

func NewSink

func NewSink(registerer prometheus.Registerer) *Sink

NewSink create a new Sink

func (*Sink) Name

func (*Sink) Name() string

Name implements metrics.Sink.

func (*Sink) Report

func (s *Sink) Report(rec metrics.Record, opts ...metrics.Option) error

Report implements metrics.Sink, which will be called synchronously on each metrics operation.

Jump to

Keyboard shortcuts

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