opentelemetry-instrumentation 0.51b0__tar.gz → 0.52b1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. {opentelemetry_instrumentation-0.51b0 → opentelemetry_instrumentation-0.52b1}/PKG-INFO +15 -2
  2. {opentelemetry_instrumentation-0.51b0 → opentelemetry_instrumentation-0.52b1}/README.rst +13 -0
  3. {opentelemetry_instrumentation-0.51b0 → opentelemetry_instrumentation-0.52b1}/pyproject.toml +1 -1
  4. {opentelemetry_instrumentation-0.51b0 → opentelemetry_instrumentation-0.52b1}/src/opentelemetry/instrumentation/auto_instrumentation/__init__.py +23 -0
  5. opentelemetry_instrumentation-0.52b1/src/opentelemetry/instrumentation/auto_instrumentation/sitecustomize.py +17 -0
  6. {opentelemetry_instrumentation-0.51b0 → opentelemetry_instrumentation-0.52b1}/src/opentelemetry/instrumentation/bootstrap_gen.py +56 -56
  7. {opentelemetry_instrumentation-0.51b0 → opentelemetry_instrumentation-0.52b1}/src/opentelemetry/instrumentation/version.py +1 -1
  8. opentelemetry_instrumentation-0.52b1/tests/auto_instrumentation/test_initialize.py +61 -0
  9. opentelemetry_instrumentation-0.52b1/tests/auto_instrumentation/test_sitecustomize.py +28 -0
  10. opentelemetry_instrumentation-0.51b0/src/opentelemetry/instrumentation/auto_instrumentation/sitecustomize.py +0 -44
  11. {opentelemetry_instrumentation-0.51b0 → opentelemetry_instrumentation-0.52b1}/.gitignore +0 -0
  12. {opentelemetry_instrumentation-0.51b0 → opentelemetry_instrumentation-0.52b1}/LICENSE +0 -0
  13. {opentelemetry_instrumentation-0.51b0 → opentelemetry_instrumentation-0.52b1}/src/opentelemetry/instrumentation/_semconv.py +0 -0
  14. {opentelemetry_instrumentation-0.51b0 → opentelemetry_instrumentation-0.52b1}/src/opentelemetry/instrumentation/auto_instrumentation/_load.py +0 -0
  15. {opentelemetry_instrumentation-0.51b0 → opentelemetry_instrumentation-0.52b1}/src/opentelemetry/instrumentation/bootstrap.py +0 -0
  16. {opentelemetry_instrumentation-0.51b0 → opentelemetry_instrumentation-0.52b1}/src/opentelemetry/instrumentation/dependencies.py +0 -0
  17. {opentelemetry_instrumentation-0.51b0 → opentelemetry_instrumentation-0.52b1}/src/opentelemetry/instrumentation/distro.py +0 -0
  18. {opentelemetry_instrumentation-0.51b0 → opentelemetry_instrumentation-0.52b1}/src/opentelemetry/instrumentation/environment_variables.py +0 -0
  19. {opentelemetry_instrumentation-0.51b0 → opentelemetry_instrumentation-0.52b1}/src/opentelemetry/instrumentation/instrumentor.py +0 -0
  20. {opentelemetry_instrumentation-0.51b0 → opentelemetry_instrumentation-0.52b1}/src/opentelemetry/instrumentation/propagators.py +0 -0
  21. {opentelemetry_instrumentation-0.51b0 → opentelemetry_instrumentation-0.52b1}/src/opentelemetry/instrumentation/py.typed +0 -0
  22. {opentelemetry_instrumentation-0.51b0 → opentelemetry_instrumentation-0.52b1}/src/opentelemetry/instrumentation/sqlcommenter_utils.py +0 -0
  23. {opentelemetry_instrumentation-0.51b0 → opentelemetry_instrumentation-0.52b1}/src/opentelemetry/instrumentation/utils.py +0 -0
  24. {opentelemetry_instrumentation-0.51b0 → opentelemetry_instrumentation-0.52b1}/tests/__init__.py +0 -0
  25. {opentelemetry_instrumentation-0.51b0 → opentelemetry_instrumentation-0.52b1}/tests/auto_instrumentation/test_load.py +0 -0
  26. {opentelemetry_instrumentation-0.51b0 → opentelemetry_instrumentation-0.52b1}/tests/auto_instrumentation/test_run.py +0 -0
  27. {opentelemetry_instrumentation-0.51b0 → opentelemetry_instrumentation-0.52b1}/tests/test_bootstrap.py +0 -0
  28. {opentelemetry_instrumentation-0.51b0 → opentelemetry_instrumentation-0.52b1}/tests/test_dependencies.py +0 -0
  29. {opentelemetry_instrumentation-0.51b0 → opentelemetry_instrumentation-0.52b1}/tests/test_distro.py +0 -0
  30. {opentelemetry_instrumentation-0.51b0 → opentelemetry_instrumentation-0.52b1}/tests/test_instrumentor.py +0 -0
  31. {opentelemetry_instrumentation-0.51b0 → opentelemetry_instrumentation-0.52b1}/tests/test_propagators.py +0 -0
  32. {opentelemetry_instrumentation-0.51b0 → opentelemetry_instrumentation-0.52b1}/tests/test_semconv.py +0 -0
  33. {opentelemetry_instrumentation-0.51b0 → opentelemetry_instrumentation-0.52b1}/tests/test_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: opentelemetry-instrumentation
