promutil

package
v0.0.0-...-bcc2220 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetGlobalMetricRegistry

func GetGlobalMetricRegistry() prometheus.Registerer

GetGlobalMetricRegistry returns the global metric registry where auto-registering metrics are registered. The register to it should be only be done by its derived factories from NewFactory4Master, ... And the returned registry can be only used for unregister.

func HTTPHandlerForMetric

func HTTPHandlerForMetric() http.Handler

HTTPHandlerForMetric return http.Handler for prometheus metric

func HTTPHandlerForMetricImpl

func HTTPHandlerForMetricImpl(gather prometheus.Gatherer) http.Handler

HTTPHandlerForMetricImpl return http.Handler for prometheus metric

func NewOnlyRegRegister

func NewOnlyRegRegister(r prometheus.Registerer) prometheus.Registerer

NewOnlyRegRegister creates an RegOnlyRegister.

func NewOnlyUnregRegister

func NewOnlyUnregRegister(r prometheus.Registerer) prometheus.Registerer

NewOnlyUnregRegister creates an UnregOnlyRegister.

func UnregisterWorkerMetrics

func UnregisterWorkerMetrics(workerID frameModel.WorkerID)

UnregisterWorkerMetrics unregisters all metrics of workerID IF 'worker' is a job master, use job id as workerID IF 'worker' is a worker, use worker id as workerID

Types

type AutoRegisterFactory

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

AutoRegisterFactory uses inner Factory to create metrics and register metrics to Registry with id. Panic if it can't register successfully.

func (*AutoRegisterFactory) NewCounter

NewCounter implements Factory.NewCounter.

func (*AutoRegisterFactory) NewCounterVec

func (f *AutoRegisterFactory) NewCounterVec(opts prometheus.CounterOpts, labelNames []string) *prometheus.CounterVec

NewCounterVec implements Factory.NewCounterVec.

func (*AutoRegisterFactory) NewGauge

NewGauge implements Factory.NewGauge.

func (*AutoRegisterFactory) NewGaugeVec

func (f *AutoRegisterFactory) NewGaugeVec(opts prometheus.GaugeOpts, labelNames []string) *prometheus.GaugeVec

NewGaugeVec implements Factory.NewGaugeVec.

func (*AutoRegisterFactory) NewHistogram

NewHistogram implements Factory.NewHistogram.

func (*AutoRegisterFactory) NewHistogramVec

func (f *AutoRegisterFactory) NewHistogramVec(opts prometheus.HistogramOpts, labelNames []string) *prometheus.HistogramVec

NewHistogramVec implements Factory.NewHistogramVec.

type Factory

type Factory interface {
	// NewCounter works like the function of the same name in the prometheus
	// package.
	NewCounter(opts prometheus.CounterOpts) prometheus.Counter

	// NewCounterVec works like the function of the same name in the
	// prometheus package.
	NewCounterVec(opts prometheus.CounterOpts, labelNames []string) *prometheus.CounterVec

	// NewGauge works like the function of the same name in the prometheus
	// package.
	NewGauge(opts prometheus.GaugeOpts) prometheus.Gauge

	// NewGaugeVec works like the function of the same name in the prometheus
	// package.
	NewGaugeVec(opts prometheus.GaugeOpts, labelNames []string) *prometheus.GaugeVec

	// NewHistogram works like the function of the same name in the prometheus
	// package.
	NewHistogram(opts prometheus.HistogramOpts) prometheus.Histogram

	// NewHistogramVec works like the function of the same name in the
	// prometheus package.
	NewHistogramVec(opts prometheus.HistogramOpts, labelNames []string) *prometheus.HistogramVec
}

Factory is the interface to create some native prometheus metric

func NewAutoRegisterFactory

func NewAutoRegisterFactory(f Factory, r *Registry, id frameModel.WorkerID) Factory

NewAutoRegisterFactory creates an AutoRegisterFactory.

func NewFactory4Framework

func NewFactory4Framework() Factory

NewFactory4Framework return a Factory for dataflow framework NOTICE: we use auto service label tagged by cloud service to distinguish different dataflow engine or different executor

func NewFactory4FrameworkImpl

func NewFactory4FrameworkImpl(reg *Registry) Factory

NewFactory4FrameworkImpl return a Factory for dataflow framework

func NewFactory4Master

func NewFactory4Master(info tenant.ProjectInfo, jobType engineModel.JobType, jobID engineModel.JobID) Factory

NewFactory4Master return a Factory for jobmaster

func NewFactory4MasterImpl

func NewFactory4MasterImpl(reg *Registry, info tenant.ProjectInfo, prefix string, jobID engineModel.JobID) Factory

NewFactory4MasterImpl return a Factory for jobmaster

func NewFactory4Test

func NewFactory4Test(testKey string) Factory

NewFactory4Test return a Factory for test NOTICE: we use testing.T.TempDir() to distinguish different test

func NewFactory4TestImpl

func NewFactory4TestImpl(reg *Registry, testID string) Factory

NewFactory4TestImpl return a Factory for test

func NewFactory4Worker

func NewFactory4Worker(info tenant.ProjectInfo, jobType engineModel.JobType, jobID engineModel.JobID,
	workerID frameModel.WorkerID,
) Factory

NewFactory4Worker return a Factory for worker

func NewFactory4WorkerImpl

