Skip to content

Incompatible with Pynamodb 6.x #436

Description

@yan12125

With pynamodb 6.0.1, I got a test failure:

________________________________ test_exception ________________________________

    def test_exception():
        class SampleModel(Model):
            class Meta:
                region = 'us-west-2'
                table_name = 'mytable'

            sample_attribute = UnicodeAttribute(hash_key=True)

        try:
            SampleModel.describe_table()
        except Exception:
            pass

        subsegments = xray_recorder.current_segment().subsegments
        assert len(subsegments) == 1
        subsegment = subsegments[0]
        assert subsegment.name == 'dynamodb'
>       assert len(subsegment.subsegments) == 0
E       assert 1 == 0
E        +  where 1 = len([<aws_xray_sdk.core.models.subsegment.Subsegment object at 0x7c54cfd0ef00>])
E        +    where [<aws_xray_sdk.core.models.subsegment.Subsegment object at 0x7c54cfd0ef00>] = <aws_xray_sdk.core.models.subsegment.Subsegment object at 0x7c54d140e600>.subsegments

tests/ext/pynamodb/test_pynamodb.py:48: AssertionError

Activity

  1. srprash commented on Jun 17, 2024

    @srprash
    Contributor

    Hey @vastin.
    I notice that this PR pinned the pynamodb version to < 6.0.0.
    Do you know if this test failure was the reason for it? Looks like we get a child subsegment for pynamodb instrumentation for v6.x. from the above exception.

  2. srprash commented on Jun 17, 2024

    @srprash
    Contributor

    Ran a quick CI with latest version of pynamodb and below is the complete log from https://github.com/aws/aws-xray-sdk-python/actions/runs/9554477432/job/26335605912?pr=437

    2024-06-17T20:44:34.0593304Z py311-ext-pynamodb create: /home/runner/work/aws-xray-sdk-python/aws-xray-sdk-python/.tox/py311-ext-pynamodb
    2024-06-17T20:44:34.3115979Z py311-ext-pynamodb installdeps: pytest > 3.0.0, pytest-benchmark, coverage == 4.5.4, codecov, wrapt, pytest-asyncio == 0.21.2, setuptools, pynamodb >=3.3.1
    2024-06-17T20:44:38.5407472Z py311-ext-pynamodb inst: /home/runner/work/aws-xray-sdk-python/aws-xray-sdk-python/.tox/.tmp/package/1/aws_xray_sdk-2.14.0.zip
    2024-06-17T20:44:40.1294339Z py311-ext-pynamodb installed: aws-xray-sdk @ file:///home/runner/work/aws-xray-sdk-python/aws-xray-sdk-python/.tox/.tmp/package/1/aws_xray_sdk-2.14.0.zip#sha256=274729707a3897ea598f8e728d4498ebd51e54e67882819da1760de706b75633,botocore==1.34.128,certifi==2024.6.2,charset-normalizer==3.3.2,codecov==2.1.13,coverage==4.5.4,idna==3.7,iniconfig==2.0.0,jmespath==1.0.1,packaging==24.1,pluggy==1.5.0,py-cpuinfo==9.0.0,pynamodb==6.0.1,pytest==8.2.2,pytest-asyncio==0.21.2,pytest-benchmark==4.0.0,python-dateutil==2.9.0.post0,requests==2.32.3,six==1.16.0,urllib3==2.2.2,wrapt==1.16.0
    2024-06-17T20:44:40.1300156Z py311-ext-pynamodb run-test-pre: PYTHONHASHSEED='3828464059'
    2024-06-17T20:44:40.1301409Z py311-ext-pynamodb run-test: commands[0] | coverage erase
    2024-06-17T20:44:40.2000254Z py311-ext-pynamodb run-test: commands[1] | coverage run --append --source aws_xray_sdk -m pytest tests/ext/pynamodb
    2024-06-17T20:44:41.5002191Z ============================= test session starts ==============================
    2024-06-17T20:44:41.5003884Z platform linux -- Python 3.11.9, pytest-8.2.2, pluggy-1.5.0
    2024-06-17T20:44:41.5005088Z cachedir: .tox/py311-ext-pynamodb/.pytest_cache
    2024-06-17T20:44:41.5007019Z benchmark: 4.0.0 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
    2024-06-17T20:44:41.5009446Z rootdir: /home/runner/work/aws-xray-sdk-python/aws-xray-sdk-python
    2024-06-17T20:44:41.5010598Z plugins: benchmark-4.0.0, asyncio-0.21.2
    2024-06-17T20:44:41.5011734Z asyncio: mode=Mode.STRICT
    2024-06-17T20:44:41.5012584Z collected 3 items
    2024-06-17T20:44:41.5012924Z 
    2024-06-17T20:44:42.4364136Z tests/ext/pynamodb/test_pynamodb.py F..                                  [100%]
    2024-06-17T20:44:42.4365956Z 
    2024-06-17T20:44:42.4366344Z =================================== FAILURES ===================================
    2024-06-17T20:44:42.4367449Z ________________________________ test_exception ________________________________
    2024-06-17T20:44:42.4368284Z 
    2024-06-17T20:44:42.4368550Z     def test_exception():
    2024-06-17T20:44:42.4369881Z         class SampleModel(Model):
    2024-06-17T20:44:42.4370623Z             class Meta:
    2024-06-17T20:44:42.4371649Z                 region = 'us-west-2'
    2024-06-17T20:44:42.4372468Z                 table_name = 'mytable'
    2024-06-17T20:44:42.4373143Z     
    2024-06-17T20:44:42.4373898Z             sample_attribute = UnicodeAttribute(hash_key=True)
    2024-06-17T20:44:42.4374759Z     
    2024-06-17T20:44:42.4375256Z         try:
    2024-06-17T20:44:42.4375911Z             SampleModel.describe_table()
    2024-06-17T20:44:42.4376657Z         except Exception:
    2024-06-17T20:44:42.4377285Z             pass
    2024-06-17T20:44:42.4377862Z     
    2024-06-17T20:44:42.4378566Z         subsegments = xray_recorder.current_segment().subsegments
    2024-06-17T20:44:42.4380141Z         assert len(subsegments) == 1
    2024-06-17T20:44:42.4381342Z         subsegment = subsegments[0]
    2024-06-17T20:44:42.4382244Z         assert subsegment.name == 'dynamodb'
    2024-06-17T20:44:42.4383146Z >       assert len(subsegment.subsegments) == 0
    2024-06-17T20:44:42.4383996Z E       assert 1 == 0
    2024-06-17T20:44:42.4385104Z E        +  where 1 = len([<aws_xray_sdk.core.models.subsegment.Subsegment object at 0x7f60982e0650>])
    2024-06-17T20:44:42.4387478Z E        +    where [<aws_xray_sdk.core.models.subsegment.Subsegment object at 0x7f60982e0650>] = <aws_xray_sdk.core.models.subsegment.Subsegment object at 0x7f6097380190>.subsegments
    2024-06-17T20:44:42.4426618Z 
    2024-06-17T20:44:42.4427088Z tests/ext/pynamodb/test_pynamodb.py:48: AssertionError
    2024-06-17T20:44:42.4428075Z =========================== short test summary info ============================
    2024-06-17T20:44:42.4429519Z FAILED tests/ext/pynamodb/test_pynamodb.py::test_exception - assert 1 == 0
    2024-06-17T20:44:42.4430801Z ========================= 1 failed, 2 passed in 1.66s ==========================
    2024-06-17T20:44:42.5152963Z ERROR: InvocationError for command /home/runner/work/aws-xray-sdk-python/aws-xray-sdk-python/.tox/py311-ext-pynamodb/bin/coverage run --append --source aws_xray_sdk -m pytest tests/ext/pynamodb (exited with code 1)
    
  3. srprash commented on Jun 17, 2024

    @srprash
    Contributor

    Hi @yan12125 , other than the failing unit test, is there any issue with the instrumentation of pynamodb v6.x that you noticed? If the instrumentation is working, can you attach to this issue, the raw trace data (json) for a sample trace for further analysis?

  4. yan12125 commented on Jun 18, 2024

    @yan12125
    Author

    I don't actually use aws-xray-sdk with pynamodb. I'm the maintainer of python-aws-xray-sdk package in Arch Linux, and tests are run to check compatibility with dependencies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions