Skip to content
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

flask.signals has no attribute signals_available #300

Closed
sosaedison opened this issue Aug 29, 2024 · 2 comments
Closed

flask.signals has no attribute signals_available #300

sosaedison opened this issue Aug 29, 2024 · 2 comments
Labels
status: info needed Further information is requested. type: bug Something isn't working

Comments

@sosaedison
Copy link

When initializing the HoneyMiddleware in a Flask application, we get the following error:

Traceback (most recent call last):
         |   File "<frozen runpy>", line 198, in _run_module_as_main
         |   File "<frozen runpy>", line 88, in _run_code
         |   File "/opt/venv/lib/python3.11/site-packages/debugpy/__main__.py", line 71, in <module>
         |     cli.main()
         |   File "/opt/venv/lib/python3.11/site-packages/debugpy/server/cli.py", line 501, in main
         |     run()
         |   File "/opt/venv/lib/python3.11/site-packages/debugpy/server/cli.py", line 384, in run_module
         |     run_module_as_main(options.target, alter_argv=True)
         |   File "/opt/venv/lib/python3.11/site-packages/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 238, in _run_module_as_main
         |     return _run_code(code, main_globals, None,
         |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         |   File "/opt/venv/lib/python3.11/site-packages/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 124, in _run_code
         |     exec(code, run_globals)
         |   File "/opt/venv/lib/python3.11/site-packages/flask/__main__.py", line 3, in <module>
         |     main()
         |   File "/opt/venv/lib/python3.11/site-packages/flask/cli.py", line 1105, in main
         |     cli.main()
         |   File "/opt/venv/lib/python3.11/site-packages/click/core.py", line 1078, in main
         |     rv = self.invoke(ctx)
         |          ^^^^^^^^^^^^^^^^
         |   File "/opt/venv/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
         |     return _process_result(sub_ctx.command.invoke(sub_ctx))
         |                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         |   File "/opt/venv/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
         |     return ctx.invoke(self.callback, **ctx.params)
         |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         |   File "/opt/venv/lib/python3.11/site-packages/click/core.py", line 783, in invoke
         |     return __callback(*args, **kwargs)
         |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
         |   File "/opt/venv/lib/python3.11/site-packages/click/decorators.py", line 92, in new_func
         |     return ctx.invoke(f, obj, *args, **kwargs)
         |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         |   File "/opt/venv/lib/python3.11/site-packages/click/core.py", line 783, in invoke
         |     return __callback(*args, **kwargs)
         |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
         |   File "/opt/venv/lib/python3.11/site-packages/flask/cli.py", line 953, in run_command
         |     raise e from None
         |   File "/opt/venv/lib/python3.11/site-packages/flask/cli.py", line 937, in run_command
         |     app: WSGIApplication = info.load_app()
         |                            ^^^^^^^^^^^^^^^
         |   File "/opt/venv/lib/python3.11/site-packages/flask/cli.py", line 335, in load_app
         |     app = locate_app(import_name, name)
         |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         |   File "/opt/venv/lib/python3.11/site-packages/flask/cli.py", line 245, in locate_app
         |     __import__(module_name)
         |   File "/home/user/app/app.py", line 17, in <module>
         |     app = make_app()
         |           ^^^^^^^^^^
         |   File "/home/user/app/make_app.py", line 54, in make_app
         |     Honeycomb().init_app(app)
         |   File "/home/user/app/monitoring/monitoring.py", line 51, in init_app
         |     HoneyMiddleware(app, db_events=False)
         |   File "/opt/venv/lib/python3.11/site-packages/beeline/middleware/flask/__init__.py", line 18, in __init__
         |     if signals.signals_available:
         |        ^^^^^^^^^^^^^^^^^^^^^^^^^
         | AttributeError: module 'flask.signals' has no attribute 'signals_available'

Versions

  • Python: 3.11
  • Beeline: 3.6.0
  • Flask: 3.0.3

Steps to reproduce

  1. Create a requirements.txt file with these packages:
honeycomb-beeline==3.6.0
Flask==3.0.3
  1. Install the packages above:

    • python3.11 -m venv .venv
    • source .venv/bin/activate
    • pip install -r requirements.txt
  2. Create app.py file and copy-paste the code below

import os
import beeline
from flask import Flask
from beeline.middleware.flask import HoneyMiddleware
from dotenv import load_dotenv

load_dotenv()

flask_app = Flask(__name__)


def beeline_init(flask_app):
    API_KEY = os.getenv("BEELINE_API_KEY")
    DATASET = os.getenv("BEELINE_DATASET")

    beeline.init(
        writekey=API_KEY,
        dataset=DATASET,
        service_name="Test App",
    )
    HoneyMiddleware(flask_app, db_events=False)


if __name__ == "__main__":
    beeline_init(flask_app)
    flask_app.run()
  1. Run the file with python3 app.py
@sosaedison sosaedison added the type: bug Something isn't working label Aug 29, 2024
@VinozzZ
Copy link
Contributor

VinozzZ commented Aug 29, 2024

It looks like this attribute is removed since Flask 2.4. Did this error occur after an upgrade of Flask or a newly instrumented application?
If this is a new instrumentation, we recommend you to use opentelemetry instead

@MikeGoldsmith
Copy link
Contributor

Closing for now, please re-open if you're still experiencing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: info needed Further information is requested. type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants
@MikeGoldsmith @sosaedison @VinozzZ @JamieDanielson and others