Skip to content

Commit 4bfbe2d

Browse files
committed
WL#16283: Remove OpenTelemetry Bundled Installation
This work log removes the bundled opentelemetry SDK/API libraries. Also, a new installation option `telemetry` for the classic connector mysql-connector-python is added. When this option is exercised, the OpenTelemetry API, SDK, and OTLP Exporter packages are installed alongside the connector package. Change-Id: I3584a34d27bc1924ba29f019fd3aaed554be47d9
1 parent c4a828b commit 4bfbe2d

File tree

117 files changed

+92
-18851
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+92
-18851
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ v9.0.0
1212
======
1313

1414
- WL#16350: Update dnspython version
15+
- WL#16283: Remove OpenTelemetry Bundled Installation
1516
- BUG#36476195: Incorrect escaping in pure Python mode if sql_mode includes NO_BACKSLASH_ESCAPES
1617
- BUG#36289767: MySQLCursorBufferedRaw does not skip conversion
1718

README.rst

Lines changed: 71 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,39 +8,86 @@ MySQL Connector/Python
88
.. image:: https://img.shields.io/pypi/l/mysql-connector-python.svg
99
:target: https://pypi.org/project/mysql-connector-python/
1010

11-
MySQL Connector/Python enables Python programs to access MySQL databases, using an API that is compliant with the `Python Database API Specification v2.0 (PEP 249) <https://www.python.org/dev/peps/pep-0249/>`_. It also contains an implementation of the `X DevAPI <https://dev.mysql.com/doc/x-devapi-userguide/en>`_, an Application Programming Interface for working with the `MySQL Document Store <https://dev.mysql.com/doc/refman/8.0/en/document-store.html>`_.
11+
MySQL Connector/Python enables Python programs to access MySQL databases, using
12+
an API that is compliant with the `Python Database API Specification v2.0
13+
(PEP 249) <https://www.python.org/dev/peps/pep-0249/>`_ - We refer to it as the
14+
`Classic API <https://dev.mysql.com/doc/connector-python/en/connector-python-reference.html>`_.
15+
16+
It also contains an implementation of the `XDevAPI <https://dev.mysql.com/doc/x-devapi-userguide/en>`_
17+
- An Application Programming Interface for working with the `MySQL Document Store
18+
<https://dev.mysql.com/doc/refman/8.0/en/document-store.html>`_.
19+
20+
Features
21+
--------
22+
23+
* `Asynchronous Connectivity <https://dev.mysql.com/doc/connector-python/en/connector-python-asyncio.html>`_
24+
* `C-extension <https://dev.mysql.com/doc/connector-python/en/connector-python-cext.html>`_
25+
* `Telemetry <https://dev.mysql.com/doc/connector-python/en/connector-python-opentelemetry.html>`_
26+
* `XDevAPI <https://dev.mysql.com/doc/x-devapi-userguide/en>`_
27+
1228

1329
Installation
1430
------------
31+
1532
The recommended way to install Connector/Python is via `pip <https://pip.pypa.io/>`_.
1633

17-
Make sure you have a recent `pip <https://pip.pypa.io/>`_ version installed on your system. If your system already has ``pip`` installed, you might need to update it. Or you can use the `standalone pip installer <https://pip.pypa.io/en/latest/installing/#installing-with-get-pip-py>`_.
34+
Make sure you have a recent `pip <https://pip.pypa.io/>`_ version installed
35+
on your system. If your system already has ``pip`` installed, you might need
36+
to update it. Or you can use the `standalone pip installer <https://pip.pypa.io/en/latest/installation/>`_.
1837

19-
+++++++
20-
Classic
21-
+++++++
38+
The *classic API* can be installed via pip as follows:
2239

2340
.. code-block:: bash
2441
25-
shell> pip install mysql-connector-python
42+
$ pip install mysql-connector-python
2643
44+
, similarly, the *XDevAPI* can be installed with:
2745

28-
+++++++
29-
XDevAPI
30-
+++++++
46+
.. code-block:: bash
47+
48+
$ pip install mysqlx-connector-python
49+
50+
Please refer to the `installation tutorial <https://dev.mysql.com/doc/dev/connector-python/8.0/installation.html>`_
51+
for installation alternatives of the XDevAPI.
52+
53+
++++++++++++++++++++
54+
Installation Options
55+
++++++++++++++++++++
56+
57+
Connector packages included in MySQL Connector/Python allow you to install
58+
optional dependencies to unleash certain functionalities.
59+
60+
.. code-block:: bash
61+
62+
# 3rd party packages to unleash the telemetry functionality are installed
63+
$ pip install mysql-connector-python[telemetry]
64+
65+
similarly, for the XDevAPI:
3166