3
- Version: 0.51b0
3
+ Version: 0.52b1
4
4
  Summary: Instrumentation Tools & Auto Instrumentation for OpenTelemetry Python
5
5
  Project-URL: Homepage, https://github.com/open-telemetry/opentelemetry-python-contrib/tree/main/opentelemetry-instrumentation
6
6
  Project-URL: Repository, https://github.com/open-telemetry/opentelemetry-python-contrib
@@ -20,7 +20,7 @@ Classifier: Programming Language :: Python :: 3.12
20
20
  Classifier: Programming Language :: Python :: 3.13
21
21
  Requires-Python: >=3.8
22
22
  Requires-Dist: opentelemetry-api~=1.4
23
- Requires-Dist: opentelemetry-semantic-conventions==0.51b0
23
+ Requires-Dist: opentelemetry-semantic-conventions==0.52b1
24
24
  Requires-Dist: packaging>=18.0
25
25
  Requires-Dist: wrapt<2.0.0,>=1.0.0
26
26
  Description-Content-Type: text/x-rst
@@ -157,6 +157,19 @@ start celery with the rest of the arguments.
157
157
  The above command will configure the global trace provider to use the Random IDs Generator, and then
158
158
  pass ``--port=3000`` to ``flask run``.
159
159
 
160
+ Programmatic Auto-instrumentation
161
+ ---------------------------------
162
+
163
+ ::
164
+
165
+ from opentelemetry.instrumentation import auto_instrumentation
166
+ auto_instrumentation.initialize()
167
+
168
+
169
+ If you are in an environment where you cannot use opentelemetry-instrument to inject auto-instrumentation you can do so programmatically with
170
+ the code above. Please note that some instrumentations may require the ``initialize()`` method to be called before the library they
171
+ instrument is imported.
172
+
160
173
  References
161
174
  ----------
162
175
 
@@ -130,6 +130,19 @@ start celery with the rest of the arguments.
130
130
  The above command will configure the global trace provider to use the Random IDs Generator, and then
131
131
  pass ``--port=3000`` to ``flask run``.
132
132
 
133
+ Programmatic Auto-instrumentation
134
+ ---------------------------------
135
+
136
+ ::
137
+
138
+ from opentelemetry.instrumentation import auto_instrumentation
139
+ auto_instrumentation.initialize()
140
+
141
+
142
+ If you are in an environment where you cannot use opentelemetry-instrument to inject auto-instrumentation you can do so programmatically with
143
+ the code above. Please note that some instrumentations may require the ``initialize()`` method to be called before the library they
144
+ instrument is imported.
145
+
133
146
  References
134
147
  ----------
135
148
 
@@ -27,7 +27,7 @@ classifiers = [
27
27
  ]
28
28
  dependencies = [
29
29
  "opentelemetry-api ~= 1.4",
30
- "opentelemetry-semantic-conventions == 0.51b0",
30
+ "opentelemetry-semantic-conventions == 0.52b1",
31
31
  "wrapt >= 1.0.0, < 2.0.0",
32
32
  "packaging >= 18.0",
33
33
  ]
