通用包
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.
utils/tracer/ali/ali_trace.go

38 lines
1.1 KiB

1 year ago
package ali
import (
"gitea.drugeyes.vip/pharnexbase/utils/tracer/generator"
"gitea.drugeyes.vip/pharnexbase/utils/tracer/provider"
1 year ago
)
type AliSLSConfig struct {
Name string
Version string
Env string
TraceExporterEndpoint string
MetricExporterEndpoint string
Project string
InstanceId string
AccessKeyId string
AccessKeySecret string
}
1 year ago
// 设置链路追逐的方法 ali
func InitTracerProvider(bc *AliSLSConfig) (*provider.Config, error) {
1 year ago
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
}