Skip to content
This repository has been archived by the owner on Jun 11, 2018. It is now read-only.

Disabled module falsely claims that it is sending messages during tests #39

Open
martey opened this issue Jun 9, 2015 · 3 comments
Open
Assignees
Milestone

Comments

@martey
Copy link

martey commented Jun 9, 2015

Django 1.8.2, Opbeat 2.1.1

I have disabled Opbeat by setting OPBEAT["APP_ID"] = None. When I run ./manage.py test, I get the following lines printed out at the end of each run:

PID 19301: Opbeat is attempting to send 1 pending messages
Waiting up to 10 seconds, press Ctrl-C to quit
PID 19301: done, took 0.12 seconds to complete

Based on what I can tell with netstat, Opbeat correctly realizes that it is disabled and does not really attempts to send messages to the intake servers. The messages are still sort of confusing, though.

@beniwohli
Copy link
Member

Thanks for the report! This is indeed a problem. In this case, the pending message is from the APM middleware, not an exception. We are looking into introducing a cleaner way to disable Opbeat collecting any data (see #36).

As a workaround, you can try removing the APM middleware during tests:

MIDDLEWARE_CLASSES.remove('opbeat.contrib.django.middleware.OpbeatAPMMiddleware')

@beniwohli beniwohli self-assigned this Jun 9, 2015
@martey
Copy link
Author

martey commented Jun 10, 2015

MIDDLEWARE_CLASSES is a tuple, so the suggested workaround gave me an error. Removing the APM middleware did work with the following code:

MIDDLEWARE_CLASSES = tuple(
    middleware for middleware in MIDDLEWARE_CLASSES
    if middleware != "opbeat.contrib.django.middleware.OpbeatAPMMiddleware")

@kennell
Copy link

kennell commented Dec 2, 2017

I belive this issue is present again with Django 1.11:

python manage.py test tests/*
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
.......................
----------------------------------------------------------------------
Ran 23 tests in 1.381s

OK
Destroying test database for alias 'default'...
PID 5831: Opbeat is attempting to send 1 pending messages
Waiting up to 10 seconds, press Ctrl-C to quit
HTTP 401:
Failed to submit message: '<no message value>'
Traceback (most recent call last):
  File "/Users/kevin/.virtualenvs/foo/lib/python3.6/site-packages/opbeat/transport/http_urllib3.py", line 75, in send_sync
    url = Urllib3Transport.send(self, data, headers)
  File "/Users/kevin/.virtualenvs/foo/lib/python3.6/site-packages/opbeat/transport/http_urllib3.py", line 61, in send
    raise TransportException(message, data, print_trace=print_trace)
opbeat.transport.base.TransportException: HTTP 401:
PID 5831: done, took 2.74 seconds to complete

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants