Skip to content

Flaky pymongo-newest test in CI #2629

@xrmx

Description

@xrmx
______________ test_mongodb_span_compression[elasticapm_client0] _______________

instrument = None
elasticapm_client = <tests.fixtures.TempStoreClient object at 0x7f17501ea7a0>
mongo_database = Database(MongoClient(host=['mongodb42:27017'], document_class=dict, tz_aware=False, connect=True), 'elasticapm_test')

    @pytest.mark.skipif(pymongo.version_tuple < (3, 7), reason="New in 3.7")
    @pytest.mark.parametrize(
        "elasticapm_client",
        [
            {
                "span_compression_enabled": True,
                "span_compression_same_kind_max_duration": "5ms",
                "span_compression_exact_match_max_duration": "50ms",
            }
        ],
        indirect=True,
    )
    @pytest.mark.integrationtest
    def test_mongodb_span_compression(instrument, elasticapm_client, mongo_database):
        elasticapm_client.begin_transaction("transaction.test")
        for i in range(5):
            blogpost = {"author": "Tom%d" % i, "text": "Foo", "date": datetime.datetime.utcnow()}
            mongo_database.blogposts.insert_one(blogpost)
        elasticapm_client.end_transaction("transaction.test")
        transactions = elasticapm_client.events[TRANSACTION]
        spans = elasticapm_client.spans_for_transaction(transactions[0])
>       assert len(spans) == 1
E       AssertionError: assert 2 == 1
E        +  where 2 = len([{'action': 'query', 'context': {'db': {'instance': 'elasticapm_test'}, 'destination': {'address': 'mongodb42', 'port': 27017, 'service': {'name': '', 'resource': 'mongodb/elasticapm_test', 'type': ''}}, 'service': {'target': {'name': 'elasticapm_test', 'type': 'mongodb'}}}, 'duration': 390.739, 'id': '9fd40815fe302473', ...}, {'action': 'query', 'composite': {'compression_strategy': 'exact_match', 'count': 4, 'sum': 1.9680000000000002}, 'context': {'db': {'instance': 'elasticapm_test'}, 'destination': {'address': 'mongodb42', 'port': 27017, 'service': {'name': '', 'resource': 'mongodb/elasticapm_test', 'type': ''}}, 'service': {'target': {'name': 'elasticapm_test', 'type': 'mongodb'}}}, 'duration': 6.901, ...}])

blogpost   = {'_id': ObjectId('69f2c893b1385626b2c62745'), 'author': 'Tom4', 'date': datetime.datetime(2026, 4, 30, 3, 12, 19, 196682), 'text': 'Foo'}
elasticapm_client = <tests.fixtures.TempStoreClient object at 0x7f17501ea7a0>
i          = 4
instrument = None
mongo_database = Database(MongoClient(host=['mongodb42:27017'], document_class=dict, tz_aware=False, connect=True), 'elasticapm_test')
spans      = [{'action': 'query', 'context': {'db': {'instance': 'elasticapm_test'}, 'destination': {'address': 'mongodb42', 'port'...m_test', 'type': ''}}, 'service': {'target': {'name': 'elasticapm_test', 'type': 'mongodb'}}}, 'duration': 6.901, ...}]
transactions = [{'context': {'tags': {}}, 'duration': 398.54699999999997, 'id': '8d6a1f383ea2271f', 'name': 'transaction.test', ...}]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions