github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/engine/pkg/promutil/plain.go (about)

     1  // Copyright 2022 PingCAP, Inc.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package promutil
    16  
    17  import (
    18  	"github.com/prometheus/client_golang/prometheus"
    19  )
    20  
    21  // PromFactory implements Factory by calling prometheus.NewXXX.
    22  type PromFactory struct{}
    23  
    24  // NewPromFactory creates PromFactory.
    25  func NewPromFactory() Factory {
    26  	return &PromFactory{}
    27  }
    28  
    29  // NewCounter implements Factory.NewCounter.
    30  func (f *PromFactory) NewCounter(opts prometheus.CounterOpts) prometheus.Counter {
    31  	return prometheus.NewCounter(opts)
    32  }
    33  
    34  // NewCounterVec implements Factory.NewCounterVec.
    35  func (f *PromFactory) NewCounterVec(opts prometheus.CounterOpts, labelNames []string) *prometheus.CounterVec {
    36  	return prometheus.NewCounterVec(opts, labelNames)
    37  }
    38  
    39  // NewGauge implements Factory.NewGauge.
    40  func (f *PromFactory) NewGauge(opts prometheus.GaugeOpts) prometheus.Gauge {
    41  	return prometheus.NewGauge(opts)
    42  }
    43  
    44  // NewGaugeVec implements Factory.NewGaugeVec.
    45  func (f *PromFactory) NewGaugeVec(opts prometheus.GaugeOpts, labelNames []string) *prometheus.GaugeVec {
    46  	return prometheus.NewGaugeVec(opts, labelNames)
    47  }
    48  
    49  // NewHistogram implements Factory.NewHistogram.
    50  func (f *PromFactory) NewHistogram(opts prometheus.HistogramOpts) prometheus.Histogram {
    51  	return prometheus.NewHistogram(opts)
    52  }
    53  
    54  // NewHistogramVec implements Factory.NewHistogramVec.
    55  func (f *PromFactory) NewHistogramVec(opts prometheus.HistogramOpts, labelNames []string) *prometheus.HistogramVec {
    56  	return prometheus.NewHistogramVec(opts, labelNames)
    57  }