Unexpected results from rule matching
@srprash がすでに取り組んでいます。
2022年1月18日 から。
評価
この issue はまだ評価されていません。
説明
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?
- 主要言語
- Python
- スター
- 340
- フォーク
- 148
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
aws/aws-xray-sdk-python のほかの issue
-
psycopg connection context manager drops X-Ray tracing wrapper, so cursor execute calls are not traced対応中かも @reginaldalfret が 21 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
aws/aws-xray-sdk-python#490 · コメント 1 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 1/100
aws/aws-xray-sdk-python#460 ·
-
Next releaseオープン
難易度 5/5 1週間以上 初心者へのやさしさ 20/100
aws/aws-xray-sdk-python#457 · リアクション 1 件 ·
-
mysql-connector 9.2.0 - TypeError: 'MySQLConnection' object is not iterable対応中かも @reginaldalfret が 21 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
aws/aws-xray-sdk-python#453 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
aws/aws-xray-sdk-python#452 · リアクション 1 件 ·
aws/aws-xray-sdk-python の issue をすべて見る
似ている issue
-
Questions crashes on a real SQuAD2 no-answer prediction対応中かも @HuaTNA が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
GST is read as Gulf Standard Time (UTC+4) instead of Guam Standard Time (UTC+10)対応中かも @yang00333 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
DOI-USGS/dataretrieval-python#454 ·
メンテナーはふだん 4 日以内に返信
-
area:core-platform effort:S priority:P3 status:in-review type:test
難易度 2/5 1時間未満 初心者へのやさしさ 80/100
randomparity/kdive#3246 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Requantification library converts m/z to mass with the hydrogen-atom mass instead of the proton massオープンbug
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
nf-core/metaboigniter#130 ·
メンテナーはふだん 1 日以内に返信
-
netbox status: needs owner type: documentation
難易度 1/5 1時間未満 初心者へのやさしさ 75/100
netbox-community/netbox#23412 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信