github.com/gogf/gf/v2@v2.7.4/net/gtrace/internal/provider/provider_idgenerator.go (about) 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 7 package provider 8 9 import ( 10 "context" 11 12 "go.opentelemetry.io/otel/trace" 13 14 "github.com/gogf/gf/v2/internal/tracing" 15 ) 16 17 // IDGenerator is a trace ID generator. 18 type IDGenerator struct{} 19 20 // NewIDGenerator returns a new IDGenerator. 21 func NewIDGenerator() *IDGenerator { 22 return &IDGenerator{} 23 } 24 25 // NewIDs creates and returns a new trace and span ID. 26 func (id *IDGenerator) NewIDs(ctx context.Context) (traceID trace.TraceID, spanID trace.SpanID) { 27 return tracing.NewIDs() 28 } 29 30 // NewSpanID returns an ID for a new span in the trace with traceID. 31 func (id *IDGenerator) NewSpanID(ctx context.Context, traceID trace.TraceID) (spanID trace.SpanID) { 32 return tracing.NewSpanID() 33 }