Skip to content

Conversation

olzhik11
Copy link
Member

@olzhik11 olzhik11 commented Oct 8, 2025

Important

Add sampling to process_batch in consumer.rs using TRACE_SUMMARY_SAMPLE_RATE to control trace processing.

  • Behavior:
    • Adds sampling to process_batch in consumer.rs using TRACE_SUMMARY_SAMPLE_RATE environment variable.
    • Uses rand::rngs::StdRng to generate random numbers for sampling decision.
    • Default sample rate is 0.25, clamped between 0.0 and 1.0.
  • Error Handling:
    • Logs error if pushing trace completion to summary queue fails.
  • Misc:
    • Imports rand::{Rng, SeedableRng} in consumer.rs.

This description was created by Ellipsis for 5a023be. You can customize this summary. It will automatically update as commits are pushed.

@olzhik11 olzhik11 self-assigned this Oct 8, 2025
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

Caution

Changes requested ❌

Reviewed everything up to 5a023be in 2 minutes and 3 seconds. Click for details.
  • Reviewed 51 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. app-server/src/traces/consumer.rs:345
  • Draft comment:
    It appears that rand::rng() might be a typo. Typically, to obtain a random number generator one might use rand::thread_rng() instead. Please verify whether rand::rng() is the intended function.
  • Reason this comment was not posted:
    Marked as duplicate.
2. app-server/src/traces/consumer.rs:349
  • Draft comment:
    The method random_range does not seem standard. Usually, the method from the rand crate is gen_range. Consider replacing rng.random_range(0.0..1.0) with rng.gen_range(0.0..1.0) if appropriate.
  • Reason this comment was not posted:
    Marked as duplicate.

Workflow ID: wflow_xRrrFWOK2jmQk1Fo

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

.unwrap_or(0.25_f64)
.clamp(0.0, 1.0);

let mut rng = rand::rngs::StdRng::from_rng(&mut rand::rng());
Copy link
Contributor

Choose a reason for hiding this comment

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

The RNG initialization is incorrect. Replace rand::rng() with a valid RNG, e.g., use rand::thread_rng() or StdRng::from_entropy().unwrap(), to properly seed StdRng.

Suggested change
let mut rng = rand::rngs::StdRng::from_rng(&mut rand::rng());
let mut rng = rand::rngs::StdRng::from_entropy();

Copy link
Member Author

Choose a reason for hiding this comment

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

hmm there is no from_entropy method on it

span.project_id,
e
);
if rng.random_range(0.0..1.0) < sample_rate {
Copy link
Contributor

Choose a reason for hiding this comment

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

Use the correct RNG method. Replace rng.random_range(0.0..1.0) with rng.gen_range(0.0..1.0) or consider using rng.gen_bool(sample_rate) for clarity.

Suggested change
if rng.random_range(0.0..1.0) < sample_rate {
if rng.gen_range(0.0..1.0) < sample_rate {

Copy link
Member Author

Choose a reason for hiding this comment

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

random_range is the right one

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