[Disk Manager] Add parent span for regular tasks, add parent span rotation for long-running regular tasks #2474
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#1199
Now spans for regular are inconvenient. Tasks have no common parent. For example, if a regular tasks had several generations, each generation will create spans in separate trace.
In this pr we create common parent span for spans created by a regular task.
Also, we rotate the parent span if the task runs for long. This prevents from obtaining too large trace and from losing all spans due to trace expiration. This feature is useful for OptimizeBaseDisks task.
For example, assume that some task ran for 7 days, trace ttl is 5 days and parent rotation period is 3 days. And assume that we want to look at the traced of this task just after it's completion. Then the task will have three traces, the oldest one will be already expired, but we will be able to see the remaining two traces. Without rotation, we wouldn't be able to see anything.
We use tracestate field in task metadata to store the timestamp of the trace.
Note: parent span rotation will not happen if a task is runned for long with one and the same generation.