config.go 666 B

123456789101112131415161718192021222324252627
  1. package trace
  2. import (
  3. "strings"
  4. )
  5. // TraceName represents the tracing name.
  6. const TraceName = "go-zero"
  7. // A Config is an opentelemetry config.
  8. type Config struct {
  9. Name string `json:",optional"`
  10. Endpoint string `json:",optional"`
  11. Sampler float64 `json:",default=1.0"`
  12. Batcher string `json:",default=jaeger,options=jaeger|jaegerudp|zipkin|otlpgrpc|otlphttp"`
  13. }
  14. func (c *Config) parseEndpoint() (host string, port string) {
  15. EndpointSlice := strings.Split(c.Endpoint, ":")
  16. if len(EndpointSlice) > 0 {
  17. host = strings.TrimSpace(EndpointSlice[0])
  18. }
  19. if len(EndpointSlice) > 0 {
  20. port = strings.TrimSpace(EndpointSlice[1])
  21. }
  22. return host, port
  23. }