-
Notifications
You must be signed in to change notification settings - Fork 710
click: ignore click based servers #3174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
770a6e3
18994f7
b5726a4
3259415
e3765b5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,24 @@ | ||
asgiref==3.8.1 | ||
blinker==1.7.0 | ||
click==8.1.7 | ||
Deprecated==1.2.14 | ||
Flask==3.0.2 | ||
iniconfig==2.0.0 | ||
itsdangerous==2.1.2 | ||
Jinja2==3.1.4 | ||
MarkupSafe==2.1.2 | ||
packaging==24.0 | ||
pluggy==1.5.0 | ||
py-cpuinfo==9.0.0 | ||
pytest==7.4.4 | ||
pytest-asyncio==0.23.5 | ||
tomli==2.0.1 | ||
typing_extensions==4.12.2 | ||
Werkzeug==3.0.6 | ||
wrapt==1.16.0 | ||
zipp==3.19.2 | ||
-e opentelemetry-instrumentation | ||
-e instrumentation/opentelemetry-instrumentation-click | ||
-e instrumentation/opentelemetry-instrumentation-flask | ||
-e instrumentation/opentelemetry-instrumentation-wsgi | ||
-e util/opentelemetry-util-http |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,8 +16,14 @@ | |
from unittest import mock | ||
|
||
import click | ||
import pytest | ||
from click.testing import CliRunner | ||
|
||
try: | ||
from flask import cli as flask_cli | ||
except ImportError: | ||
flask_cli = None | ||
|
||
from opentelemetry.instrumentation.click import ClickInstrumentor | ||
from opentelemetry.test.test_base import TestBase | ||
from opentelemetry.trace import SpanKind | ||
|
@@ -60,7 +66,7 @@ def command(): | |
) | ||
|
||
@mock.patch("sys.argv", ["flask", "command"]) | ||
def test_flask_run_command_wrapping(self): | ||
def test_flask_command_wrapping(self): | ||
@click.command() | ||
def command(): | ||
pass | ||
|
@@ -162,6 +168,27 @@ def command_raises(): | |
}, | ||
) | ||
|
||
def test_uvicorn_cli_command_ignored(self): | ||
@click.command("uvicorn") | ||
def command_uvicorn(): | ||
pass | ||
|
||
runner = CliRunner() | ||
result = runner.invoke(command_uvicorn) | ||
Comment on lines
+172
to
+177
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we could just call Please do not ask me to create an issue. I'm good. 🙏 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you look at the code flask is recognized by checking a parameter type since the command name |
||
self.assertEqual(result.exit_code, 0) | ||
|
||
self.assertFalse(self.memory_exporter.get_finished_spans()) | ||
|
||
@pytest.mark.skipif(flask_cli is None, reason="requires flask") | ||
def test_flask_run_command_ignored(self): | ||
runner = CliRunner() | ||
result = runner.invoke( | ||
flask_cli.run_command, obj=flask_cli.ScriptInfo() | ||
) | ||
self.assertEqual(result.exit_code, 2) | ||
|
||
self.assertFalse(self.memory_exporter.get_finished_spans()) | ||
|
||
def test_uninstrument(self): | ||
ClickInstrumentor().uninstrument() | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.