You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If the X-B3-Sampled header is missing from the incoming request - for example when you just call the app from a browser - no span whatsoever will be sampled. This effectively means the sampling rate will be ignored.
I'm not enough of a Python programmer to submit a merge request, but here's what I think would work:
create a new field unmarkedRequests in init
in each _before_request
if the header X-B3-TraceId is missing, increment unmarkedRequests
is_sampled = (unmarkedRequests >= 100 / sample_rate) or X-B3-Sampled is present and "1"
if unmarkedRequests >= 100 / sample_rate then set unmarkedRequests to 0
I tested with this code added in _before_request(self), and it seems to work right:
if (not headers.get('X-B3-Sampled')):
self._unmarked = self._unmarked + 1;
is_sampled = (self._unmarked >= 100 / self._sample_rate) or is_sampled;
if (self._unmarked >= 1 / self._sample_rate):
self._unmarked = 0;
Why this way: if requests come from a source which has already set sampling info, we don't need to deal with them. Otherwise, we need to record a proportion of sample_rate of them - which translates roughly to one request every 100 / sample_rate requests.
The text was updated successfully, but these errors were encountered:
If the X-B3-Sampled header is missing from the incoming request - for example when you just call the app from a browser - no span whatsoever will be sampled. This effectively means the sampling rate will be ignored.
I'm not enough of a Python programmer to submit a merge request, but here's what I think would work:
I tested with this code added in
_before_request(self)
, and it seems to work right:Why this way: if requests come from a source which has already set sampling info, we don't need to deal with them. Otherwise, we need to record a proportion of sample_rate of them - which translates roughly to one request every 100 / sample_rate requests.
The text was updated successfully, but these errors were encountered: