The code attempts to check whether there is a specific sampling rule specified for the request's route, by looking it up in the rulesMap. The rulesMap is an object, in the example above is { __ANY: 0 }. 0 is the index into the rules array.
However, the code in the lines above evaluates to -1 because 0 is falsy.
ref is then -1, which is treated as no specific rule matching, so you get the default configuration.
As a work around, one can simply specify a dummy rule before any import rules in the sample configuration, which will then happily be ignored.
There's a bug when configuring sampling rules.
Using the following configuration:
requests for the
/report
route would still end up using the default sampling configuration, instead of the route specific one.The bug lies in the lines https://github.com/jeremydaly/lambda-api/blob/5ca68708194a26a66c65b010c00ad5ff3082dbe6/lib/logger.js#L222-L230
The code attempts to check whether there is a specific sampling rule specified for the request's route, by looking it up in the rulesMap. The rulesMap is an object, in the example above is
{ __ANY: 0 }
.0
is the index into the rules array.However, the code in the lines above evaluates to
-1
because 0 is falsy.ref
is then -1, which is treated as no specific rule matching, so you get the default configuration.As a work around, one can simply specify a dummy rule before any import rules in the sample configuration, which will then happily be ignored.