func NewFactory4WorkerImpl(reg *Registry, info tenant.ProjectInfo, prefix string, jobID engineModel.JobID,
	workerID frameModel.WorkerID,
) Factory

NewFactory4WorkerImpl return a Factory for worker

func NewPromFactory

func NewPromFactory() Factory

NewPromFactory creates PromFactory.

func NewWrappingFactory

func NewWrappingFactory(f Factory, prefix string, labels prometheus.Labels) Factory

NewWrappingFactory creates a WrappingFactory. if `prefix` is not empty, it is added to the metric name to avoid cross app metric conflict, e.g. $prefix_$namespace_$subsystem_$name. `labels` is added to user metric when create metrics.

type PromFactory

type PromFactory struct{}

PromFactory implements Factory by calling prometheus.NewXXX.

func (*PromFactory) NewCounter

func (f *PromFactory) NewCounter(opts prometheus.CounterOpts) prometheus.Counter

NewCounter implements Factory.NewCounter.

func (*PromFactory) NewCounterVec

func (f *PromFactory) NewCounterVec(opts prometheus.CounterOpts, labelNames []string) *prometheus.CounterVec

NewCounterVec implements Factory.NewCounterVec.

func (*PromFactory) NewGauge

func (f *PromFactory) NewGauge(opts prometheus.GaugeOpts) prometheus.Gauge

NewGauge implements Factory.NewGauge.

func (*PromFactory) NewGaugeVec

func (f *PromFactory) NewGaugeVec(opts prometheus.GaugeOpts, labelNames []string) *prometheus.GaugeVec

NewGaugeVec implements Factory.NewGaugeVec.

func (*PromFactory) NewHistogram

NewHistogram implements Factory.NewHistogram.

func (*PromFactory) NewHistogramVec

func (f *PromFactory) NewHistogramVec(opts prometheus.HistogramOpts, labelNames []string) *prometheus.HistogramVec

NewHistogramVec implements Factory.NewHistogramVec.

type RegOnlyRegister

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

RegOnlyRegister can Register collectors but can't Unregister. It's only used in tests.

func (RegOnlyRegister) MustRegister

func (o RegOnlyRegister) MustRegister(collector ...prometheus.Collector)

MustRegister implements prometheus.Registerer.

func (RegOnlyRegister) Register

func (o RegOnlyRegister) Register(collector prometheus.Collector) error

Register implements prometheus.Registerer.

func (RegOnlyRegister) Unregister

func (o RegOnlyRegister) Unregister(collector prometheus.Collector) bool

Unregister implements prometheus.Registerer.

type Registry

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

Registry is used for registering metric

func NewRegistry

func NewRegistry() *Registry

NewRegistry return a new Registry

func (*Registry) Gather

func (r *Registry) Gather() ([]*dto.MetricFamily, error)

Gather implements Gatherer interface

func (*Registry) MustRegister

func (r *Registry) MustRegister(workerID frameModel.WorkerID, c prometheus.Collector)

MustRegister registers the provided Collector of the specified worker

func (*Registry) Unregister

func (r *Registry) Unregister(workerID frameModel.WorkerID)

Unregister unregisters all Collectors of the specified worker

type UnregOnlyRegister

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

UnregOnlyRegister can Unregister collectors but can't Register. It's used to protect the global registry.

func (UnregOnlyRegister) MustRegister

func (o UnregOnlyRegister) MustRegister(collector ...prometheus.Collector)

MustRegister implements prometheus.Registerer.

func (UnregOnlyRegister) Register

func (o UnregOnlyRegister) Register(collector prometheus.Collector) error

Register implements prometheus.Registerer.

func (UnregOnlyRegister) Unregister

func (o UnregOnlyRegister) Unregister(collector prometheus.Collector) bool

Unregister implements prometheus.Registerer.

type WrappingFactory

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

WrappingFactory uses inner Factory to create metrics and attaches some information to the metrics it created. The usage is dataflow engine can wrap prefix and labels for DM, and DM can wrap labels for dumpling/lightning.

func (*WrappingFactory) NewCounter

NewCounter works like the function of the same name in the prometheus package except for it will wrap prefix and constLabels. Thread-safe.

func (*WrappingFactory) NewCounterVec

func (f *WrappingFactory) NewCounterVec(opts prometheus.CounterOpts, labelNames []string) *prometheus.CounterVec

NewCounterVec works like the function of the same name in the prometheus package except for it will wrap prefix and constLabels. Thread-safe.

func (*WrappingFactory) NewGauge

NewGauge works like the function of the same name in the prometheus package except for it will wrap prefix and constLabels. Thread-safe.

func (*WrappingFactory) NewGaugeVec

func (f *WrappingFactory) NewGaugeVec(opts prometheus.GaugeOpts, labelNames []string) *prometheus.GaugeVec

NewGaugeVec works like the function of the same name in the prometheus package except for it will wrap prefix and constLabels. Thread-safe.

func (*WrappingFactory) NewHistogram

NewHistogram works like the function of the same name in the prometheus package except for it will wrap prefix and constLabels. Thread-safe.

func (*WrappingFactory) NewHistogramVec

func (f *WrappingFactory) NewHistogramVec(opts prometheus.HistogramOpts, labelNames []string) *prometheus.HistogramVec

NewHistogramVec works like the function of the same name in the prometheus package except for it will wrap prefix and constLabels. Thread-safe.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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