fix: context creation to use request context in TaskStart method
This commit is contained in:
parent
bef94becce
commit
426701f58c
@ -60,11 +60,11 @@ 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
|
||||||
taskCtx, cancel := context.WithCancel(context.Background())
|
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)))
|
||||||
|
|
||||||
log.WithContext(ctx).WithFields(log.Fields{
|
log.WithContext(taskCtx).WithFields(log.Fields{
|
||||||
"task_id": id,
|
"task_id": id,
|
||||||
"user_source_id": creation.UserSourceId,
|
"user_source_id": creation.UserSourceId,
|
||||||
}).Info("Starting task")
|
}).Info("Starting task")
|
||||||
|
Loading…
Reference in New Issue
Block a user