gtrace_tracer.go 672 B

12345678910111213141516171819202122232425262728
  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. // Tracer warps trace.Tracer for compatibility and extension.
  12. type Tracer struct {
  13. trace.Tracer
  14. }
  15. // NewTracer Tracer is a short function for retrieving Tracer.
  16. func NewTracer(name ...string) *Tracer {
  17. tracerName := ""
  18. if len(name) > 0 {
  19. tracerName = name[0]
  20. }
  21. return &Tracer{
  22. Tracer: otel.Tracer(tracerName),
  23. }
  24. }