You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@trafficserver.apache.org by Aaron Canary <ac...@verizonmedia.com.INVALID> on 2020/04/03 14:59:47 UTC

Re: Throttler utility

Yes and no. It makes it easier for humans to read (sometimes). I know ops
uses Splunk to report the most frequent errors/warnings.
Also, I tend to grep or other post-process filters to just look at a single
session/transaction, and it would suck to not have the error because it
already happened for something else.

Maybe it could be used in conjunction with normal tag filtered debug
output.
<thought1>
void DebugError(tag, throttle, msg, args);
  // if tag is enabled, logs all errors
  // else throttles log errors
</thought1>

But I could also use it to set a transaction to be verbose every once in a
while, without overloading a production machine.
Something like this would also make HostDB timing/updates considerably more
readable.

On Tue, Mar 31, 2020 at 4:58 PM Walt Karas <wk...@verizonmedia.com.invalid>
wrote:

> Should we add a utility like this to include/ts/util ?
>
> class Throttle
> {
> public:
>   Throttle(unsigned secondsBetween = 60);
>
>   // Returns true the first time it's called, and if the time since the
> last time it returned true is
>   // more than secondsBetween seconds.
>   //
>   bool operator () ();
>
>   // Returns the number of times the member operator has been called.
>   //
>   unsigned times() const;
> };
>
> void Error(...);
>
> void foo(bool zwoop_ate_too_much_sushi)
> {
>     if (zwoop_ate_too_much_sushi) {
>         static Throttle t;
>
>         if (t()) {
>             Error("Zwoop ate too much sushi %u times, make salmon an
> endangered species", t.times());
>         }
>     }
> }
>

Re: Throttler utility

Posted by Walt Karas <wk...@verizonmedia.com.INVALID>.
Evil Dave crabbed about repetitive error logging, that's what motivated me
to do this.

On Fri, Apr 3, 2020 at 9:59 AM Aaron Canary <ac...@verizonmedia.com>
wrote:

> Yes and no. It makes it easier for humans to read (sometimes). I know ops
> uses Splunk to report the most frequent errors/warnings.
> Also, I tend to grep or other post-process filters to just look at a
> single session/transaction, and it would suck to not have the error because
> it already happened for something else.
>
> Maybe it could be used in conjunction with normal tag filtered debug
> output.
> <thought1>
> void DebugError(tag, throttle, msg, args);
>   // if tag is enabled, logs all errors
>   // else throttles log errors
> </thought1>
>
> But I could also use it to set a transaction to be verbose every once in a
> while, without overloading a production machine.
> Something like this would also make HostDB timing/updates
> considerably more readable.
>
> On Tue, Mar 31, 2020 at 4:58 PM Walt Karas <wk...@verizonmedia.com.invalid>
> wrote:
>
>> Should we add a utility like this to include/ts/util ?
>>
>> class Throttle
>> {
>> public:
>>   Throttle(unsigned secondsBetween = 60);
>>
>>   // Returns true the first time it's called, and if the time since the
>> last time it returned true is
>>   // more than secondsBetween seconds.
>>   //
>>   bool operator () ();
>>
>>   // Returns the number of times the member operator has been called.
>>   //
>>   unsigned times() const;
>> };
>>
>> void Error(...);
>>
>> void foo(bool zwoop_ate_too_much_sushi)
>> {
>>     if (zwoop_ate_too_much_sushi) {
>>         static Throttle t;
>>
>>         if (t()) {
>>             Error("Zwoop ate too much sushi %u times, make salmon an
>> endangered species", t.times());
>>         }
>>     }
>> }
>>
>