- Added Punycode encoding implementation for cookie handling. - Introduced serialization for cookie jar with JSON support. - Created a comprehensive README for the tracing provider, detailing configuration and usage. - Developed a configuration structure for tracing, including sampler and reporter settings. - Implemented the provider logic to initialize Jaeger tracer with logging capabilities. - Ensured graceful shutdown of the tracer on application exit.
74 lines
1.5 KiB
Smarty
74 lines
1.5 KiB
Smarty
package otel
|
|
|
|
import (
|
|
"os"
|
|
|
|
"go.ipao.vip/atom"
|
|
"go.ipao.vip/atom/container"
|
|
"go.ipao.vip/atom/opt"
|
|
)
|
|
|
|
const DefaultPrefix = "OTEL"
|
|
|
|
func DefaultProvider() container.ProviderContainer {
|
|
return container.ProviderContainer{
|
|
Provider: Provide,
|
|
Options: []opt.Option{
|
|
opt.Prefix(DefaultPrefix),
|
|
opt.Group(atom.GroupInitialName),
|
|
},
|
|
}
|
|
}
|
|
|
|
type Config struct {
|
|
ServiceName string
|
|
Version string
|
|
Env string
|
|
|
|
EndpointGRPC string
|
|
EndpointHTTP string
|
|
Token string
|
|
|
|
// Connection security
|
|
InsecureGRPC bool // if true, use grpc insecure for OTLP gRPC
|
|
InsecureHTTP bool // if true, use http insecure for OTLP HTTP
|
|
|
|
// Tracing sampler
|
|
// Sampler: "always" (default) or "ratio"
|
|
Sampler string
|
|
SamplerRatio float64 // used when Sampler == "ratio"; 0..1
|
|
|
|
// Tracing batcher options (milliseconds)
|
|
BatchTimeoutMs uint
|
|
ExportTimeoutMs uint
|
|
MaxQueueSize int
|
|
MaxExportBatchSize int
|
|
|
|
// Metrics options (milliseconds)
|
|
MetricReaderIntervalMs uint // export interval for PeriodicReader
|
|
RuntimeReadMemStatsIntervalMs uint // runtime metrics min read interval
|
|
}
|
|
|
|
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"
|
|
}
|
|
}
|
|
}
|