You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am attempting to have the sampling rule selected with service name, but it does not appear to be selected correctly.
reproduction
The following sampling rules have already been created.
The scenario is intended to be that a rule matching the service and ServiceName of the trace is applied.
The following is the Python code that outputs the trace.
When creating the segment, "app-b" is set for service, but the sampling rules for "app-a" have been applied.
$ python --version
Python 3.9.0
$ pip list
Package Version
--------------- -------
aws-xray-sdk 2.10.0
botocore 1.27.62
jmespath 1.0.1
pip 20.2.3
python-dateutil 2.8.2
setuptools 49.2.1
six 1.16.0
urllib3 1.26.12
wrapt 1.14.1
$ cat ./main.py
import logging
from time import sleep
from aws_xray_sdk.core import xray_recorder
def main():
for _ in range(10):
with xray_recorder.in_segment() as segment:
sleep(0.4)
print(f"trace_id: {segment.trace_id}")
if __name__ == "__main__":
logging.basicConfig(level=logging.DEBUG)
xray_recorder.configure(service="app-b", sampling=True)
main()
$ AWS_XRAY_DAEMON_ADDRESS=127.0.0.1:2000 AWS_XRAY_TRACING_NAME=app-b python main.py
DEBUG:botocore.hooks:Changing event name from creating-client-class.iot-data to creating-client-class.iot-data-plane
DEBUG:botocore.hooks:Changing event name from before-call.apigateway to before-call.api-gateway
DEBUG:botocore.hooks:Changing event name from request-created.machinelearning.Predict to request-created.machine-learning.Predict
DEBUG:botocore.hooks:Changing event name from before-parameter-build.autoscaling.CreateLaunchConfiguration to before-parameter-build.auto-scaling.CreateLaunchConfiguration
DEBUG:botocore.hooks:Changing event name from before-parameter-build.route53 to before-parameter-build.route-53
DEBUG:botocore.hooks:Changing event name from request-created.cloudsearchdomain.Search to request-created.cloudsearch-domain.Search
DEBUG:botocore.hooks:Changing event name from docs.*.autoscaling.CreateLaunchConfiguration.complete-section to docs.*.auto-scaling.CreateLaunchConfiguration.complete-section
DEBUG:botocore.hooks:Changing event name from before-parameter-build.logs.CreateExportTask to before-parameter-build.cloudwatch-logs.CreateExportTask
DEBUG:botocore.hooks:Changing event name from docs.*.logs.CreateExportTask.complete-section to docs.*.cloudwatch-logs.CreateExportTask.complete-section
DEBUG:botocore.hooks:Changing event name from before-parameter-build.cloudsearchdomain.Search to before-parameter-build.cloudsearch-domain.Search
DEBUG:botocore.hooks:Changing event name from docs.*.cloudsearchdomain.Search.complete-section to docs.*.cloudsearch-domain.Search.complete-section
DEBUG:botocore.loaders:Loading JSON file: /Users/kenta.onishi/chart/xray-sandbox/.venv/lib/python3.9/site-packages/botocore/data/endpoints.json
DEBUG:botocore.loaders:Loading JSON file: /Users/kenta.onishi/chart/xray-sandbox/.venv/lib/python3.9/site-packages/botocore/data/sdk-default-configuration.json
DEBUG:botocore.hooks:Event choose-service-name: calling handler <function handle_service_name_alias at 0x1032cb9d0>
DEBUG:botocore.loaders:Loading JSON file: /Users/kenta.onishi/chart/xray-sandbox/.venv/lib/python3.9/site-packages/botocore/data/xray/2016-04-12/service-2.json
DEBUG:botocore.hooks:Event creating-client-class.xray: calling handler <function add_generate_presigned_url at 0x103206ca0>
DEBUG:botocore.endpoint:Setting xray timeout as (60, 60)
DEBUG:botocore.loaders:Loading JSON file: /Users/kenta.onishi/chart/xray-sandbox/.venv/lib/python3.9/site-packages/botocore/data/_retry.json
DEBUG:botocore.client:Registering retry handlers for service: xray
DEBUG:botocore.hooks:Event before-parameter-build.xray.GetSamplingRules: calling handler <function generate_idempotent_uuid at 0x1032e7040>
DEBUG:botocore.hooks:Event before-call.xray.GetSamplingRules: calling handler <function add_recursion_detection_header at 0x1032e2ca0>
INFO:aws_xray_sdk.core.sampling.sampler:No effective centralized sampling rule match. Fallback to local rules.
DEBUG:botocore.hooks:Event before-call.xray.GetSamplingRules: calling handler <function inject_api_version_header_if_needed at 0x1032e88b0>
DEBUG:botocore.endpoint:Making request for OperationModel(name=GetSamplingRules) with params: {'url_path': '/GetSamplingRules', 'query_string': {}, 'method': 'POST', 'headers': {'Content-Type': 'application/json', 'User-Agent': 'Botocore/1.27.62 Python/3.9.0 Darwin/21.6.0'}, 'body': b'{}', 'url': 'http://127.0.0.1:2000/GetSamplingRules', 'context': {'client_region': 'us-west-2', 'client_config': <botocore.config.Config object at 0x1038cfd90>, 'has_streaming_input': False, 'auth_type': None}}
DEBUG:botocore.hooks:Event request-created.xray.GetSamplingRules: calling handler <bound method RequestSigner.handler of <botocore.signers.RequestSigner object at 0x1038cfd30>>
DEBUG:botocore.hooks:Event choose-signer.xray.GetSamplingRules: calling handler <function set_operation_specific_signer at 0x1032e2ee0>
DEBUG:botocore.hooks:Event request-created.xray.GetSamplingRules: calling handler <function add_retry_headers at 0x1032e8f70>
DEBUG:botocore.endpoint:Sending http request: <AWSPreparedRequest stream_output=False, method=POST, url=http://127.0.0.1:2000/GetSamplingRules, headers={'Content-Type': b'application/json', 'User-Agent': b'Botocore/1.27.62 Python/3.9.0 Darwin/21.6.0', 'amz-sdk-invocation-id': b'd57dbf03-fd23-4807-bd1c-65630bf1dbd7', 'amz-sdk-request': b'attempt=1', 'Content-Length': '2'}>
DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): 127.0.0.1:2000
DEBUG:urllib3.connectionpool:http://127.0.0.1:2000 "POST /GetSamplingRules HTTP/1.1" 200 1068
DEBUG:botocore.parsers:Response headers: {'Content-Length': '1068', 'Content-Type': 'application/json', 'Date': 'Tue, 30 Aug 2022 04:17:54 GMT', 'Strict-Transport-Security': 'max-age=31540000; includeSubDomains', 'X-Amzn-Requestid': '3fd0dde5-0007-460e-9762-5e3b3987870c', 'X-Content-Type-Options': 'nosniff'}
DEBUG:botocore.parsers:Response body:
b'{"NextToken":null,"SamplingRuleRecords":[{"CreatedAt":1.661500922E9,"ModifiedAt":1.661826542E9,"SamplingRule":{"Attributes":{},"FixedRate":1.0,"HTTPMethod":"*","Host":"*","Priority":11,"ReservoirSize":1,"ResourceARN":"*","RuleARN":"arn:aws:xray:ap-northeast-1:123456789012:sampling-rule/app-b","RuleName":"app-b","ServiceName":"app-b","ServiceType":"*","URLPath":"*","Version":1}},{"CreatedAt":1.661233373E9,"ModifiedAt":1.661826536E9,"SamplingRule":{"Attributes":{},"FixedRate":0.01,"HTTPMethod":"*","Host":"*","Priority":10,"ReservoirSize":1,"ResourceARN":"*","RuleARN":"arn:aws:xray:ap-northeast-1:123456789012:sampling-rule/app-a","RuleName":"app-a","ServiceName":"app-a","ServiceType":"*","URLPath":"*","Version":1}},{"CreatedAt":0.0,"ModifiedAt":0.0,"SamplingRule":{"Attributes":{},"FixedRate":0.05,"HTTPMethod":"*","Host":"*","Priority":10000,"ReservoirSize":1,"ResourceARN":"*","RuleARN":"arn:aws:xray:ap-northeast-1:123456789012:sampling-rule/Default","RuleName":"Default","ServiceName":"*","ServiceType":"*","URLPath":"*","Version":1}}]}'
DEBUG:botocore.hooks:Event needs-retry.xray.GetSamplingRules: calling handler <botocore.retryhandler.RetryHandler object at 0x1038cf310>
DEBUG:botocore.retryhandler:No retry needed.
trace_id: 1-630d8f72-32b7265a9103495bb9a41f38
DEBUG:aws_xray_sdk.core.emitters.udp_emitter:sending: {"format":"json","version":1}
{"id": "28a9fbef177a9cb0", "name": "app-b", "start_time": 1661833074.652981, "in_progress": false, "aws": {"xray": {"sdk": "X-Ray for Python", "sdk_version": "2.10.0"}}, "trace_id": "1-630d8f72-32b7265a9103495bb9a41f38", "service": {"runtime": "CPython", "runtime_version": "3.9.0"}, "end_time": 1661833075.056917} to 127.0.0.1:2000.
DEBUG:aws_xray_sdk.core.sampling.sampler:Rule app-a is selected to make a sampling decision.
trace_id: 1-630d8f73-813017f3aafc5dc1cc9b6b64
DEBUG:aws_xray_sdk.core.emitters.udp_emitter:sending: {"format":"json","version":1}
{"id": "07d58fa3c63246cd", "name": "app-b", "start_time": 1661833075.057573, "in_progress": false, "aws": {"xray": {"sdk": "X-Ray for Python", "sdk_version": "2.10.0", "sampling_rule_name": "app-a"}}, "trace_id": "1-630d8f73-813017f3aafc5dc1cc9b6b64", "service": {"runtime": "CPython", "runtime_version": "3.9.0"}, "end_time": 1661833075.46228} to 127.0.0.1:2000.
DEBUG:aws_xray_sdk.core.sampling.sampler:Rule app-a is selected to make a sampling decision.
trace_id: 1-00000000-000000000000000000000000
DEBUG:aws_xray_sdk.core.sampling.sampler:Rule app-a is selected to make a sampling decision.
trace_id: 1-00000000-000000000000000000000000
DEBUG:aws_xray_sdk.core.sampling.sampler:Rule app-a is selected to make a sampling decision.
trace_id: 1-630d8f74-c95387d8196161ec9bd65cbb
DEBUG:aws_xray_sdk.core.emitters.udp_emitter:sending: {"format":"json","version":1}
{"id": "8530c9dc398feb84", "name": "app-b", "start_time": 1661833076.271061, "in_progress": false, "aws": {"xray": {"sdk": "X-Ray for Python", "sdk_version": "2.10.0", "sampling_rule_name": "app-a"}}, "trace_id": "1-630d8f74-c95387d8196161ec9bd65cbb", "service": {"runtime": "CPython", "runtime_version": "3.9.0"}, "end_time": 1661833076.67341} to 127.0.0.1:2000.
DEBUG:aws_xray_sdk.core.sampling.sampler:Rule app-a is selected to make a sampling decision.
trace_id: 1-00000000-000000000000000000000000
DEBUG:aws_xray_sdk.core.sampling.sampler:Rule app-a is selected to make a sampling decision.
trace_id: 1-630d8f75-74b2720c662574a78476c09b
DEBUG:aws_xray_sdk.core.emitters.udp_emitter:sending: {"format":"json","version":1}
{"id": "790a9823ca73b034", "name": "app-b", "start_time": 1661833077.07854, "in_progress": false, "aws": {"xray": {"sdk": "X-Ray for Python", "sdk_version": "2.10.0", "sampling_rule_name": "app-a"}}, "trace_id": "1-630d8f75-74b2720c662574a78476c09b", "service": {"runtime": "CPython", "runtime_version": "3.9.0"}, "end_time": 1661833077.483422} to 127.0.0.1:2000.
DEBUG:aws_xray_sdk.core.sampling.sampler:Rule app-a is selected to make a sampling decision.
trace_id: 1-00000000-000000000000000000000000
DEBUG:aws_xray_sdk.core.sampling.sampler:Rule app-a is selected to make a sampling decision.
trace_id: 1-00000000-000000000000000000000000
DEBUG:aws_xray_sdk.core.sampling.sampler:Rule app-a is selected to make a sampling decision.
trace_id: 1-630d8f76-5b69640dd4404539427a9ea1
DEBUG:aws_xray_sdk.core.emitters.udp_emitter:sending: {"format":"json","version":1}
{"id": "48178b2211a495a8", "name": "app-b", "start_time": 1661833078.293151, "in_progress": false, "aws": {"xray": {"sdk": "X-Ray for Python", "sdk_version": "2.10.0", "sampling_rule_name": "app-a"}}, "trace_id": "1-630d8f76-5b69640dd4404539427a9ea1", "service": {"runtime": "CPython", "runtime_version": "3.9.0"}, "end_time": 1661833078.695625} to 127.0.0.1:2000.
I checked the sampling_rule_name of the raw data in the trace and it was "app-a" as well.
Uh oh!
There was an error while loading. Please reload this page.
I am attempting to have the sampling rule selected with service name, but it does not appear to be selected correctly.
reproduction
The following sampling rules have already been created.
The scenario is intended to be that a rule matching the service and ServiceName of the trace is applied.
I have an X-Ray daemon process running on my local MacOS.
The following is the Python code that outputs the trace.
When creating the segment, "app-b" is set for service, but the sampling rules for "app-a" have been applied.
I checked the sampling_rule_name of the raw data in the trace and it was "app-a" as well.
The text was updated successfully, but these errors were encountered: