You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
package ali
|
|
|
|
|
|
|
|
import (
|
|
|
|
"gitea.drugeyes.vip/pharnexbase/utils/tracer/generator"
|
|
|
|
"gitea.drugeyes.vip/pharnexbase/utils/tracer/provider"
|
|
|
|
)
|
|
|
|
|
|
|
|
type AliSLSConfig struct {
|
|
|
|
Name string
|
|
|
|
Version string
|
|
|
|
Env string
|
|
|
|
TraceExporterEndpoint string
|
|
|
|
MetricExporterEndpoint string
|
|
|
|
Project string
|
|
|
|
InstanceId string
|
|
|
|
AccessKeyId string
|
|
|
|
AccessKeySecret string
|
|
|
|
}
|
|
|
|
|
|
|
|
// 设置链路追逐的方法 ali
|
|
|
|
func InitTracerProvider(bc *AliSLSConfig) (*provider.Config, error) {
|
|
|
|
slsConfig, err := provider.NewConfig(provider.WithServiceName(bc.Name),
|
|
|
|
provider.WithServiceVersion(bc.Version),
|
|
|
|
provider.WithServiceNamespace(bc.Env),
|
|
|
|
provider.WithTraceExporterEndpoint(bc.TraceExporterEndpoint),
|
|
|
|
provider.WithMetricExporterEndpoint(bc.MetricExporterEndpoint),
|
|
|
|
provider.WithIDGenerator(generator.DefaultIDGenerator()),
|
|
|
|
provider.WithSLSConfig(bc.Project, bc.InstanceId, bc.AccessKeyId, bc.AccessKeySecret))
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
if err := provider.Start(slsConfig); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return slsConfig, nil
|
|
|
|
}
|