Skip to content
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

[ANE-1027] Reduce broker trace file size #146

Merged
merged 4 commits into from
Sep 23, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/debug.rs
Original file line number Diff line number Diff line change
@@ -140,7 +140,10 @@ impl Config {
.with(
tracing_subscriber::fmt::layer()
.json()
.with_span_events(FmtSpan::FULL)
.flatten_event(true)
.with_thread_ids(true)
.with_span_list(false)
.with_span_events(FmtSpan::ACTIVE)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • flatten_event1
    • This is just a minor simplification of the json structure that should save a bit of space
  • with_span_list2 and with_thread_ids3
    • Idea here is that we don't need to add the span list to every trace if we include the thread id
    • We can infer the span list by looking at the previously entered/exited spans on the same thread id for a given trace
  • with_span_events4
    • Switching to ACTIVE as that includes all enters/exits, which seem to me to be far more relevant for debugging than creates/drops

Footnotes

  1. https://docs.rs/tracing-subscriber/latest/tracing_subscriber/fmt/struct.Layer.html#method.flatten_event

  2. https://docs.rs/tracing-subscriber/latest/tracing_subscriber/fmt/struct.Layer.html#method.with_span_list

  3. https://docs.rs/tracing-subscriber/latest/tracing_subscriber/fmt/struct.Layer.html#method.with_thread_ids

  4. https://docs.rs/tracing-subscriber/latest/tracing_subscriber/fmt/struct.Layer.html#method.with_span_events

Copy link
Member

@jssblck jssblck Sep 19, 2024

Choose a reason for hiding this comment

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

flatten_event

Do you have examples of what this looks like before/after?

with_span_list and with_thread_ids
Idea here is that we don't need to add the span list to every trace if we include the thread id

Is the idea that by recording thread IDs, we can retain the context across temporally intertwined span events without actually including them in the message?

If so, this won't actually do what you're after: tokio is multithreaded, yes, but only as an implementation detail; it is primarily a work-stealing executor of concurrent lightweight tasks.

In other words, the same thread can work on many disparate tasks that have no relation to one another. So unfortunately I don't think this'll avoid that problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you have examples of what this looks like before/after?

Sure! Before:

{"timestamp":"2024-09-19T21:32:44.075971Z","level":"INFO","fields":{"message":"enter"},"target":"broker::db::sqlite","span":{"location":"\"/Users/nic/.config/fossa/broker/db.sqlite\"","name":"connect"},"threadId":"ThreadId(1)"}

After:

{"timestamp":"2024-09-19T19:38:11.111064Z","level":"INFO","message":"enter","target":"broker::db::sqlite","span":{"location":"\"/Users/nic/.config/fossa/broker/db.sqlite\"","name":"connect"},"threadId":"ThreadId(1)"}

If so, this won't actually do what you're after: tokio is multithreaded, yes, but only as an implementation detail; it is primarily a work-stealing executor of concurrent lightweight tasks.

In other words, the same thread can work on many disparate tasks that have no relation to one another. So unfortunately I don't think this'll avoid that problem.

Damn, okay, good to know. I was hoping that this would be a cheeky built-in way to accomplish what you mentioned in this thread but alas. I'll take another stab at it!

.with_writer(sink),
);

Loading