AWS X-Ray

2018/08/28 - AWS X-Ray - 6 new api methods

Changes  Support for new APIs that enable management of sampling rules.

GetSamplingStatisticSummaries (new) Link ¶

Retrieves information about recent sampling results for all sampling rules.

See also: AWS API Documentation

Request Syntax

client.get_sampling_statistic_summaries(
    NextToken='string'
)
type NextToken

string

param NextToken

Pagination token. Not used.

rtype

dict

returns

Response Syntax

{
    'SamplingStatisticSummaries': [
        {
            'RuleName': 'string',
            'Timestamp': datetime(2015, 1, 1),
            'RequestCount': 123,
            'BorrowCount': 123,
            'SampledCount': 123
        },
    ],
    'NextToken': 'string'
}

Response Structure

  • (dict) --

    • SamplingStatisticSummaries (list) --

      Information about the number of requests instrumented for each sampling rule.

      • (dict) --

        Aggregated request sampling data for a sampling rule across all services for a 10 second window.

        • RuleName (string) --

          The name of the sampling rule.

        • Timestamp (datetime) --

          The start time of the reporting window.

        • RequestCount (integer) --

          The number of requests that matched the rule.

        • BorrowCount (integer) --

          The number of requests recorded with borrowed reservoir quota.

        • SampledCount (integer) --

          The number of requests recorded.

    • NextToken (string) --

      Pagination token. Not used.

DeleteSamplingRule (new) Link ¶

Deletes a sampling rule.

See also: AWS API Documentation

Request Syntax

client.delete_sampling_rule(
    RuleName='string',
    RuleARN='string'
)
type RuleName

string

param RuleName

The name of the sampling rule. Specify a rule by either name or ARN, but not both.

type RuleARN

string

param RuleARN

The ARN of the sampling rule. Specify a rule by either name or ARN, but not both.

rtype

dict

returns

Response Syntax

{
    'SamplingRuleRecord': {
        'SamplingRule': {
            'RuleName': 'string',
            'RuleARN': 'string',
            'ResourceARN': 'string',
            'Priority': 123,
            'FixedRate': 123.0,
            'ReservoirSize': 123,
            'ServiceName': 'string',
            'ServiceType': 'string',
            'Host': 'string',
            'HTTPMethod': 'string',
            'URLPath': 'string',
            'Version': 123,
            'Attributes': {
                'string': 'string'
            }
        },
        'CreatedAt': datetime(2015, 1, 1),
        'ModifiedAt': datetime(2015, 1, 1)
    }
}

Response Structure

  • (dict) --

    • SamplingRuleRecord (dict) --

      The deleted rule definition and metadata.

      • SamplingRule (dict) --

        The sampling rule.

        • RuleName (string) --

          The name of the sampling rule. Specify a rule by either name or ARN, but not both.

        • RuleARN (string) --

          The ARN of the sampling rule. Specify a rule by either name or ARN, but not both.

        • ResourceARN (string) --

          Matches the ARN of the AWS resource on which the service runs.

        • Priority (integer) --

          The priority of the sampling rule.

        • FixedRate (float) --

          The percentage of matching requests to instrument, after the reservoir is exhausted.

        • ReservoirSize (integer) --

          A fixed number of matching requests to instrument per second, prior to applying the fixed rate. The reservoir is not used directly by services, but applies to all services using the rule collectively.

        • ServiceName (string) --

          Matches the name that the service uses to identify itself in segments.

        • ServiceType (string) --

          Matches the origin that the service uses to identify its type in segments.

        • Host (string) --

          Matches the hostname from a request URL.

        • HTTPMethod (string) --

          Matches the HTTP method of a request.

        • URLPath (string) --

          Matches the path from a request URL.

        • Version (integer) --

          The version of the sampling rule format ( 1 ).

        • Attributes (dict) --

          Matches attributes derived from the request.

          • (string) --

            • (string) --

      • CreatedAt (datetime) --

        When the rule was created.

      • ModifiedAt (datetime) --

        When the rule was last modified.

GetSamplingTargets (new) Link ¶

Requests a sampling quota for rules that the service is using to sample requests.

See also: AWS API Documentation

Request Syntax

client.get_sampling_targets(
    SamplingStatisticsDocuments=[
        {
            'RuleName': 'string',
            'ClientID': 'string',
            'Timestamp': datetime(2015, 1, 1),
            'RequestCount': 123,
            'SampledCount': 123,
            'BorrowCount': 123
        },
    ]
)
type SamplingStatisticsDocuments

list

param SamplingStatisticsDocuments

[REQUIRED]

Information about rules that the service is using to sample requests.

  • (dict) --

    Request sampling results for a single rule from a service. Results are for the last 10 seconds unless the service has been assigned a longer reporting interval after a previous call to GetSamplingTargets.

    • RuleName (string) -- [REQUIRED]

      The name of the sampling rule.

    • ClientID (string) -- [REQUIRED]

      A unique identifier for the service in hexadecimal.

    • Timestamp (datetime) -- [REQUIRED]

      The current time.

    • RequestCount (integer) -- [REQUIRED]

      The number of requests that matched the rule.

    • SampledCount (integer) -- [REQUIRED]

      The number of requests recorded.

    • BorrowCount (integer) --

      The number of requests recorded with borrowed reservoir quota.

rtype

dict

returns

Response Syntax

{
    'SamplingTargetDocuments': [
        {
            'RuleName': 'string',
            'FixedRate': 123.0,
            'ReservoirQuota': 123,
            'ReservoirQuotaTTL': datetime(2015, 1, 1),
            'Interval': 123
        },
    ],
    'LastRuleModification': datetime(2015, 1, 1),
    'UnprocessedStatistics': [
        {
            'RuleName': 'string',
            'ErrorCode': 'string',
            'Message': 'string'
        },
    ]
}

Response Structure

  • (dict) --

    • SamplingTargetDocuments (list) --

      Updated rules that the service should use to sample requests.

      • (dict) --

        Temporary changes to a sampling rule configuration. To meet the global sampling target for a rule, X-Ray calculates a new reservoir for each service based on the recent sampling results of all services that called GetSamplingTargets.

        • RuleName (string) --

          The name of the sampling rule.

        • FixedRate (float) --

          The percentage of matching requests to instrument, after the reservoir is exhausted.

        • ReservoirQuota (integer) --

          The number of requests per second that X-Ray allocated this service.

        • ReservoirQuotaTTL (datetime) --

          When the reservoir quota expires.

        • Interval (integer) --

          The number of seconds for the service to wait before getting sampling targets again.

    • LastRuleModification (datetime) --

      The last time a user changed the sampling rule configuration. If the sampling rule configuration changed since the service last retrieved it, the service should call GetSamplingRules to get the latest version.

    • UnprocessedStatistics (list) --

      Information about SamplingStatisticsDocument that X-Ray could not process.

      • (dict) --

        Sampling statistics from a call to GetSamplingTargets that X-Ray could not process.

        • RuleName (string) --

          The name of the sampling rule.

        • ErrorCode (string) --

          The error code.

        • Message (string) --

          The error message.

GetSamplingRules (new) Link ¶

Retrieves all sampling rules.

See also: AWS API Documentation

Request Syntax

client.get_sampling_rules(
    NextToken='string'
)
type NextToken

string

param NextToken

Pagination token. Not used.

rtype

dict

returns

Response Syntax

{
    'SamplingRuleRecords': [
        {
            'SamplingRule': {
                'RuleName': 'string',
                'RuleARN': 'string',
                'ResourceARN': 'string',
                'Priority': 123,
                'FixedRate': 123.0,
                'ReservoirSize': 123,
                'ServiceName': 'string',
                'ServiceType': 'string',
                'Host': 'string',
                'HTTPMethod': 'string',
                'URLPath': 'string',
                'Version': 123,
                'Attributes': {
                    'string': 'string'
                }
            },
            'CreatedAt': datetime(2015, 1, 1),
            'ModifiedAt': datetime(2015, 1, 1)
        },
    ],
    'NextToken': 'string'
}

Response Structure

  • (dict) --

    • SamplingRuleRecords (list) --

      Rule definitions and metadata.

      • (dict) --

        A SamplingRule and its metadata.

        • SamplingRule (dict) --

          The sampling rule.

          • RuleName (string) --

            The name of the sampling rule. Specify a rule by either name or ARN, but not both.

          • RuleARN (string) --

            The ARN of the sampling rule. Specify a rule by either name or ARN, but not both.

          • ResourceARN (string) --

            Matches the ARN of the AWS resource on which the service runs.

          • Priority (integer) --

            The priority of the sampling rule.

          • FixedRate (float) --

            The percentage of matching requests to instrument, after the reservoir is exhausted.

          • ReservoirSize (integer) --

            A fixed number of matching requests to instrument per second, prior to applying the fixed rate. The reservoir is not used directly by services, but applies to all services using the rule collectively.

          • ServiceName (string) --

            Matches the name that the service uses to identify itself in segments.

          • ServiceType (string) --

            Matches the origin that the service uses to identify its type in segments.

          • Host (string) --

            Matches the hostname from a request URL.

          • HTTPMethod (string) --

            Matches the HTTP method of a request.

          • URLPath (string) --

            Matches the path from a request URL.

          • Version (integer) --

            The version of the sampling rule format ( 1 ).

          • Attributes (dict) --

            Matches attributes derived from the request.

            • (string) --

              • (string) --

        • CreatedAt (datetime) --

          When the rule was created.

        • ModifiedAt (datetime) --

          When the rule was last modified.

    • NextToken (string) --

      Pagination token. Not used.

UpdateSamplingRule (new) Link ¶

Modifies a sampling rule's configuration.

See also: AWS API Documentation

Request Syntax

client.update_sampling_rule(
    SamplingRuleUpdate={
        'RuleName': 'string',
        'RuleARN': 'string',
        'ResourceARN': 'string',
        'Priority': 123,
        'FixedRate': 123.0,
        'ReservoirSize': 123,
        'Host': 'string',
        'ServiceName': 'string',
        'ServiceType': 'string',
        'HTTPMethod': 'string',
        'URLPath': 'string',
        'Attributes': {
            'string': 'string'
        }
    }
)
type SamplingRuleUpdate

dict

param SamplingRuleUpdate

[REQUIRED]

The rule and fields to change.

  • RuleName (string) --

    The name of the sampling rule. Specify a rule by either name or ARN, but not both.

  • RuleARN (string) --

    The ARN of the sampling rule. Specify a rule by either name or ARN, but not both.

  • ResourceARN (string) --

    Matches the ARN of the AWS resource on which the service runs.

  • Priority (integer) --

    The priority of the sampling rule.

  • FixedRate (float) --

    The percentage of matching requests to instrument, after the reservoir is exhausted.

  • ReservoirSize (integer) --

    A fixed number of matching requests to instrument per second, prior to applying the fixed rate. The reservoir is not used directly by services, but applies to all services using the rule collectively.

  • Host (string) --

    Matches the hostname from a request URL.

  • ServiceName (string) --

    Matches the name that the service uses to identify itself in segments.

  • ServiceType (string) --

    Matches the origin that the service uses to identify its type in segments.

  • HTTPMethod (string) --

    Matches the HTTP method of a request.

  • URLPath (string) --

    Matches the path from a request URL.

  • Attributes (dict) --

    Matches attributes derived from the request.

    • (string) --

      • (string) --

rtype

dict

returns

Response Syntax

{
    'SamplingRuleRecord': {
        'SamplingRule': {
            'RuleName': 'string',
            'RuleARN': 'string',
            'ResourceARN': 'string',
            'Priority': 123,
            'FixedRate': 123.0,
            'ReservoirSize': 123,
            'ServiceName': 'string',
            'ServiceType': 'string',
            'Host': 'string',
            'HTTPMethod': 'string',
            'URLPath': 'string',
            'Version': 123,
            'Attributes': {
                'string': 'string'
            }
        },
        'CreatedAt': datetime(2015, 1, 1),
        'ModifiedAt': datetime(2015, 1, 1)
    }
}

Response Structure

  • (dict) --

    • SamplingRuleRecord (dict) --

      The updated rule definition and metadata.

      • SamplingRule (dict) --

        The sampling rule.

        • RuleName (string) --

          The name of the sampling rule. Specify a rule by either name or ARN, but not both.

        • RuleARN (string) --

          The ARN of the sampling rule. Specify a rule by either name or ARN, but not both.

        • ResourceARN (string) --

          Matches the ARN of the AWS resource on which the service runs.

        • Priority (integer) --

          The priority of the sampling rule.

        • FixedRate (float) --

          The percentage of matching requests to instrument, after the reservoir is exhausted.

        • ReservoirSize (integer) --

          A fixed number of matching requests to instrument per second, prior to applying the fixed rate. The reservoir is not used directly by services, but applies to all services using the rule collectively.

        • ServiceName (string) --

          Matches the name that the service uses to identify itself in segments.

        • ServiceType (string) --

          Matches the origin that the service uses to identify its type in segments.

        • Host (string) --

          Matches the hostname from a request URL.

        • HTTPMethod (string) --

          Matches the HTTP method of a request.

        • URLPath (string) --

          Matches the path from a request URL.

        • Version (integer) --

          The version of the sampling rule format ( 1 ).

        • Attributes (dict) --

          Matches attributes derived from the request.

          • (string) --

            • (string) --

      • CreatedAt (datetime) --

        When the rule was created.

      • ModifiedAt (datetime) --

        When the rule was last modified.

CreateSamplingRule (new) Link ¶

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.

See also: AWS API Documentation

Request Syntax

client.create_sampling_rule(
    SamplingRule={
        'RuleName': 'string',
        'RuleARN': 'string',
        'ResourceARN': 'string',
        'Priority': 123,
        'FixedRate': 123.0,
        'ReservoirSize': 123,
        'ServiceName': 'string',
        'ServiceType': 'string',
        'Host': 'string',
        'HTTPMethod': 'string',
        'URLPath': 'string',
        'Version': 123,
        'Attributes': {
            'string': 'string'
        }
    }
)
type SamplingRule

dict

param SamplingRule

[REQUIRED]

The rule definition.

  • RuleName (string) --

    The name of the sampling rule. Specify a rule by either name or ARN, but not both.

  • RuleARN (string) --

    The ARN of the sampling rule. Specify a rule by either name or ARN, but not both.

  • ResourceARN (string) -- [REQUIRED]

    Matches the ARN of the AWS resource on which the service runs.

  • Priority (integer) -- [REQUIRED]

    The priority of the sampling rule.

  • FixedRate (float) -- [REQUIRED]

    The percentage of matching requests to instrument, after the reservoir is exhausted.

  • ReservoirSize (integer) -- [REQUIRED]

    A fixed number of matching requests to instrument per second, prior to applying the fixed rate. The reservoir is not used directly by services, but applies to all services using the rule collectively.

  • ServiceName (string) -- [REQUIRED]

    Matches the name that the service uses to identify itself in segments.

  • ServiceType (string) -- [REQUIRED]

    Matches the origin that the service uses to identify its type in segments.

  • Host (string) -- [REQUIRED]

    Matches the hostname from a request URL.

  • HTTPMethod (string) -- [REQUIRED]

    Matches the HTTP method of a request.

  • URLPath (string) -- [REQUIRED]

    Matches the path from a request URL.

  • Version (integer) -- [REQUIRED]

    The version of the sampling rule format ( 1 ).

  • Attributes (dict) --

    Matches attributes derived from the request.

    • (string) --

      • (string) --

rtype

dict

returns

Response Syntax

{
    'SamplingRuleRecord': {
        'SamplingRule': {
            'RuleName': 'string',
            'RuleARN': 'string',
            'ResourceARN': 'string',
            'Priority': 123,
            'FixedRate': 123.0,
            'ReservoirSize': 123,
            'ServiceName': 'string',
            'ServiceType': 'string',
            'Host': 'string',
            'HTTPMethod': 'string',
            'URLPath': 'string',
            'Version': 123,
            'Attributes': {
                'string': 'string'
            }
        },
        'CreatedAt': datetime(2015, 1, 1),
        'ModifiedAt': datetime(2015, 1, 1)
    }
}

Response Structure

  • (dict) --

    • SamplingRuleRecord (dict) --

      The saved rule definition and metadata.

      • SamplingRule (dict) --

        The sampling rule.

        • RuleName (string) --

          The name of the sampling rule. Specify a rule by either name or ARN, but not both.

        • RuleARN (string) --

          The ARN of the sampling rule. Specify a rule by either name or ARN, but not both.

        • ResourceARN (string) --

          Matches the ARN of the AWS resource on which the service runs.

        • Priority (integer) --

          The priority of the sampling rule.

        • FixedRate (float) --

          The percentage of matching requests to instrument, after the reservoir is exhausted.

        • ReservoirSize (integer) --

          A fixed number of matching requests to instrument per second, prior to applying the fixed rate. The reservoir is not used directly by services, but applies to all services using the rule collectively.

        • ServiceName (string) --

          Matches the name that the service uses to identify itself in segments.

        • ServiceType (string) --

          Matches the origin that the service uses to identify its type in segments.

        • Host (string) --

          Matches the hostname from a request URL.

        • HTTPMethod (string) --

          Matches the HTTP method of a request.

        • URLPath (string) --

          Matches the path from a request URL.

        • Version (integer) --

          The version of the sampling rule format ( 1 ).

        • Attributes (dict) --

          Matches attributes derived from the request.

          • (string) --

            • (string) --

      • CreatedAt (datetime) --

        When the rule was created.

      • ModifiedAt (datetime) --

        When the rule was last modified.