Skip to content

[ENH] Reorganize load-service traces #4518

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 12, 2025
Merged

Conversation

jasonvigil
Copy link
Contributor

Description of changes

Remove the parent "workload" trace for the entire workload. It's too long-lasting, and contains too many sub-spans. Instead, generate a "step" root trace for each workload step. Events for each workload step will be associated with the step's root trace.

This will make spans easier to read, and debug.

Test plan

Tested locally via tilt and jaeger.

Documentation Changes

N/A

@jasonvigil jasonvigil requested a review from rescrv May 9, 2025 21:14
Copy link

github-actions bot commented May 9, 2025

Reviewer Checklist

Please leverage this checklist to ensure your code review is thorough before approving

Testing, Bugs, Errors, Logs, Documentation

  • Can you think of any use case in which the code does not behave as intended? Have they been tested?
  • Can you think of any inputs or external events that could break the code? Is user input validated and safe? Have they been tested?
  • If appropriate, are there adequate property based tests?
  • If appropriate, are there adequate unit tests?
  • Should any logging, debugging, tracing information be added or removed?
  • Are error messages user-friendly?
  • Have all documentation changes needed been made?
  • Have all non-obvious changes been commented?

System Compatibility

  • Are there any potential impacts on other parts of the system or backward compatibility?
  • Does this change intersect with any items on our roadmap, and if so, is there a plan for fitting them together?

Quality

  • Is this code of a unexpectedly high quality (Readability, Modularity, Intuitiveness)

@@ -1271,13 +1271,11 @@ impl LoadService {
for declared in declared {
if let Entry::Vacant(entry) = running.entry(declared.uuid) {
tracing::info!("spawning workload {}", declared.uuid);
let root = tracing::info_span!(parent: None, "workload");
let this = Arc::clone(self);
let done = Arc::new(AtomicBool::new(false));
let done_p = Arc::clone(&done);
let inhibit = Arc::clone(&self.inhibit);
let task = tokio::task::spawn(async move {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[BestPractice]

Consider using a descriptive span name that includes the workload UUID for better tracing context. This would make debugging and log analysis easier by clearly identifying which workload a particular trace belongs to.

@@ -1408,30 +1376,45 @@ impl LoadService {
.await
.map_err(|err| Error::FailWorkload(err.to_string()))
{
Ok(()) => Ok(()),
Ok(()) => (),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[CriticalError]

It appears that you're returning () from the Ok path but not handling the error path properly. The pattern matching suggests you should either return something or propagate the error, but the error is effectively swallowed here. Consider adding explicit error handling or returning a Result from this closure.

Err(err) => {
if err.to_string().contains("invalid request: No results") {
if format!("{err:?}").contains("invalid request: No results") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[BestPractice]

For consistent error handling, replace format!("{err:?}").contains() with a more structured approach. String matching on error messages is fragile and could break if error messages change. Consider adding error types or codes that can be checked more reliably.

Copy link
Contributor

propel-code-bot bot commented May 9, 2025

Reorganizing Load-Service Traces for Better Debugging

This PR restructures the tracing architecture in the load-service by removing the single long-lasting 'workload' trace span that contained too many sub-spans. Instead, it creates individual 'step' root traces for each workload step, making spans easier to read and debug. The change also improves error handling and logging, with more descriptive tracing for different error conditions.

Key Changes:
• Removed parent 'workload' trace span in favor of individual 'step' spans
• Eliminated task reaper mechanism in favor of direct error handling
• Added workload UUID to trace spans for better identification
• Improved error logging with specific messages for different error types

Affected Areas:
• rust/load/src/lib.rs - workload tracing infrastructure

This summary was automatically generated by @propel-code-bot

};
tx.send(tokio::spawn(fut)).await.unwrap();
let span = tracing::info_span!(parent: None, "step", workload_uuid = %spec.uuid);
tokio::spawn(fut.instrument(span));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[BestPractice]

Using instrument(span) without properly closing or dropping the span may lead to resource leaks. Ensure that the span is properly managed in the spawned task, especially when dealing with many workloads.

Err(err) => {
if err.to_string().contains("invalid request: No results") {
if format!("{err:?}").contains("invalid request: No results") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we shouldn't make this drop. Not in this PR, but we should remove this case of error handling. It's error-masking.

@jasonvigil jasonvigil enabled auto-merge (squash) May 9, 2025 21:45
@jasonvigil jasonvigil force-pushed the jason/cv-trace-improvements branch from cacb9d7 to 8984f88 Compare May 9, 2025 22:09
jasonvigil added 2 commits May 9, 2025 15:33
Remove the parent "workload" trace for the entire workload. It's too
long-lasting, and contains too many sub-spans. Instead, generate a "step" root
trace for each workload step. Events for each workload step will be associated
with the step's root trace.
@jasonvigil jasonvigil force-pushed the jason/cv-trace-improvements branch from 28d2363 to 7d9863b Compare May 9, 2025 22:34
@jasonvigil jasonvigil merged commit 8170f91 into main May 12, 2025
70 checks passed
@jasonvigil jasonvigil deleted the jason/cv-trace-improvements branch May 12, 2025 16:36
narner pushed a commit to narner/chroma that referenced this pull request May 12, 2025
## Description of changes

Remove the parent "workload" trace for the entire workload. It's too
long-lasting, and contains too many sub-spans. Instead, generate a
"step" root trace for each workload step. Events for each workload step
will be associated with the step's root trace.

This will make spans easier to read, and debug.

## Test plan

Tested locally via tilt and jaeger.

## Documentation Changes

N/A

---------

Co-authored-by: propel-code-bot[bot] <203372662+propel-code-bot[bot]@users.noreply.github.com>
itaismith pushed a commit that referenced this pull request May 23, 2025
## Description of changes

Remove the parent "workload" trace for the entire workload. It's too
long-lasting, and contains too many sub-spans. Instead, generate a
"step" root trace for each workload step. Events for each workload step
will be associated with the step's root trace.

This will make spans easier to read, and debug.

## Test plan

Tested locally via tilt and jaeger.

## Documentation Changes

N/A

---------

Co-authored-by: propel-code-bot[bot] <203372662+propel-code-bot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants