Unexpected results from rule matching
@srprash đang làm issue này rồi.
Từ ngày 18/1/2022.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
Hi,
I have standalone apps and APIs in my environment. But, it seems like the SamplingRule.match() always return the highest priority rule as the result for all standalone apps. Currently, all the rules are in the cloud.
My use case is to have a blanket rule to ignore a certain endpoint from multiple APIs and still be able to tweak sampling rules for standalone apps and/or APIs.
Here's my sample test:
import time
import pytest
from aws_xray_sdk.core.sampling.sampling_rule import SamplingRule
from aws_xray_sdk.core.sampling.rule_cache import RuleCache
from aws_xray_sdk.core.sampling.reservoir import Reservoir
rule_ignore = SamplingRule(name='ignore', priority=10, rate=0,
reservoir_size=0, host='*', method='*',
path='/ignore_endpoint', service='*',
service_type='*')
rule_std_app1 = SamplingRule(name='std_app1', priority=20, rate=0.5,
reservoir_size=10, host='*', method='*',
path='*', service='std_app1',
service_type='*')
rule_api1 = SamplingRule(name='api1', priority=20, rate=0.5,
reservoir_size=10, host='*', method='*',
path='*', service='api1',
service_type='*')
rule_default = SamplingRule(name='Default', priority=1000, rate=0.1,
reservoir_size=1)
def test_rule_matching():
cache = RuleCache()
now = int(time.time())
cache.load_rules([rule_ignore, rule_std_app1, rule_api1, rule_default])
cache.last_updated = now
print("\n")
sampling_req = {'path':'/ignore_endpoint'}
rule = cache.get_matched_rule(sampling_req, now)
print(f"\nsampling_req: {sampling_req}\nExpected: ignore, Matched: {rule.name}")
print(f"{rule.name} == 'ignore'? {rule.name == 'ignore'}")
# assert rule.name == 'ignore'
sampling_req = {'service':'std_app1'}
rule = cache.get_matched_rule(sampling_req, now)
print(f"\nsampling_req: {sampling_req}\nExpected: std_app1, Matched: {rule.name}")
print(f"{rule.name} == 'std_app1'? {rule.name == 'std_app1'}")
# assert rule.name == 'std_app1'
sampling_req = {'service':'std_app2'}
rule = cache.get_matched_rule(sampling_req, now)
print(f"\nsampling_req: {sampling_req}\nExpected: Default, Matched: {rule.name}")
print(f"{rule.name} == 'Default'? {rule.is_default()}")
# assert rule.is_default()
sampling_req = {'service':'api1', 'path':'/test'}
rule = cache.get_matched_rule(sampling_req, now)
print(f"\nsampling_req: {sampling_req}\nExpected: api1, Matched: {rule.name}")
print(f"{rule.name} == 'api1'? {rule.name == 'api1'}")
# assert rule.name == 'api1'
Here's the debug output for the print statements
sampling_req: {'path': '/ignore_endpoint'}
Expected: ignore, Matched: ignore
ignore == 'ignore'? True
sampling_req: {'service': 'std_app1'}
Expected: std_app1, Matched: ignore
ignore == 'std_app1'? False
sampling_req: {'service': 'std_app2'}
Expected: Default, Matched: ignore
ignore == 'Default'? False
sampling_req: {'service': 'api1', 'path': '/test'}
Expected: api1, Matched: api1
api1 == 'api1'? True
As you can see, the standalone apps (std_app1 and std_app2) resulted with ignore rule instead of the expected rule.
Please confirm if this is an expected behavior or a bug?
- Ngôn ngữ chính
- Python
- Star
- 340
- Fork
- 148
- Merge trung bình
- 7 ngày 8 giờ
- Pull request đã merge (30 ngày)
- 2
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của aws/aws-xray-sdk-python
-
psycopg connection context manager drops X-Ray tracing wrapper, so cursor execute calls are not tracedCó thể đã có người làm @reginaldalfret đã nhận 23 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
aws/aws-xray-sdk-python#490 · 1 bình luận ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 1/100
aws/aws-xray-sdk-python#460 ·
-
Next releaseĐang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 20/100
aws/aws-xray-sdk-python#457 · 1 reaction ·
-
mysql-connector 9.2.0 - TypeError: 'MySQLConnection' object is not iterableCó thể đã có người làm @reginaldalfret đã nhận 23 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
aws/aws-xray-sdk-python#453 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
aws/aws-xray-sdk-python#452 · 1 reaction ·
Tất cả issue của aws/aws-xray-sdk-python
Issue tương tự
-
bug Size: XS
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
oposs/repo-infra#93 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 69/100
Graphify-Labs/graphify#4546 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 65/100
521xueweihan/HelloGitHub#4025 ·