Unexpected results from rule matching
@srprash ya está trabajando en esto.
Desde el 18/1/2022.
Evaluación
Este issue todavía no se ha evaluado.
Descripción
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?
- Lenguaje dominante
- Python
- Estrellas
- 340
- Forks
- 148
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de aws/aws-xray-sdk-python
-
psycopg connection context manager drops X-Ray tracing wrapper, so cursor execute calls are not tracedPosiblemente ocupada @reginaldalfret la tomó hace 20 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
aws/aws-xray-sdk-python#490 · 1 comentario ·
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 1/100
aws/aws-xray-sdk-python#460 ·
-
Next releaseAbierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 20/100
aws/aws-xray-sdk-python#457 · 1 reacción ·
-
mysql-connector 9.2.0 - TypeError: 'MySQLConnection' object is not iterablePosiblemente ocupada @reginaldalfret la tomó hace 20 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
aws/aws-xray-sdk-python#453 ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
aws/aws-xray-sdk-python#452 · 1 reacción ·
Todos los issues de aws/aws-xray-sdk-python
Issues similares
-
good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
btclib-org/btclib-node#1955 ·
Los mantenedores suelen responder en 1 día
-
documentation v0.9.2
Dificultad 2/5 Medio día Aptitud para principiantes 72/100
khuisman/mcp-gee-sweet#1033 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
ossf/cve-bin-tool#5966 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 2 días
-
write_iceberg ignores the table's write.parquet.compression-codec propertyPosiblemente ocupada @YuangGao la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Eventual-Inc/Daft#7606 ·
Los mantenedores suelen responder en 1 día