Skip to content
This repository was archived by the owner on Oct 23, 2023. It is now read-only.

Add sample_rate configuration #978

Merged
merged 1 commit into from
Mar 9, 2017
Merged

Add sample_rate configuration #978

merged 1 commit into from
Mar 9, 2017

Conversation

dcramer
Copy link
Member

@dcramer dcramer commented Mar 9, 2017

No description provided.

.. code-block:: python

# send 50% of events
sample_rate = 5.0
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't this contradict what the description says? 0.5 would be sending 50% of events. I didn't read the code to see how it' simplemented though, so not sure which one is accurate.

Copy link
Member Author

Choose a reason for hiding this comment

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

oops

@dcramer dcramer merged commit 24c0ecd into master Mar 9, 2017
@dcramer dcramer deleted the feature/sample-rate branch March 9, 2017 20:16
@@ -627,7 +631,9 @@ def capture(self, event_type, data=None, date=None, time_spent=None,
event_type, data, date, time_spent, extra, stack, tags=tags,
**kwargs)

self.send(**data)
# should this event be sampled?
if self._random.random() <= self.sample_rate:

Choose a reason for hiding this comment

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

Technically this is lower bound inclusive, so a sample rate of 0.0 can still result in an event being sent. It'd be safer/more correct to make this comparison <. 🤓

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants