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.
37 lines
1.1 KiB
37 lines
1.1 KiB
package ali
|
|
|
|
import (
|
|
"gitea.drugeyes.vip/pharnexbase/utils/tracer/generator"
|
|
"github.com/aliyun-sls/opentelemetry-go-provider-sls/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
|
|
}
|
|
|