mirror of
				https://github.com/go-micro/go-micro.git
				synced 2025-10-30 23:27:41 +02:00 
			
		
		
		
	add trace context
This commit is contained in:
		| @@ -37,7 +37,7 @@ func (t *trace) Read(opts ...ReadOption) ([]*Span, error) { | ||||
| 	return spans, nil | ||||
| } | ||||
|  | ||||
| func (t *trace) Start(ctx context.Context, name string) *Span { | ||||
| func (t *trace) Start(ctx context.Context, name string) (context.Context, *Span) { | ||||
| 	span := &Span{ | ||||
| 		Name:     name, | ||||
| 		Trace:    uuid.New().String(), | ||||
| @@ -48,12 +48,12 @@ func (t *trace) Start(ctx context.Context, name string) *Span { | ||||
|  | ||||
| 	// return span if no context | ||||
| 	if ctx == nil { | ||||
| 		return span | ||||
| 		return context.Background(), span | ||||
| 	} | ||||
|  | ||||
| 	s, ok := FromContext(ctx) | ||||
| 	if !ok { | ||||
| 		return span | ||||
| 		return ctx, span | ||||
| 	} | ||||
|  | ||||
| 	// set trace id | ||||
| @@ -62,7 +62,7 @@ func (t *trace) Start(ctx context.Context, name string) *Span { | ||||
| 	span.Parent = s.Id | ||||
|  | ||||
| 	// return the sapn | ||||
| 	return span | ||||
| 	return ctx, span | ||||
| } | ||||
|  | ||||
| func (t *trace) Finish(s *Span) error { | ||||
|   | ||||
| @@ -9,7 +9,7 @@ import ( | ||||
| // Trace is an interface for distributed tracing | ||||
| type Trace interface { | ||||
| 	// Start a trace | ||||
| 	Start(ctx context.Context, name string) *Span | ||||
| 	Start(ctx context.Context, name string) (context.Context, *Span) | ||||
| 	// Finish the trace | ||||
| 	Finish(*Span) error | ||||
| 	// Read the traces | ||||
|   | ||||
		Reference in New Issue
	
	Block a user