config.go 697 B

123456789101112131415161718192021222324252627
  1. package trace
  2. import "fmt"
  3. // TraceName represents the tracing name.
  4. const TraceName = "go-zero"
  5. // A Config is an opentelemetry config.
  6. type Config struct {
  7. Name string `json:",optional"`
  8. AgentHost string `json:",optional"`
  9. AgentPort 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) isAgentEndPoint() bool {
  15. return len(c.AgentHost) != 0 && len(c.AgentPort) != 0
  16. }
  17. func (c *Config) getEndpoint() string {
  18. if c.isAgentEndPoint() {
  19. return fmt.Sprintf("%s:%s", c.AgentHost, c.AgentPort)
  20. }
  21. return c.Endpoint
  22. }