From 6b91b4ef09cd6a8ae1a6c8b67d2c2eea1daf090f Mon Sep 17 00:00:00 2001 From: David Janowski Date: Mon, 26 Aug 2024 16:38:14 +0200 Subject: [PATCH] fix: context creation to use request context in TaskStart method --- pkg/plug/grpc.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/plug/grpc.go b/pkg/plug/grpc.go index ad009f2..715d6d2 100644 --- a/pkg/plug/grpc.go +++ b/pkg/plug/grpc.go @@ -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 // 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 - taskCtx, cancel := context.WithCancel(context.Background()) + taskCtx, cancel := context.WithCancel(ctx) s.ctx[id] = cancel 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, "user_source_id": creation.UserSourceId, }).Info("Starting task")