gtrace_tracer.go 600 B

123456789101112131415161718192021222324252627
  1. // Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
  2. //
  3. // This Source Code Form is subject to the terms of the MIT License.
  4. // If a copy of the MIT was not distributed with this file,
  5. // You can obtain one at https://github.com/gogf/gf.
  6. package gtrace
  7. import (
  8. "go.opentelemetry.io/otel"
  9. "go.opentelemetry.io/otel/trace"
  10. )
  11. type Tracer struct {
  12. trace.Tracer
  13. }
  14. // Tracer is a short function for retrieving Tracer.
  15. func NewTracer(name ...string) *Tracer {
  16. tracerName := ""
  17. if len(name) > 0 {
  18. tracerName = name[0]
  19. }
  20. return &Tracer{
  21. Tracer: otel.Tracer(tracerName),
  22. }
  23. }