github.com/matrixorigin/matrixone@v1.2.0/pkg/util/metric/v2/trace.go (about) 1 // Copyright 2023 Matrix Origin 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 v2 16 17 import "github.com/prometheus/client_golang/prometheus" 18 19 // trace.go observe motrace, mometric those packages' behavior 20 21 var ( 22 traceCollectorDurationHistogram = prometheus.NewHistogramVec( 23 prometheus.HistogramOpts{ 24 Namespace: "mo", 25 Subsystem: "trace", 26 Name: "collector_duration_seconds", 27 Help: "Bucketed histogram of trace collector duration.", 28 Buckets: prometheus.ExponentialBuckets(0.0001, 2.0, 20), 29 }, []string{"type"}) 30 TraceCollectorCollectDurationHistogram = traceCollectorDurationHistogram.WithLabelValues("collect") 31 TraceCollectorGenerateAwareDurationHistogram = traceCollectorDurationHistogram.WithLabelValues("generate_awake") 32 TraceCollectorGenerateAwareDiscardDurationHistogram = traceCollectorDurationHistogram.WithLabelValues("generate_awake_discard") 33 TraceCollectorGenerateDelayDurationHistogram = traceCollectorDurationHistogram.WithLabelValues("generate_delay") 34 TraceCollectorGenerateDurationHistogram = traceCollectorDurationHistogram.WithLabelValues("generate") 35 TraceCollectorGenerateDiscardDurationHistogram = traceCollectorDurationHistogram.WithLabelValues("generate_discard") 36 TraceCollectorExportDurationHistogram = traceCollectorDurationHistogram.WithLabelValues("export") 37 38 traceNegativeCUCounter = prometheus.NewCounterVec( 39 prometheus.CounterOpts{ 40 Namespace: "mo", 41 Subsystem: "trace", 42 Name: "negative_cu_total", 43 Help: "Count of negative cu to backend", 44 }, []string{"type"}) 45 ) 46 47 func GetTraceNegativeCUCounter(typ string) prometheus.Counter { 48 return traceNegativeCUCounter.WithLabelValues(typ) 49 }