createSamplingRule method

Future<CreateSamplingRuleResult> createSamplingRule({
  1. required SamplingRule samplingRule,
  2. List<Tag>? tags,
})

Creates a rule to control sampling behavior for instrumented applications. Services retrieve rules with GetSamplingRules, and evaluate each rule in ascending order of priority for each request. If a rule matches, the service records a trace, borrowing it from the reservoir size. After 10 seconds, the service reports back to X-Ray with GetSamplingTargets to get updated versions of each in-use rule. The updated rule contains a trace quota that the service can use instead of borrowing from the reservoir.

May throw InvalidRequestException. May throw ThrottledException. May throw RuleLimitExceededException.

Parameter samplingRule : The rule definition.

Parameter tags : A map that contains one or more tag keys and tag values to attach to an X-Ray sampling rule. For more information about ways to use tags, see Tagging AWS resources in the AWS General Reference.

The following restrictions apply to tags:

  • Maximum number of user-applied tags per resource: 50
  • Maximum tag key length: 128 Unicode characters
  • Maximum tag value length: 256 Unicode characters
  • Valid values for key and value: a-z, A-Z, 0-9, space, and the following characters: _ . : / = + - and @
  • Tag keys and values are case sensitive.
  • Don't use aws: as a prefix for keys; it's reserved for AWS use.

Implementation

Future<CreateSamplingRuleResult> createSamplingRule({
  required SamplingRule samplingRule,
  List<Tag>? tags,
}) async {
  ArgumentError.checkNotNull(samplingRule, 'samplingRule');
  final $payload = <String, dynamic>{
    'SamplingRule': samplingRule,
    if (tags != null) 'Tags': tags,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/CreateSamplingRule',
    exceptionFnMap: _exceptionFns,
  );
  return CreateSamplingRuleResult.fromJson(response);
}