Skip to content

Commit 1030abf

Browse files
committed
potato
2 parents 2862863 + c59b514 commit 1030abf

File tree

44 files changed

+2281
-409
lines changed

Some content is hidden

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

44 files changed

+2281
-409
lines changed

.github/workflows/component-owners.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ jobs:
1010
run_self:
1111
runs-on: ubuntu-latest
1212
name: Auto Assign Owners
13+
permissions:
14+
contents: read # to read changed files
15+
issues: write # to read/write issue assignees
16+
pull-requests: write # to read/write PR reviewers
1317
# Don't fail tests if this workflow fails. Some pending issues:
1418
# - https://github.com/dyladan/component-owners/issues/8
1519
continue-on-error: true

.github/workflows/misc_0.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,21 @@ jobs:
152152

153153
- name: Run tests
154154
run: tox -e ruff
155+
156+
typecheck:
157+
name: typecheck
158+
runs-on: ubuntu-latest
159+
steps:
160+
- name: Checkout repo @ SHA - ${{ github.sha }}
161+
uses: actions/checkout@v4
162+
163+
- name: Set up Python 3.11
164+
uses: actions/setup-python@v5
165+
with:
166+
python-version: "3.11"
167+
168+
- name: Install tox
169+
run: pip install tox
170+
171+
- name: Run tests
172+
run: tox -e typecheck

