When initializing Aspecto SDK, you can pass the
samplingRatio option to control the general sampling rate of our client. But sometimes you'd want more sampling control only over specific flows. That's where sampling rules come in handy.
Go to the sampling rules page on Aspecto website, and click on the "New Rule" button. You'd be presented with the rule creation dialog:
In the above example, we are creating a rule to sample only 10% of
health-check requests where the service name is
wikipedia-serviceand the environment starts with
Setting a rule matcher for Service Name and Environment is mandatory.
You can then choose to create extra conditions for your rules.
Possible matchers for the extra conditions are:
HTTP Request Path (i.e.
HTTP Full URL (i.e.
HTTP Method (i.e.
HTTP Host (i.e.
User Agent (i.e.
Queue/Topic Name (Queue name for SQS, Topic name for Kafka, etc.)
All rule conditions must be fulfilled for a rule to apply.
Rules are matched only against the entry point of a flow, but affect the sampling of the entire flow.
That means that if I set a rule where
HTTP Request Path equals "/user" , and my flow starts with a request to an endpoint called
/account , which internally calls the
/user endpoint, the rule will not apply, even though the user endpoint was involved.
String-based rules are case insensitive (i.e.
"HELLO" contains "he" will match)
SDK clients are updated in real-time and changes are effective immediately, so be careful!
Rules are run by their priority where 1 is the top priority. Once a rule is matched the other rules won't be run on the targeted flow anymore.
If non of the rules match, the default sampling rate will be used (
samplingRate option or 100% if none provided).
Sampling rules are ignored when running in local mode.