dubbo.apache.org/dubbo-go/v3@v3.1.1/metrics/reporter.go (about)

     1  /*
     2   * Licensed to the Apache Software Foundation (ASF) under one or more
     3   * contributor license agreements.  See the NOTICE file distributed with
     4   * this work for additional information regarding copyright ownership.
     5   * The ASF licenses this file to You under the Apache License, Version 2.0
     6   * (the "License"); you may not use this file except in compliance with
     7   * the License.  You may obtain a copy of the License at
     8   *
     9   *     http://www.apache.org/licenses/LICENSE-2.0
    10   *
    11   * Unless required by applicable law or agreed to in writing, software
    12   * distributed under the License is distributed on an "AS IS" BASIS,
    13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14   * See the License for the specific language governing permissions and
    15   * limitations under the License.
    16   */
    17  
    18  package metrics
    19  
    20  const DefMaxAge = 600000000000
    21  
    22  type ReporterConfig struct {
    23  	Enable             bool
    24  	Namespace          string
    25  	Mode               ReportMode
    26  	Port               string
    27  	Path               string
    28  	PushGatewayAddress string
    29  	SummaryMaxAge      int64
    30  	Protocol           string // exporters, like prometheus
    31  }
    32  
    33  type ReportMode string
    34  
    35  const (
    36  	ReportModePull = "pull"
    37  	ReportModePush = "push"
    38  )
    39  
    40  func NewReporterConfig() *ReporterConfig {
    41  	return &ReporterConfig{
    42  		Enable:             true,
    43  		Namespace:          "dubbo",
    44  		Port:               "9090",
    45  		Path:               "/metrics",
    46  		Mode:               ReportModePull,
    47  		PushGatewayAddress: "",
    48  		SummaryMaxAge:      DefMaxAge,
    49  	}
    50  }
    51  
    52  // Reporter is an interface used to represent the backend of metrics to be exported
    53  type Reporter interface {
    54  	StartServer(config *ReporterConfig)
    55  	ShutdownServer()
    56  }