CHANGELOG.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,55 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717
([#3100](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3100))
1818
- Add support to database stability opt-in in `_semconv` utilities and add tests
1919
([#3111](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3111))
20+
- `opentelemetry-opentelemetry-pymongo` Add `py.typed` file to enable PEP 561
21+
([#3136](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3136))
22+
- `opentelemetry-opentelemetry-requests` Add `py.typed` file to enable PEP 561
23+
([#3135](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3135))
2024
- `opentelemetry-instrumentation-system-metrics` Add `py.typed` file to enable PEP 561
2125
([#3132](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3132))
2226
- `opentelemetry-opentelemetry-sqlite3` Add `py.typed` file to enable PEP 561
2327
([#3133](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3133))
2428
- `opentelemetry-instrumentation-falcon` add support version to v4
2529
([#3086](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3086))
30+
- `opentelemetry-instrumentation-falcon` Implement new HTTP semantic convention opt-in for Falcon
31+
([#2790](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2790))
2632
- `opentelemetry-instrumentation-wsgi` always record span status code to have it available in metrics
2733
([#3148](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3148))
2834
- add support to Python 3.13
2935
([#3134](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3134))
36+
- `opentelemetry-opentelemetry-wsgi` Add `py.typed` file to enable PEP 561
37+
([#3129](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3129))
38+
- `opentelemetry-util-http` Add `py.typed` file to enable PEP 561
39+
([#3127](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3127))
3040

3141
### Fixed
3242

3343
- `opentelemetry-instrumentation-httpx` Fix `RequestInfo`/`ResponseInfo` type hints
3444
([#3105](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3105))
45+
- `opentelemetry-instrumentation-dbapi` Move `TracedCursorProxy` and `TracedConnectionProxy` to the module level
46+
([#3068](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3068))
47+
- `opentelemetry-instrumentation-click` Disable tracing of well-known server click commands
48+
([#3174](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3174))
49+
- `opentelemetry-instrumentation` Fix `get_dist_dependency_conflicts` if no distribution requires
50+
([#3168](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3168))
51+
52+
### Breaking changes
53+
54+
- `opentelemetry-instrumentation-sqlalchemy` including sqlcomment in `db.statement` span attribute value is now opt-in
55+
([#3112](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3112))
56+
57+
### Breaking changes
58+
59+
- `opentelemetry-instrumentation-dbapi` including sqlcomment in `db.statement` span attribute value is now opt-in
60+
([#3115](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3115))
61+
62+
63+
### Breaking changes
64+
65+
- `opentelemetry-instrumentation-dbapi` including sqlcomment in `db.statement` span attribute value is now opt-in
66+
([#3115](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3115))
67+
- `opentelemetry-instrumentation-psycopg2`, `opentelemetry-instrumentation-psycopg`, `opentelemetry-instrumentation-mysqlclient`, `opentelemetry-instrumentation-pymysql`: including sqlcomment in `db.statement` span attribute value is now opt-in
68+
([#3121](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3121))
3569

3670

3771
## Version 1.29.0/0.50b0 (2024-12-11)

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ The Python auto-instrumentation libraries for [OpenTelemetry](https://openteleme
4848
* [Installation](#installation)
4949
* [Releasing](#releasing)
5050
* [Releasing a package as `1.0` stable](#releasing-a-package-as-10-stable)
51+
* [Semantic Convention status of instrumentations](#semantic-convention-status-of-instrumentations)
5152
* [Contributing](#contributing)
5253
* [Thanks to all the people who already contributed](#thanks-to-all-the-people-who-already-contributed)
5354

@@ -100,7 +101,7 @@ To release a package as `1.0` stable, the package:
100101

101102
## Semantic Convention status of instrumentations
102103

103-
In our efforts to maintain optimal user experience and prevent breaking changes for transitioning into stable semantic conventions, OpenTelemetry Python is adopting the [semantic convention migration plan](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/http/migration-guide.md) for several instrumentations. Currently this plan is only being adopted for HTTP-related instrumentations, but will eventually cover all types. Please refer to the `semconv status` column of the [instrumentation README](instrumentation/README.md) of the current status of instrumentations' semantic conventions. The possible values are `experimental`, `stable` and `migration` referring to [status](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.31.0/specification/document-status.md#lifecycle-status) of that particular semantic convention. `Migration` refers to an instrumentation that currently supports the migration plan.
104+
In our efforts to maintain optimal user experience and prevent breaking changes for transitioning into stable semantic conventions, OpenTelemetry Python is adopting the semantic convention migration plan for several instrumentations. Currently this plan is only being adopted for [HTTP-related instrumentations](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/non-normative/http-migration.md), but will eventually cover all types. Please refer to the `semconv status` column of the [instrumentation README](instrumentation/README.md) of the current status of instrumentations' semantic conventions. The possible values are `experimental`, `stable` and `migration` referring to [status](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.31.0/specification/document-status.md#lifecycle-status) of that particular semantic convention. `Migration` refers to an instrumentation that currently supports the migration plan.
104105

105106
## Contributing
106107

dev-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
pylint==3.0.2
22
httpretty==1.1.4
3-
mypy==0.931
3+
pyright==v1.1.390
44
sphinx==7.1.2
55
sphinx-rtd-theme==2.0.0rc4
66
sphinx-autodoc-typehints==1.25.2

docs/nitpick-exceptions.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ py-class=
4343
confluent_kafka.Message
4444
psycopg.Connection
4545
psycopg.AsyncConnection
46+
ObjectProxy
4647

4748
any=
4849
; API
@@ -70,6 +71,8 @@ any=
7071

7172
py-obj=
7273
opentelemetry.propagators.textmap.CarrierT
74+
opentelemetry.instrumentation.dbapi.ConnectionT
75+
opentelemetry.instrumentation.dbapi.CursorT
7376

7477
py-func=
7578
poll

instrumentation/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
| [opentelemetry-instrumentation-dbapi](./opentelemetry-instrumentation-dbapi) | dbapi | No | experimental
2121
| [opentelemetry-instrumentation-django](./opentelemetry-instrumentation-django) | django >= 1.10 | Yes | experimental
2222
| [opentelemetry-instrumentation-elasticsearch](./opentelemetry-instrumentation-elasticsearch) | elasticsearch >= 6.0 | No | experimental
23-
| [opentelemetry-instrumentation-falcon](./opentelemetry-instrumentation-falcon) | falcon >= 1.4.1, < 5.0.0 | Yes | experimental
23+
| [opentelemetry-instrumentation-falcon](./opentelemetry-instrumentation-falcon) | falcon >= 1.4.1, < 5.0.0 | Yes | migration
2424
| [opentelemetry-instrumentation-fastapi](./opentelemetry-instrumentation-fastapi) | fastapi ~= 0.58 | Yes | migration
2525
| [opentelemetry-instrumentation-flask](./opentelemetry-instrumentation-flask) | flask >= 1.0 | Yes | migration
2626
| [opentelemetry-instrumentation-grpc](./opentelemetry-instrumentation-grpc) | grpcio >= 1.42.0 | No | experimental

instrumentation/opentelemetry-instrumentation-asyncpg/tests/test_asyncpg_wrapper.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from asyncpg import Connection, Record, cursor
66
from wrapt import ObjectProxy
77

8+
from opentelemetry import trace as trace_api
89
from opentelemetry.instrumentation.asyncpg import AsyncPGInstrumentor
910
from opentelemetry.test.test_base import TestBase
1011

@@ -105,3 +106,36 @@ async def exec_mock(*args, **kwargs):
105106
spans = self.memory_exporter.get_finished_spans()
106107
self.assertEqual(len(spans), 2)
107108
self.assertEqual([span.status.is_ok for span in spans], [True, True])
109+
110+
def test_no_op_tracer_provider(self):
111+
AsyncPGInstrumentor().uninstrument()
112+
AsyncPGInstrumentor().instrument(
113+
tracer_provider=trace_api.NoOpTracerProvider()
114+
)
115+
116+
# Mock out all interaction with postgres
117+
async def bind_mock(*args, **kwargs):
118+
return []
119+
120+
async def exec_mock(*args, **kwargs):
121+
return [], None, True
122+
123+
conn = mock.Mock()
124+
conn.is_closed = lambda: False
125+
126+
conn._protocol = mock.Mock()
127+
conn._protocol.bind = bind_mock
128+
conn._protocol.execute = exec_mock
129+
conn._protocol.bind_execute = exec_mock
130+
conn._protocol.close_portal = bind_mock
131+
132+
state = mock.Mock()
133+
state.closed = False
134+
135+
# init the cursor and fetch a single record
136+
crs = cursor.Cursor(conn, "SELECT * FROM test", state, [], Record)
137+
asyncio.run(crs._init(1))
138+
asyncio.run(crs.fetch(1))
139+
140+
spans = self.memory_exporter.get_finished_spans()
141+
self.assertEqual(len(spans), 0)

instrumentation/opentelemetry-instrumentation-click/src/opentelemetry/instrumentation/click/__init__.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
# limitations under the License.
1414

1515
"""
16-
Instrument `click`_ CLI applications.
16+
Instrument `click`_ CLI applications. The instrumentor will avoid instrumenting
17+
well-known servers (e.g. *flask run* and *uvicorn*) to avoid unexpected effects
18+
like every request having the same Trace ID.
1719
1820
.. _click: https://pypi.org/project/click/
1921
@@ -47,6 +49,12 @@ def hello():
4749
import click
4850
from wrapt import wrap_function_wrapper
4951

52+
try:
53+
from flask.cli import ScriptInfo as FlaskScriptInfo
54+
except ImportError:
55+
FlaskScriptInfo = None
56+
57+
5058
from opentelemetry import trace
5159
from opentelemetry.instrumentation.click.package import _instruments
5260
from opentelemetry.instrumentation.click.version import __version__
@@ -66,6 +74,20 @@ def hello():
6674
_logger = getLogger(__name__)
6775

6876

77+
def _skip_servers(ctx: click.Context):
78+
# flask run
79+
if (
80+
ctx.info_name == "run"
81+
and FlaskScriptInfo
82+
and isinstance(ctx.obj, FlaskScriptInfo)
83+
):
84+
return True
85+
# uvicorn
86+
if ctx.info_name == "uvicorn":
87+
return True
88+
return False
89+
90+
6991
def _command_invoke_wrapper(wrapped, instance, args, kwargs, tracer):
7092
# Subclasses of Command include groups and CLI runners, but
7193
# we only want to instrument the actual commands which are
@@ -74,6 +96,12 @@ def _command_invoke_wrapper(wrapped, instance, args, kwargs, tracer):
7496
return wrapped(*args, **kwargs)
7597

7698
ctx = args[0]
99+
100+
# we don't want to create a root span for long running processes like servers
101+
# otherwise all requests would have the same trace id
102+
if _skip_servers(ctx):
103+
return wrapped(*args, **kwargs)
104+
77105
span_name = ctx.info_name
78106
span_attributes = {
79107
PROCESS_COMMAND_ARGS: sys.argv,
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
11
asgiref==3.8.1
2+
blinker==1.7.0
23
click==8.1.7
34
Deprecated==1.2.14
5+
Flask==3.0.2
46
iniconfig==2.0.0
7+
itsdangerous==2.1.2
8+
Jinja2==3.1.4
9+
MarkupSafe==2.1.2
510
packaging==24.0
611
pluggy==1.5.0
712
py-cpuinfo==9.0.0
813
pytest==7.4.4
914
pytest-asyncio==0.23.5
1015
tomli==2.0.1
1116
typing_extensions==4.12.2
17+
Werkzeug==3.0.6
1218
wrapt==1.16.0
1319
zipp==3.19.2
1420
-e opentelemetry-instrumentation
1521
-e instrumentation/opentelemetry-instrumentation-click
22+
-e instrumentation/opentelemetry-instrumentation-flask
23+
-e instrumentation/opentelemetry-instrumentation-wsgi
24+
-e util/opentelemetry-util-http

0 commit comments

Comments
 (0)