open-telemetry / opentelemetry-python-contrib

OpenTelemetry instrumentation for Python modules
https://opentelemetry.io
Apache License 2.0
739 stars 612 forks source link

Stop TestBase DeprecationWarnings from instrumentor test span info checks #3033

Closed tammy-baylis-swi closed 6 hours ago

tammy-baylis-swi commented 1 day ago

Describe your environment

OS: Ubuntu Python version: Python 3.12.5 Package version: 0.50b0.dev (local) SDK version: 1.29.0.dev (local) API version: 1.29.0.dev (local)

What happened?

Several instrumentor tests are using core util assertEqualSpanInstrumentationInfo and this results in deprecation warnings, e.g.

instrumentation/opentelemetry-instrumentation-mysqlclient/tests/test_mysqlclient_integration.py::TestMySQLClientIntegration::test_instrumentor
  /Users/tammy/opentelemetry-python-contrib/.tox/py312-test-instrumentation-mysqlclient/lib/python3.12/site-packages/opentelemetry/test/test_base.py:74: DeprecationWarning: Call to deprecated function (or staticmethod) instrumentation_info. (You should use instrumentation_scope) -- Deprecated since version 1.11.1.
    self.assertEqual(span.instrumentation_info.name, module.__name__)

instrumentation/opentelemetry-instrumentation-mysqlclient/tests/test_mysqlclient_integration.py::TestMySQLClientIntegration::test_instrumentor
  /Users/tammy/opentelemetry-python-contrib/.tox/py312-test-instrumentation-mysqlclient/lib/python3.12/site-packages/opentelemetry/test/test_base.py:75: DeprecationWarning: Call to deprecated function (or staticmethod) instrumentation_info. (You should use instrumentation_scope) -- Deprecated since version 1.11.1.
    self.assertEqual(span.instrumentation_info.version, module.__version__)

I think they should all switch to using assertEqualSpanInstrumentationScope.

Steps to Reproduce

  1. Checkout the contrib repo at main.
  2. Run any instrumentor unit tests that call assertEqualSpanInstrumentationInfo, e.g. tox -e py312-test-instrumentation-mysqlclient.
  3. Check tox output for warnings.

Expected Result

No Deprecation warnings.

Actual Result

DeprecationWarning as described above.

Additional context

No response

Would you like to implement a fix?

Yes