3267
.. code-block:: bash
3368
34-
shell> pip install mysqlx-connector-python
69+
# 3rd party packages to unleash the compression functionality are installed
70+
$ pip install mysqlx-connector-python[compression]
71+
72+
This installation option can be seen as a shortcut to install all the
73+
dependencies needed by a particular feature. Mind that this is optional
74+
and you are free to install the required dependencies by yourself.
3575

76+
Options for the Classic connector:
3677

37-
Please refer to the `installation tutorial <https://dev.mysql.com/doc/dev/connector-python/8.0/installation.html>`_ for installation alternatives of the X DevAPI.
78+
* dns-srv
79+
* gssapi
80+
* fido2
81+
* telemetry
3882

83+
Options for the XDevAPI connector:
3984

40-
Getting Started
41-
---------------
85+
* dns-srv
86+
* compression
4287

43-
Using the MySQL classic protocol:
88+
89+
Classic
90+
-------
4491

4592
.. code:: python
4693
@@ -66,7 +113,9 @@ Using the MySQL classic protocol:
66113
# Close connection
67114
cnx.close()
68115
69-
Using the MySQL X DevAPI:
116+
117+
XDevAPI
118+
-------
70119

71120
.. code:: python
72121
@@ -97,8 +146,6 @@ Using the MySQL X DevAPI:
97146
session.close()
98147
99148
100-
Please refer to the `MySQL Connector/Python Developer Guide <https://dev.mysql.com/doc/connector-python/en/>`_ and the `MySQL Connector/Python X DevAPI Reference <https://dev.mysql.com/doc/dev/connector-python/>`_ for a complete usage guide.
101-
102149
Additional Resources
103150
--------------------
104151

@@ -108,14 +155,18 @@ Additional Resources
108155
- `MySQL Public Bug Tracker <https://bugs.mysql.com>`_
109156
- `Slack <https://mysqlcommunity.slack.com>`_ (`Sign-up <https://lefred.be/mysql-community-on-slack/>`_ required if you do not have an Oracle account)
110157
- `Stack Overflow <https://stackoverflow.com/questions/tagged/mysql-connector-python>`_
111-
- `InsideMySQL.com Connectors Blog <https://insidemysql.com/category/mysql-development/connectors/>`_
158+
- `Oracle Blogs <https://blogs.oracle.com/search.html?q=connector-python>`_
159+
112160

113161
Contributing
114162
------------
115163

116-
There are a few ways to contribute to the Connector/Python code. Please refer to the `contributing guidelines <CONTRIBUTING.rst>`_ for additional information.
164+
There are a few ways to contribute to the Connector/Python code. Please refer
165+
to the `contributing guidelines <CONTRIBUTING.rst>`_ for additional information.
166+
117167

118168
License
119169
-------
120170

121-
Please refer to the `README.txt <README.txt>`_ and `LICENSE.txt <LICENSE.txt>`_ files, available in this repository, for further details.
171+
Please refer to the `README.txt <README.txt>`_ and `LICENSE.txt <LICENSE.txt>`_
172+
files, available in this repository, for further details.

mysql-connector-python/cpydist/__init__.py

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -123,31 +123,6 @@
123123
SASL_WIN_LIBS_AUTH_METHODS = ["saslSCRAM.dll", "saslGSSAPI.dll"]
124124

125125

126-
def get_otel_src_package_data():
127-
"""Get a list including all py.typed and dist-info files corresponding
128-
to opentelemetry-python (see [1]) located at
129-
`mysql/opentelemetry`.
130-
131-
Returns:
132-
package_data: List[str].
133-
134-
References:
135-
[1]: https://github.com/open-telemetry/opentelemetry-python
136-
"""
137-
path_otel = os.path.join("lib", "mysql", "opentelemetry")
138-
139-
package_data = []
140-
for root, dirs, filenames in os.walk(os.path.join(os.getcwd(), path_otel, "")):
141-
offset = root.replace(os.path.join(os.getcwd(), path_otel, ""), "")
142-
for _dir in dirs:
143-
if _dir.endswith(".dist-info"):
144-
package_data.append(os.path.join(offset, _dir, "*"))
145-
for filename in filenames:
146-
if filename == "py.typed":
147-
package_data.append(os.path.join(offset, filename))
148-
return package_data
149-
150-
151126
class BaseCommand(Command):
152127
"""Base command class for Connector/Python."""
153128

@@ -232,10 +207,7 @@ def finalize_options(self):
232207
install.extra_link_args = self.extra_link_args
233208
install.skip_vendor = self.skip_vendor
234209

