feat: Assign new context with span context to address gRPC closure issue
This commit is contained in:
parent
426701f58c
commit
7ce3b94756
@ -60,6 +60,8 @@ func (s *server) TaskStart(ctx context.Context, creation *gRPC.PlugTaskCreation)
|
|||||||
// gRPC closes the context after the call ended. So the whole scrapping stopped without waiting
|
// gRPC closes the context after the call ended. So the whole scrapping stopped without waiting
|
||||||
// by using this method we assign a new context to each new request we get.
|
// by using this method we assign a new context to each new request we get.
|
||||||
// This can be used for example to close the context with the given id
|
// This can be used for example to close the context with the given id
|
||||||
|
ctx = trace.ContextWithSpanContext(context.Background(), trace.NewSpanContext(trace.SpanContextConfig{TraceID: span.SpanContext().TraceID()}))
|
||||||
|
|
||||||
taskCtx, cancel := context.WithCancel(ctx)
|
taskCtx, cancel := context.WithCancel(ctx)
|
||||||
s.ctx[id] = cancel
|
s.ctx[id] = cancel
|
||||||
span.AddEvent("Created new context for task", trace.WithAttributes(attribute.String("task_id", id)))
|
span.AddEvent("Created new context for task", trace.WithAttributes(attribute.String("task_id", id)))
|
||||||
|
Loading…
Reference in New Issue
Block a user