github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/jobs/metrics.go (about)

     1  // Copyright 2018 The Cockroach Authors.
     2  //
     3  // Use of this software is governed by the Business Source License
     4  // included in the file licenses/BSL.txt.
     5  //
     6  // As of the Change Date specified in that file, in accordance with
     7  // the Business Source License, use of this software will be governed
     8  // by the Apache License, Version 2.0, included in the file
     9  // licenses/APL.txt.
    10  
    11  package jobs
    12  
    13  import (
    14  	"time"
    15  
    16  	"github.com/cockroachdb/cockroach/pkg/util/metric"
    17  )
    18  
    19  // Metrics are for production monitoring of each job type.
    20  type Metrics struct {
    21  	Changefeed metric.Struct
    22  }
    23  
    24  // MetricStruct implements the metric.Struct interface.
    25  func (Metrics) MetricStruct() {}
    26  
    27  // InitHooks initializes the metrics for job monitoring.
    28  func (m *Metrics) InitHooks(histogramWindowInterval time.Duration) {
    29  	if MakeChangefeedMetricsHook != nil {
    30  		m.Changefeed = MakeChangefeedMetricsHook(histogramWindowInterval)
    31  	}
    32  }
    33  
    34  // MakeChangefeedMetricsHook allows for registration of changefeed metrics from
    35  // ccl code.
    36  var MakeChangefeedMetricsHook func(time.Duration) metric.Struct