@@ -19,6 +19,12 @@ from os.path import abspath, dirname, pathsep
19
19
  from re import sub
20
20
  from shutil import which
21
21
 
22
+ from opentelemetry.instrumentation.auto_instrumentation._load import (
23
+ _load_configurators,
24
+ _load_distro,
25
+ _load_instrumentors,
26
+ )
27
+ from opentelemetry.instrumentation.utils import _python_path_without_directory
22
28
  from opentelemetry.instrumentation.version import __version__
23
29
  from opentelemetry.util._importlib_metadata import entry_points
24
30
 
@@ -110,3 +116,20 @@ def run() -> None:
110
116
 
111
117
  executable = which(args.command)
112
118
  execl(executable, executable, *args.command_args)
119
+
120
+
121
+ def initialize():
122
+ """Setup auto-instrumentation, called by the sitecustomize module"""
123
+ # prevents auto-instrumentation of subprocesses if code execs another python process
124
+ if "PYTHONPATH" in environ:
125
+ environ["PYTHONPATH"] = _python_path_without_directory(
126
+ environ["PYTHONPATH"], dirname(abspath(__file__)), pathsep
127
+ )
128
+
129
+ try:
130
+ distro = _load_distro()
131
+ distro.configure()
132
+ _load_configurators()
133
+ _load_instrumentors(distro)
134
+ except Exception: # pylint: disable=broad-except
135
+ _logger.exception("Failed to auto initialize OpenTelemetry")
@@ -0,0 +1,17 @@
1
+ # Copyright The OpenTelemetry Authors
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ from opentelemetry.instrumentation.auto_instrumentation import initialize
16
+
17
+ initialize()
@@ -18,203 +18,203 @@
18
18
  libraries = [
19
19
  {
20
20
  "library": "openai >= 1.26.0",
21
- "instrumentation": "opentelemetry-instrumentation-openai-v2==2.2b0.dev",
21
+ "instrumentation": "opentelemetry-instrumentation-openai-v2",
22
22
  },
23
23
  {
24
24
  "library": "google-cloud-aiplatform >= 1.64",
25
- "instrumentation": "opentelemetry-instrumentation-vertexai==2.1b0.dev",
25
+ "instrumentation": "opentelemetry-instrumentation-vertexai>=2.0b0",
26
26
  },
27
27
  {
28
28
  "library": "aio_pika >= 7.2.0, < 10.0.0",
29
- "instrumentation": "opentelemetry-instrumentation-aio-pika==0.51b0",
29
+ "instrumentation": "opentelemetry-instrumentation-aio-pika==0.52b1",
30
30
  },
31
31
  {
32
32
  "library": "aiohttp ~= 3.0",
33
- "instrumentation": "opentelemetry-instrumentation-aiohttp-client==0.51b0",
33
+ "instrumentation": "opentelemetry-instrumentation-aiohttp-client==0.52b1",
34
34
  },
35
35
  {
36
36
  "library": "aiohttp ~= 3.0",
37
- "instrumentation": "opentelemetry-instrumentation-aiohttp-server==0.51b0",
37
+ "instrumentation": "opentelemetry-instrumentation-aiohttp-server==0.52b1",
38
38
  },
39
39
  {
40
40
  "library": "aiokafka >= 0.8, < 1.0",
41
- "instrumentation": "opentelemetry-instrumentation-aiokafka==0.51b0",
41
+ "instrumentation": "opentelemetry-instrumentation-aiokafka==0.52b1",
42
42
  },
43
43
  {
44
44
  "library": "aiopg >= 0.13.0, < 2.0.0",
45
- "instrumentation": "opentelemetry-instrumentation-aiopg==0.51b0",
45
+ "instrumentation": "opentelemetry-instrumentation-aiopg==0.52b1",
46
46
  },
47
47
  {
48
48
  "library": "asgiref ~= 3.0",
49
- "instrumentation": "opentelemetry-instrumentation-asgi==0.51b0",
49
+ "instrumentation": "opentelemetry-instrumentation-asgi==0.52b1",
50
50
  },
51
51
  {
52
52
  "library": "asyncpg >= 0.12.0",
53
- "instrumentation": "opentelemetry-instrumentation-asyncpg==0.51b0",
53
+ "instrumentation": "opentelemetry-instrumentation-asyncpg==0.52b1",
54
54
  },
55
55
  {
56
56
  "library": "boto~=2.0",
57
- "instrumentation": "opentelemetry-instrumentation-boto==0.51b0",
57
+ "instrumentation": "opentelemetry-instrumentation-boto==0.52b1",
58
58
  },
59
59
  {
60
60
  "library": "boto3 ~= 1.0",
61
- "instrumentation": "opentelemetry-instrumentation-boto3sqs==0.51b0",
61
+ "instrumentation": "opentelemetry-instrumentation-boto3sqs==0.52b1",
62
62
  },
63
63
  {
64
64
  "library": "botocore ~= 1.0",
65
- "instrumentation": "opentelemetry-instrumentation-botocore==0.51b0",
65
+ "instrumentation": "opentelemetry-instrumentation-botocore==0.52b1",
66
66
  },
67
67
  {
68
68
  "library": "cassandra-driver ~= 3.25",
69
- "instrumentation": "opentelemetry-instrumentation-cassandra==0.51b0",
69
+ "instrumentation": "opentelemetry-instrumentation-cassandra==0.52b1",
70
70
  },
71
71
  {
72
72
  "library": "scylla-driver ~= 3.25",
73
- "instrumentation": "opentelemetry-instrumentation-cassandra==0.51b0",
73
+ "instrumentation": "opentelemetry-instrumentation-cassandra==0.52b1",
74
74
  },
75
75
  {
76
76
  "library": "celery >= 4.0, < 6.0",
77
- "instrumentation": "opentelemetry-instrumentation-celery==0.51b0",
77
+ "instrumentation": "opentelemetry-instrumentation-celery==0.52b1",
78
78
  },
79
79
  {
80
80
  "library": "click >= 8.1.3, < 9.0.0",
81
- "instrumentation": "opentelemetry-instrumentation-click==0.51b0",
81
+ "instrumentation": "opentelemetry-instrumentation-click==0.52b1",
82
82
  },
83
83
  {
84
84
  "library": "confluent-kafka >= 1.8.2, <= 2.7.0",
85
- "instrumentation": "opentelemetry-instrumentation-confluent-kafka==0.51b0",
85
+ "instrumentation": "opentelemetry-instrumentation-confluent-kafka==0.52b1",
86
86
  },
87
87
  {
88
88
  "library": "django >= 1.10",
89
- "instrumentation": "opentelemetry-instrumentation-django==0.51b0",
89
+ "instrumentation": "opentelemetry-instrumentation-django==0.52b1",
90
90
  },
91
91
  {
92
92
  "library": "elasticsearch >= 6.0",
93
- "instrumentation": "opentelemetry-instrumentation-elasticsearch==0.51b0",
93
+ "instrumentation": "opentelemetry-instrumentation-elasticsearch==0.52b1",
94
94
  },
95
95
  {
96
96
  "library": "falcon >= 1.4.1, < 5.0.0",
97
- "instrumentation": "opentelemetry-instrumentation-falcon==0.51b0",
97
+ "instrumentation": "opentelemetry-instrumentation-falcon==0.52b1",
98
98
  },
99
99
  {
100
100
  "library": "fastapi ~= 0.58",
101
- "instrumentation": "opentelemetry-instrumentation-fastapi==0.51b0",
101
+ "instrumentation": "opentelemetry-instrumentation-fastapi==0.52b1",
102
102
  },
103
103
  {
104
104
  "library": "flask >= 1.0",
105
- "instrumentation": "opentelemetry-instrumentation-flask==0.51b0",
105
+ "instrumentation": "opentelemetry-instrumentation-flask==0.52b1",
106
106
  },
107
107
  {
108
108
  "library": "grpcio >= 1.42.0",
109
- "instrumentation": "opentelemetry-instrumentation-grpc==0.51b0",
109
+ "instrumentation": "opentelemetry-instrumentation-grpc==0.52b1",
110
110
  },
111
111
  {
112
112
  "library": "httpx >= 0.18.0",
113
- "instrumentation": "opentelemetry-instrumentation-httpx==0.51b0",
113
+ "instrumentation": "opentelemetry-instrumentation-httpx==0.52b1",
114
114
  },
115
115
  {
116
116
  "library": "jinja2 >= 2.7, < 4.0",
117
- "instrumentation": "opentelemetry-instrumentation-jinja2==0.51b0",
117
+ "instrumentation": "opentelemetry-instrumentation-jinja2==0.52b1",
118
118
  },
119
119
  {
120
120
  "library": "kafka-python >= 2.0, < 3.0",
121
- "instrumentation": "opentelemetry-instrumentation-kafka-python==0.51b0",
121
+ "instrumentation": "opentelemetry-instrumentation-kafka-python==0.52b1",
122
122
  },
123
123
  {
124
124
  "library": "kafka-python-ng >= 2.0, < 3.0",
125
- "instrumentation": "opentelemetry-instrumentation-kafka-python==0.51b0",
125
+ "instrumentation": "opentelemetry-instrumentation-kafka-python==0.52b1",
126
126
  },
127
127
  {
128
128
  "library": "mysql-connector-python >= 8.0, < 10.0",
129
- "instrumentation": "opentelemetry-instrumentation-mysql==0.51b0",
129
+ "instrumentation": "opentelemetry-instrumentation-mysql==0.52b1",
130
130
  },
131
131
  {
132
132
  "library": "mysqlclient < 3",
133
- "instrumentation": "opentelemetry-instrumentation-mysqlclient==0.51b0",
133
+ "instrumentation": "opentelemetry-instrumentation-mysqlclient==0.52b1",
134
134
  },
135
135
  {
136
136
  "library": "pika >= 0.12.0",
137
- "instrumentation": "opentelemetry-instrumentation-pika==0.51b0",
137
+ "instrumentation": "opentelemetry-instrumentation-pika==0.52b1",
138
138
  },
139
139
  {
140
140
  "library": "psycopg >= 3.1.0",
141
- "instrumentation": "opentelemetry-instrumentation-psycopg==0.51b0",
141
+ "instrumentation": "opentelemetry-instrumentation-psycopg==0.52b1",
142
142
  },
143
143
  {
144
144
  "library": "psycopg2 >= 2.7.3.1",
145
- "instrumentation": "opentelemetry-instrumentation-psycopg2==0.51b0",
145
+ "instrumentation": "opentelemetry-instrumentation-psycopg2==0.52b1",
146
146
  },
147
147
  {
148
148
  "library": "psycopg2-binary >= 2.7.3.1",
149
- "instrumentation": "opentelemetry-instrumentation-psycopg2==0.51b0",
149
+ "instrumentation": "opentelemetry-instrumentation-psycopg2==0.52b1",
150
150
  },
151
151
  {
152
152
  "library": "pymemcache >= 1.3.5, < 5",
153
- "instrumentation": "opentelemetry-instrumentation-pymemcache==0.51b0",
153
+ "instrumentation": "opentelemetry-instrumentation-pymemcache==0.52b1",
154
154
  },
155
155
  {
156
156
  "library": "pymongo >= 3.1, < 5.0",
157
- "instrumentation": "opentelemetry-instrumentation-pymongo==0.51b0",
157
+ "instrumentation": "opentelemetry-instrumentation-pymongo==0.52b1",
158
158
  },
159
159
  {
160
160
  "library": "pymssql >= 2.1.5, < 3",
161
- "instrumentation": "opentelemetry-instrumentation-pymssql==0.51b0",
161
+ "instrumentation": "opentelemetry-instrumentation-pymssql==0.52b1",
162
162
  },
163
163
  {
164
164
  "library": "PyMySQL < 2",
165
- "instrumentation": "opentelemetry-instrumentation-pymysql==0.51b0",
165
+ "instrumentation": "opentelemetry-instrumentation-pymysql==0.52b1",
166
166
  },
167
167
  {
168
168
  "library": "pyramid >= 1.7",
169
- "instrumentation": "opentelemetry-instrumentation-pyramid==0.51b0",
169
+ "instrumentation": "opentelemetry-instrumentation-pyramid==0.52b1",
170
170
  },
171
171
  {
172
172
  "library": "redis >= 2.6",
173
- "instrumentation": "opentelemetry-instrumentation-redis==0.51b0",
173
+ "instrumentation": "opentelemetry-instrumentation-redis==0.52b1",
174
174
  },
175
175
  {
176
176
  "library": "remoulade >= 0.50",
177
- "instrumentation": "opentelemetry-instrumentation-remoulade==0.51b0",
177
+ "instrumentation": "opentelemetry-instrumentation-remoulade==0.52b1",
178
178
  },
179
179
  {
180
180
  "library": "requests ~= 2.0",
181
- "instrumentation": "opentelemetry-instrumentation-requests==0.51b0",
181
+ "instrumentation": "opentelemetry-instrumentation-requests==0.52b1",
182
182
  },
183
183
  {
184
184
  "library": "sqlalchemy >= 1.0.0, < 2.1.0",
185
- "instrumentation": "opentelemetry-instrumentation-sqlalchemy==0.51b0",
185
+ "instrumentation": "opentelemetry-instrumentation-sqlalchemy==0.52b1",
186
186
  },
187
187
  {
188
- "library": "starlette ~= 0.13.0",
189
- "instrumentation": "opentelemetry-instrumentation-starlette==0.51b0",
188
+ "library": "starlette >= 0.13, <0.15",
189
+ "instrumentation": "opentelemetry-instrumentation-starlette==0.52b1",
190
190
  },
191
191
  {
192
192
  "library": "psutil >= 5",
193
- "instrumentation": "opentelemetry-instrumentation-system-metrics==0.51b0",
193
+ "instrumentation": "opentelemetry-instrumentation-system-metrics==0.52b1",
194
194
  },
195
195
  {
196
196
  "library": "tornado >= 5.1.1",
197
- "instrumentation": "opentelemetry-instrumentation-tornado==0.51b0",
197
+ "instrumentation": "opentelemetry-instrumentation-tornado==0.52b1",
198
198
  },
199
199
  {
200
200
  "library": "tortoise-orm >= 0.17.0",
201
- "instrumentation": "opentelemetry-instrumentation-tortoiseorm==0.51b0",
201
+ "instrumentation": "opentelemetry-instrumentation-tortoiseorm==0.52b1",
202
202
  },
203
203
  {
204
204
  "library": "pydantic >= 1.10.2",
205
- "instrumentation": "opentelemetry-instrumentation-tortoiseorm==0.51b0",
205
+ "instrumentation": "opentelemetry-instrumentation-tortoiseorm==0.52b1",
206
206
  },
207
207
  {
208
208
  "library": "urllib3 >= 1.0.0, < 3.0.0",
209
- "instrumentation": "opentelemetry-instrumentation-urllib3==0.51b0",
209
+ "instrumentation": "opentelemetry-instrumentation-urllib3==0.52b1",
210
210
  },
211
211
  ]