235-
self.distribution.package_data = {
236-
"mysql.connector": ["py.typed"],
237-
"mysql.opentelemetry": get_otel_src_package_data(),
238-
}
210+
self.distribution.package_data = {"mysql.connector": ["py.typed"]}
239211
if not cmd_build_ext.skip_vendor:
240212
self._copy_vendor_libraries()
241213

@@ -561,7 +533,6 @@ def _copy_vendor_libraries(self):
561533
"vendor/private/sasl2/*",
562534
],
563535
"mysql.connector": ["py.typed"],
564-
"mysql.opentelemetry": get_otel_src_package_data(),
565536
}
566537

567538

mysql-connector-python/lib/mysql/connector/opentelemetry/constants.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,7 @@
3737
from opentelemetry.sdk.trace import TracerProvider # check sdk
3838
from opentelemetry.semconv.trace import SpanAttributes # check semconv
3939
except ImportError:
40-
# falling back to the bundled installation
41-
try:
42-
from mysql.opentelemetry import trace
43-
from mysql.opentelemetry.sdk.trace import TracerProvider
44-
from mysql.opentelemetry.semconv.trace import SpanAttributes
45-
except ImportError:
46-
# bundled installation has missing dependencies
47-
OTEL_ENABLED = False
40+
OTEL_ENABLED = False
4841

4942

5043
OPTION_CNX_SPAN = "_span"

mysql-connector-python/lib/mysql/connector/opentelemetry/context_propagation.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,10 @@
3535
from .constants import OTEL_ENABLED, TRACEPARENT_HEADER_NAME
3636

3737
if OTEL_ENABLED:
38-
from .instrumentation import OTEL_SYSTEM_AVAILABLE
39-
40-
if OTEL_SYSTEM_AVAILABLE:
41-
# pylint: disable=import-error
42-
# load otel from the system
43-
from opentelemetry import trace
44-
from opentelemetry.trace.span import format_span_id, format_trace_id
45-
else:
46-
# load otel from the bundled installation
47-
from mysql.opentelemetry import trace
48-
from mysql.opentelemetry.trace.span import format_span_id, format_trace_id
38+
# pylint: disable=import-error
39+
# load otel from the system
40+
from opentelemetry import trace
41+
from opentelemetry.trace.span import format_span_id, format_trace_id
4942

5043

5144
if TYPE_CHECKING:

mysql-connector-python/lib/mysql/connector/opentelemetry/instrumentation.py

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -61,22 +61,10 @@
6161
from opentelemetry import trace # check api
6262
from opentelemetry.sdk.trace import TracerProvider # check sdk
6363
from opentelemetry.semconv.trace import SpanAttributes # check semconv
64-
65-
OTEL_SYSTEM_AVAILABLE = True
66-
except ImportError:
67-
try:
68-
# falling back to the bundled installation
69-
from mysql.opentelemetry import trace
70-
from mysql.opentelemetry.semconv.trace import SpanAttributes
71-
72-
OTEL_SYSTEM_AVAILABLE = False
73-
except ImportError as missing_dependencies_err:
74-
raise connector.errors.ProgrammingError(
75-
"Bundled installation has missing dependencies. "
76-
"Please use `pip install mysql-connector-python[opentelemetry]`, "
77-
"or for an editable install use `pip install -e '.[opentelemetry]'`, "
78-
"to install the dependencies required by the bundled opentelemetry package."
79-
) from missing_dependencies_err
64+
except ImportError as missing_dependencies_err:
65+
raise connector.errors.ProgrammingError(
66+
"OpenTelemetry installation not found. " "You must install the API and SDK."
67+
) from missing_dependencies_err
8068

8169

8270
from .constants import (

mysql-connector-python/lib/mysql/opentelemetry/__init__.py

Whitespace-only changes.

mysql-connector-python/lib/mysql/opentelemetry/_dist_info/opentelemetry_api-1.18.0.dist-info/INSTALLER

Lines changed: 0 additions & 1 deletion
This file was deleted.

mysql-connector-python/lib/mysql/opentelemetry/_dist_info/opentelemetry_api-1.18.0.dist-info/METADATA

Lines changed: 0 additions & 45 deletions
This file was deleted.

mysql-connector-python/lib/mysql/opentelemetry/_dist_info/opentelemetry_api-1.18.0.dist-info/RECORD

Lines changed: 0 additions & 63 deletions
This file was deleted.

mysql-connector-python/lib/mysql/opentelemetry/_dist_info/opentelemetry_api-1.18.0.dist-info/WHEEL

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)