fix: issues

This commit is contained in:
Rogee
2025-01-07 18:30:41 +08:00
parent e557108a3e
commit 75125e507a
2 changed files with 78 additions and 245 deletions

View File

@@ -25,3 +25,55 @@ type Config struct {
EndpointHTTP string
Token string
}
package otel
import (
"os"
"git.ipao.vip/rogeecn/atom/container"
"git.ipao.vip/rogeecn/atom/utils/opt"
)
const DefaultPrefix = "OTEL"
func DefaultProvider() container.ProviderContainer {
return container.ProviderContainer{
Provider: Provide,
Options: []opt.Option{
opt.Prefix(DefaultPrefix),
},
}
}
type Config struct {
ServiceName string
Version string
Env string
EndpointGRPC string
EndpointHTTP string
Token string
}
func (c *Config) format() {
if c.ServiceName == "" {
c.ServiceName = os.Getenv("SERVICE_NAME")
if c.ServiceName == "" {
c.ServiceName = "unknown"
}
}
if c.Version == "" {
c.Version = os.Getenv("SERVICE_VERSION")
if c.Version == "" {
c.Version = "unknown"
}
}
if c.Env == "" {
c.Env = os.Getenv("DEPLOY_ENVIRONMENT")
if c.Env == "" {
c.Env = "unknown"
}
}
}