package prometheus

// import (
// 	"errors"
// 	"fmt"

// 	confMetrics "github.com/pingcap-inc/clinic/clinic_data_service/pkg/config/metrics"
// 	"github.com/pingcap-inc/clinic/clinic_data_service/pkg/log"
// 	"go.uber.org/zap"
// )

// CreatePrometheusClientTiDB creates a Prometheus client for TiDB
// func CreatePrometheusClientTiDB(clusterId string) (*PrometheusClient, error) {
// 	cluster := confMetrics.GetClusterByID(clusterId)
// 	if cluster == nil {
// 		log.PlainError("Cluster configuration not found", zap.String("clusterId", clusterId))
// 		return nil, errors.New("Cluster configuration not found")
// 	}
// 	if cluster.MetricsRouting == "" || cluster.Region == "" {
// 		log.PlainError("Cluster configuration missing metricsRouting or region", zap.String("clusterId", clusterId))
// 		return nil, errors.New("Cluster configuration missing metricsRouting or region")
// 	}
// 	prometheusURL := fmt.Sprintf(confMetrics.AppConfig.Clinic.ClusterMetricsTemplateUrl, cluster.Region, cluster.MetricsRouting)
// 	if cluster.DeployType == "premium" {
// 		prometheusURL = fmt.Sprintf(confMetrics.AppConfig.Clinic.ClusterMetricsTemplateUrlTiDBX, cluster.Region, cluster.MetricsRouting)
// 	}

// 	log.PlainInfo("query: " + prometheusURL)
// 	pc, err := newPrometheusClient(prometheusURL)
// 	if err != nil {
// 		log.PlainError("newPrometheusClient failed", zap.Error(err))
// 		return nil, err
// 	}
// 	return pc, nil
// }

// func CreateO11yClientTiDB(clusterId string) (*PrometheusClient, error) {
// 	cluster := confMetrics.GetClusterByID(clusterId)
// 	org := config.GetOrgByClusterID(clusterId)

// 	if cluster == nil {
// 		log.PlainError("Cluster configuration not found", zap.String("clusterId", clusterId))
// 		return nil, errors.New("Cluster configuration not found")
// 	}
// 	if cluster.MetricsRouting == "" || cluster.Region == "" {
// 		log.PlainError("Cluster configuration missing metricsRouting or region", zap.String("clusterId", clusterId))
// 		return nil, errors.New("Cluster configuration missing metricsRouting or region")
// 	}
// 	var bizType o11y.BizType
// 	var applicationId o11y.ApplicationID

// 	switch cluster.Provider {
// 	case string(o11y.VendorAliCloud):
// 		bizType = o11y.BizTypeNextGen
// 	case string(o11y.VendorAWS):
// 		bizType = o11y.BizTypeTidbCloud
// 	default:
// 		bizType = o11y.BizTypeTidbCloud
// 	}

// 	switch cluster.DeployType {
// 	case "premium":
// 		applicationId = o11y.ApplicationID(cluster.ApplicationId)
// 	default:
// 		applicationId = o11y.ApplicationIDK8sInfra
// 	}
// 	// /?bizType=%s&vendor=%s&region=%s&applicationID=k8s-infra&projectID=%s
// 	apiUrl := fmt.Sprintf("%s/?bizType=%s&vendor=%s&region=%s&applicationID=%s&projectID=%s", confMetrics.AppConfig.O11yConfig.O11yMetadataBase, string(bizType), cluster.Provider, cluster.Region, string(applicationId), cluster.ProjectId)

// 	headerMap := map[string]string{
// 		"X-Region-Id": cluster.Region,
// 		"X-Org-Id":    org.OrgID,
// 		"X-Biz-Type":  string(bizType),
// 	}
// 	prometheusURL, err := confMetrics.GetO11yPrometheusUrl(apiUrl, clusterId, headerMap)
// 	if err != nil {
// 		log.PlainError("get prometheusURL form clinic api [api/v1/clusters]  failed", zap.Error(err))
// 		return nil, err
// 	}
// 	//prometheusURL := strings.ReplaceAll(url, "/", "")
// 	pc, err := newPrometheusClient(prometheusURL)
// 	if err != nil {
// 		log.PlainError("newPrometheusClient failed", zap.Error(err))
// 		return nil, err
// 	}
// 	return pc, nil
// }