212
212
  default_instrumentations = [
213
- "opentelemetry-instrumentation-asyncio==0.51b0",
214
- "opentelemetry-instrumentation-dbapi==0.51b0",
215
- "opentelemetry-instrumentation-logging==0.51b0",
216
- "opentelemetry-instrumentation-sqlite3==0.51b0",
217
- "opentelemetry-instrumentation-threading==0.51b0",
218
- "opentelemetry-instrumentation-urllib==0.51b0",
219
- "opentelemetry-instrumentation-wsgi==0.51b0",
213
+ "opentelemetry-instrumentation-asyncio==0.52b1",
214
+ "opentelemetry-instrumentation-dbapi==0.52b1",
215
+ "opentelemetry-instrumentation-logging==0.52b1",
216
+ "opentelemetry-instrumentation-sqlite3==0.52b1",
217
+ "opentelemetry-instrumentation-threading==0.52b1",
218
+ "opentelemetry-instrumentation-urllib==0.52b1",
219
+ "opentelemetry-instrumentation-wsgi==0.52b1",
220
220
  ]
@@ -12,4 +12,4 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- __version__ = "0.51b0"
15
+ __version__ = "0.52b1"
@@ -0,0 +1,61 @@
1
+ # Copyright The OpenTelemetry Authors
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ # type: ignore
15
+
16
+ from os import environ
17
+ from os.path import abspath, dirname, pathsep
18
+ from unittest import TestCase
19
+ from unittest.mock import patch
20
+
21
+ from opentelemetry.instrumentation import auto_instrumentation
22
+
23
+ # TODO: convert to assertNoLogs instead of mocking logger when 3.10 is baseline
24
+
25
+
26
+ class TestInitialize(TestCase):
27
+ auto_instrumentation_path = dirname(abspath(auto_instrumentation.__file__))
28
+
29
+ @patch.dict("os.environ", {}, clear=True)
30
+ @patch("opentelemetry.instrumentation.auto_instrumentation._logger")
31
+ def test_handles_pythonpath_not_set(self, logger_mock):
32
+ auto_instrumentation.initialize()
33
+ self.assertNotIn("PYTHONPATH", environ)
34
+ logger_mock.exception.assert_not_called()
35
+
36
+ @patch.dict("os.environ", {"PYTHONPATH": "."})
37
+ @patch("opentelemetry.instrumentation.auto_instrumentation._logger")
38
+ def test_handles_pythonpath_set(self, logger_mock):
39
+ auto_instrumentation.initialize()
40
+ self.assertEqual(environ["PYTHONPATH"], ".")
41
+ logger_mock.exception.assert_not_called()
42
+
43
+ @patch.dict(
44
+ "os.environ",
45
+ {"PYTHONPATH": auto_instrumentation_path + pathsep + "foo"},
46
+ )
47
+ @patch("opentelemetry.instrumentation.auto_instrumentation._logger")
48
+ def test_clears_auto_instrumentation_path(self, logger_mock):
49
+ auto_instrumentation.initialize()
50
+ self.assertEqual(environ["PYTHONPATH"], "foo")
51
+ logger_mock.exception.assert_not_called()
52
+
53
+ @patch("opentelemetry.instrumentation.auto_instrumentation._logger")
54
+ @patch("opentelemetry.instrumentation.auto_instrumentation._load_distro")
55
+ def test_handles_exceptions(self, load_distro_mock, logger_mock):
56
+ # pylint:disable=no-self-use
57
+ load_distro_mock.side_effect = ValueError
58
+ auto_instrumentation.initialize()
59
+ logger_mock.exception.assert_called_once_with(
60
+ "Failed to auto initialize OpenTelemetry"
61
+ )
@@ -0,0 +1,28 @@
1
+ # Copyright The OpenTelemetry Authors
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ # type: ignore
15
+
16
+ from unittest import TestCase
17
+ from unittest.mock import patch
18
+
19
+
20
+ class TestSiteCustomize(TestCase):
21
+ # pylint:disable=import-outside-toplevel,unused-import,no-self-use
22
+ @patch("opentelemetry.instrumentation.auto_instrumentation.initialize")
23
+ def test_sitecustomize_side_effects(self, initialize_mock):
24
+ initialize_mock.assert_not_called()
25
+
26
+ import opentelemetry.instrumentation.auto_instrumentation.sitecustomize # NOQA
27
+
28
+ initialize_mock.assert_called_once()
@@ -1,44 +0,0 @@
1
- # Copyright The OpenTelemetry Authors
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- from logging import getLogger
16
- from os import environ
17
- from os.path import abspath, dirname, pathsep
18
-
19
- from opentelemetry.instrumentation.auto_instrumentation._load import (
20
- _load_configurators,
21
- _load_distro,
22
- _load_instrumentors,
23
- )
24
- from opentelemetry.instrumentation.utils import _python_path_without_directory
25
-
26
- logger = getLogger(__name__)
27
-
28
-
29
- def initialize():
30
- # prevents auto-instrumentation of subprocesses if code execs another python process
31
- environ["PYTHONPATH"] = _python_path_without_directory(
32
- environ["PYTHONPATH"], dirname(abspath(__file__)), pathsep
33
- )
34
-
35
- try:
36
- distro = _load_distro()
37
- distro.configure()
38
- _load_configurators()
39
- _load_instrumentors(distro)
40
- except Exception: # pylint: disable=broad-except
41
- logger.exception("Failed to auto initialize opentelemetry")
42
-
43
-
44
- initialize()