pymongo instrumentation: Invalid COLLECTION_METHODS_V3 names

Open
#791 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
observability

Research direction

Start in src/scout_apm/instruments/pymongo.py at ensure_installed, using the listed Collection method names and the example AttributeError as the reproduction signal. Check the instrumentation behavior across the stated pymongo versions, then confirm that old versions no longer produce warnings while supported versions retain the relevant instrumentation.

Written by the indexing model from the issue text.

Description

The pymongo instrumentation generates some harmless-but-noisy logs for versions 3.0.0 - 4.5. There are several method names that get added to the methods we assume will be on pymongo Collections that are not valid until at least version 4.5 AFAICT. It is possible that they existed earlier and were removed for a stretch of releases.

    "drop_search_index",
    "create_search_indexes",
    "create_search_index",
    "list_search_indexes",
    "update_search_index",

These should be removed from pymongo < 4.5 instrumentation attempts.

Example log record:

WARNING:scout_apm.instruments.pymongo:Failed to instrument pymongo.Collection.create_search_indexes: AttributeError("type object 'Collection' has no attribute 'create_search_indexes'")
Traceback (most recent call last):
  File "/.../scout_apm_python/src/scout_apm/instruments/pymongo.py", line 39, in ensure_installed
    Collection, name, wrap_collection_method(getattr(Collection, name))
                                             ^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: type object 'Collection' has no attribute 'create_search_indexes'
Dominant language
Python
Stars
77
Forks
19
Avg merge
1d 9h
Merged PRs (30d)
5

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from scoutapp/scout_apm_python

All issues in scoutapp/scout_apm_python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.