Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sampling rules matching when they shouldn't #22

Open
LarsFronius opened this issue Mar 5, 2019 · 1 comment
Open

Sampling rules matching when they shouldn't #22

LarsFronius opened this issue Mar 5, 2019 · 1 comment
Labels

Comments

@LarsFronius
Copy link
Contributor

LarsFronius commented Mar 5, 2019

Say I have a sampling rule like this with priority 1:
screenshot 2019-03-05 at 13 44 02
The only other rule configured is the Default rule.

I'd expect for this sampling rule to apply to a service, which starts it's segment like
XRay.recorder.begin_segment 'anotherService' and no others, in order to throttle tracing data originating from anotherService.

However, it appears to also match in our case to other documents than originally intended and thus is effectively becoming the new default.
From our document I can see that the rule has been applied (censored some bits):

{
    "Duration": 0.095,
    "Id": "1-5c7e774b-8423ee74fd64ab8c0540f810",
    "Segments": [
        {
            "Document": {
                "id": "1799765cda88d70c",
                "name": "aDifferentServiceName",
                "start_time": 1551791947.8924115,
                "end_time": 1551791947.9878953,
                "http": {
                    "request": {
                        "url": "XXXXX",
                        "method": "GET",
                        "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36",
                        "client_ip": "XXXXXX",
                        "x_forwarded_for": true
                    },
                    "response": {
                        "status": 200,
                        "content_length": 12345
                    }
                },
                "aws": {
                    "xray": {
                        "sdk_version": "0.11.1",
                        "sdk": "X-Ray for Ruby",
                        "sampling_rule_name": "foo"
                    }
                },

I'd have expected for my rule not to match in this case and only the Default rule to match.

@LarsFronius LarsFronius changed the title Sampling rules matching too wide Sampling rules matching when they shouldn't Mar 5, 2019
@haotianw465 haotianw465 added the bug label Mar 8, 2019
@haotianw465
Copy link
Contributor

I confirmed this is a bug. The sampling rule definition is mostly http centric (host, url, path etc) and the matching is done at middleware level if the rack middleware is used for generating segments. But as you can see when manually creating segment the SDK doesn't match against anything so the rule with highest priority always matches: https://github.com/aws/aws-xray-sdk-ruby/blob/master/lib/aws-xray-sdk/recorder.rb#L31-L32

But the field service_name should apply to all scenarios such that manually creating a segment also respects that pattern. We will fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants