/******************************************************************************
 * Copyright (c)  2022 PingCAP                                                *
 * Licensed under the Apache License, Version 2.0 (the "License");            *
 * you may not use this file except in compliance with the License.           *
 * You may obtain a copy of the License at                                    *
 *                                                                            *
 * http://www.apache.org/licenses/LICENSE-2.0                                 *
 *                                                                            *
 * Unless required by applicable law or agreed to in writing, software        *
 * distributed under the License is distributed on an "AS IS" BASIS,          *
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   *
 * See the License for the specific language governing permissions and        *
 * limitations under the License.                                             *
 ******************************************************************************/

/*******************************************************************************
 * @File: define.go
 * @Description:
 * @Author: jiangxunyu@pingcap.com
 * @Version: 1.0.0
 * @Date: 2022/7/8 16:27
*******************************************************************************/

package metrics

const (
	ServiceLabel = "service"
	HandlerLabel = "handler"
	MethodLabel  = "method"
	CodeLabel    = "code"
	VendorLabel  = "vendor"
	RegionLabel  = "region"

	FileNameLabel     = "file_name"
	FuncNameLabel     = "func_name"
	ErrorMessageLabel = "error_msg"

	AZLabel                    = "az"
	PullIntervalLabel          = "pull_interval"
	ClusterIDLabel             = "cluster_id"
	ResourceNameLabel          = "resource_name"
	ControllerNameLabel        = "contoller_name"
	VersionLabel               = "version"
	TenantIDLabel              = "tenant_id"
	ProjectIDLabel             = "project_id"
	ApplicationIDLabel         = "application_id"
	BizTypeLabel               = "biz_type"
	O11YClusterIDLabel         = "o11y_cluster_id"
	MinutesToLastModifiedLabel = "minutes_to_last_modified"

	AWSClientLabel = "aws_client"
	AWSAPILabel    = "aws_api"

	AliCloudClientLabel = "alicloud_client"
	AliCloudAPILabel    = "alicloud_api"

	GCPClientLabel = "gcp_client"
	GCPAPILabel    = "gcp_api"
)

type MetricDef struct {
	Name       string
	Help       string
	LabelNames []string
}

// Metrics define
var (
	BootTimeGaugeMetricDef = MetricDef{
		Name:       "boot_time",
		Help:       "A gauge of process boot time.",
		LabelNames: []string{ServiceLabel},
	}

	APIRequestsCounterMetricDef = MetricDef{
		Name:       "http_requests_total",
		Help:       "A counter for requests to the wrapped handler.",
		LabelNames: []string{ServiceLabel, HandlerLabel, MethodLabel, CodeLabel, VendorLabel, RegionLabel},
	}
	RequestDurationHistogramMetricDef = MetricDef{
		Name:       "http_request_duration_seconds",
		Help:       "A histogram of latencies for requests, statistics by second.",
		LabelNames: []string{ServiceLabel, HandlerLabel, MethodLabel, CodeLabel, VendorLabel, RegionLabel},
	}
	RequestSizeHistogramMetricDef = MetricDef{
		Name:       "http_request_size_bytes",
		Help:       "A histogram of request sizes for requests, statistics by kb.",
		LabelNames: []string{ServiceLabel, HandlerLabel, MethodLabel, CodeLabel, VendorLabel, RegionLabel},
	}
	ResponseSizeHistogramMetricDef = MetricDef{
		Name:       "http_response_size_bytes",
		Help:       "A histogram of response sizes for requests, statistics by kb.",
		LabelNames: []string{ServiceLabel, HandlerLabel, MethodLabel, CodeLabel, VendorLabel, RegionLabel},
	}

	BizErrorTotalCounterMetricDef = MetricDef{
		Name:       "biz_error_total",
		Help:       "A counter for error message handler.",
		LabelNames: []string{ServiceLabel, FileNameLabel, FuncNameLabel, ErrorMessageLabel},
	}

	GlobalRoutingRegionalTotalGaugeMetricDef = MetricDef{
		Name:       "routing_regional_total",
		Help:       "A gauge for global routing regional total.",
		LabelNames: []string{ServiceLabel, VendorLabel},
	}
	GlobalRoutingRegionalInfoGaugeMetricDef = MetricDef{
		Name:       "routing_regional_info",
		Help:       "A gauge for global routing regional info.",
		LabelNames: []string{ServiceLabel, VendorLabel, RegionLabel},
	}

	RegionalControllerRunsTotalCounterMetricDef = MetricDef{
		Name:       "controller_runs_total",
		Help:       "A counter for controller runs total.",
		LabelNames: []string{ServiceLabel, VendorLabel, RegionLabel, ResourceNameLabel, ControllerNameLabel, PullIntervalLabel, ErrorMessageLabel},
	}

	ErrorDialTestMetricsInfoCounterMetricDef = MetricDef{
		Name:       "dial_test_metrics_error_info",
		Help:       "A counter for dial test metrics error info.",
		LabelNames: []string{VendorLabel, RegionLabel, O11YClusterIDLabel, TenantIDLabel, ProjectIDLabel, ApplicationIDLabel},
	}

	ErrorDialTestRegionalServerCounterMetricDef = MetricDef{
		Name:       "dial_test_regional_server_error_total",
		Help:       "A counter for dial test regional server error total.",
		LabelNames: []string{ServiceLabel, VendorLabel, RegionLabel},
	}

	DialTestLogsInfoCounterMetricDef = MetricDef{
		Name:       "dial_test_logs_info",
		Help:       "A counter for dial test logs info.",
		LabelNames: []string{VendorLabel, RegionLabel, O11YClusterIDLabel, TenantIDLabel, ProjectIDLabel, ApplicationIDLabel, MinutesToLastModifiedLabel},
	}

	AWSAPIRequestCounterMetricDef = MetricDef{
		Name:       "aws_api_request_total",
		Help:       "A counter for AWS client api requests.",
		LabelNames: []string{RegionLabel, AWSClientLabel, AWSAPILabel, ResourceNameLabel, ErrorMessageLabel},
	}

	GCPAPIRequestCounterMetricDef = MetricDef{
		Name:       "gcp_api_request_total",
		Help:       "A counter for GCP client api requests.",
		LabelNames: []string{RegionLabel, GCPClientLabel, GCPAPILabel, ResourceNameLabel, ErrorMessageLabel},
	}

	AliCloudAPIRequestCounterMetricDef = MetricDef{
		Name:       "ali_cloud_api_request_total",
		Help:       "A counter for ali cloud client api requests.",
		LabelNames: []string{RegionLabel, AliCloudClientLabel, AliCloudAPILabel, ResourceNameLabel, ErrorMessageLabel},
	}
)
