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

added initial telemetry work #386

Open
wants to merge 45 commits into
base: master
Choose a base branch
from
Open

added initial telemetry work #386

wants to merge 45 commits into from

Conversation

pawelsz-rb
Copy link
Collaborator

@pawelsz-rb pawelsz-rb commented Jul 9, 2021

Description of the change

to enable telemetry, put that in init:

logFormatter = logging.Formatter("%(asctime)s [%(threadName)-12.12s] [%(levelname)-5.5s]  %(message)s")

rollbar.init('access_token', log_telemetry=True, log_telemetry_formatter=logFormatter,
             network_telemetry=True, enable_response_headers=True, enable_req_headers=True)

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Related issues

Fix #88309

Checklists

Development

  • Lint rules pass locally
  • The code changed/added as part of this pull request has been covered with tests
  • All tests related to the changed code pass in development

Code review

  • This pull request has a descriptive title and information useful to a reviewer. There may be a screenshot or screencast attached
  • "Ready for review" label attached to the PR and reviewers mentioned in a comment
  • Changes have been reviewed by at least one other engineer
  • Issue from task tracker has a link to this pull request

rollbar/lib/telemetry.py Outdated Show resolved Hide resolved
@pawelsz-rb pawelsz-rb marked this pull request as ready for review July 26, 2021 17:45
Copy link
Contributor

@bxsx bxsx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @pawelsz-rb. I think this is a good start, but a lot of the Telemetry's functionality is missing or not working correctly.

I left some inline comments. Here's also a quick summary of what at first glance is missing:

  1. Architecture and API for Telemetry must be well designed.
  2. Telemetry doesn't work with most supported web frameworks. I was able to log telemetry while using Starlette or FastAPI, but e.g. Flask or Django has a cold start (no Telemetry data in the first occurrence). Other frameworks also don't work well.
  3. The Telemetry events history should be local for each HTTP request.
  4. report_message() includes global Telemetry history for each call.
  5. Network telemetry should fully support the urllib, requests, and httpx packages.
  6. Network telemetry should support non-HTTP network events (like DNS errors).
  7. Telemetry should support User Inputs events by extracting the request object
  8. Missing tests for provided functionality and supported frameworks.

to enable telemetry, put that in init:

logFormatter = logging.Formatter("%(asctime)s [%(threadName)-12.12s] [%(levelname)-5.5s]  %(message)s")

rollbar.init('access_token', log_telemetry=True, log_telemetry_formatter=logFormatter,
              network_telemetry=True, enable_response_headers=True, enable_req_headers=True)

It's overcomplicated. The default formatter and other flags should be SDK-initialized defaults.

I would expect to enable telemetry with something more user-friendly like:
rollbar.init('access_token', telemetry=True).
Other options should be optional.

rollbar/__init__.py Outdated Show resolved Hide resolved
Comment on lines +17 to +40
- FLASK_VERSION=0.10.1 Werkzeug\>=0.7,\<1.0 chardet==3.0.4 idna==2.7 mock==3.0.5
- FLASK_VERSION=0.11.1 Werkzeug\>=0.7,\<1.0 chardet==3.0.4 idna==2.7 mock==3.0.5
- FLASK_VERSION=0.12.4 Werkzeug\>=0.7,\<1.0 chardet==3.0.4 idna==2.7 mock==3.0.5
- FLASK_VERSION=1.0.2 chardet==3.0.4 idna==2.7 mock==3.0.5
- TWISTED_VERSION=15.5.0 treq==15.1.0 zope.interface==4.1.3 mock==2.0.0
- TWISTED_VERSION=16.1.0 treq==16.12.0 zope.interface==4.1.3 mock==2.0.0
- TWISTED_VERSION=16.2.0 treq==16.12.0 zope.interface==4.1.3 mock==2.0.0
- TWISTED_VERSION=16.3.0 treq==16.12.0 zope.interface==4.2.0 mock==2.0.0
- TWISTED_VERSION=16.4.0 treq==16.12.0 zope.interface==4.5.0 mock==2.0.0
- TWISTED_VERSION=16.5.0 treq==16.12.0 zope.interface==4.5.0 mock==2.0.0
- TWISTED_VERSION=16.6.0 treq==16.12.0 zope.interface==4.5.0 mock==2.0.0
- TWISTED_VERSION=17.1.0 treq==16.12.0 zope.interface==4.5.0 mock==2.0.0
- DJANGO_VERSION=1.11.20 chardet==3.0.4 idna==2.7 mock==3.0.5
- DJANGO_VERSION=2.0.13 mock==2.0.0
- DJANGO_VERSION=2.1.7 mock==2.0.0
- DJANGO_VERSION=2.1.15 mock==2.0.0
- PYRAMID_VERSION=1.9.2 chardet==3.0.4 idna==2.7 mock==3.0.5
- PYRAMID_VERSION=1.10.4 chardet==3.0.4 idna==2.7 mock==3.0.5
- STARLETTE_VERSION=0.12.12 httpx==0.18.1 python-multipart==0.0.5 mock==3.0.5
- STARLETTE_VERSION=0.12.13 httpx==0.18.1 python-multipart==0.0.5 mock==3.0.5
- STARLETTE_VERSION=0.14.2 httpx==0.18.1 python-multipart==0.0.5 mock==3.0.5
- FASTAPI_VERSION=0.40.0 httpx==0.18.1 python-multipart==0.0.5 mock==3.0.5
- FASTAPI_VERSION=0.50.0 httpx==0.18.1 python-multipart==0.0.5 mock==3.0.5
- FASTAPI_VERSION=0.63.0 httpx==0.18.1 python-multipart==0.0.5 mock==3.0.5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All Python versions from the matrix except 2.7 have the mock module included in the standard library. We don't need to install it manually.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, but it does not hurt to install it, and just for that I would need to pull 2.7 out of this matrix and have a different definition.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO requiring the installation of unnecessary packages hurts quality.

Our other test suites solve it in this way:

try:
from unittest import mock
except ImportError:
import mock

You should follow the pattern. In my opinion, this PR does not require any changes in the CI builds. The builds failed for a good reason.

The installation of the mock package for Python <3.3 is already implemented:

pyrollbar/setup.py

Lines 20 to 24 in f67253a

tests_require = [
'webob',
'blinker',
'unittest2',
'mock<=3.0.5; python_version < "3.3"',

Comment on lines -43 to +63
framework: DJANGO_VERSION=2.0.13
framework: DJANGO_VERSION=2.0.13 mock==2.0.0
- python-version: 2.7
framework: DJANGO_VERSION=2.1.7
framework: DJANGO_VERSION=2.1.7 mock==2.0.0
- python-version: 2.7
framework: DJANGO_VERSION=2.1.15
framework: DJANGO_VERSION=2.1.15 mock==2.0.0
- python-version: 3.4
framework: DJANGO_VERSION=2.1.7
framework: DJANGO_VERSION=2.0.13 mock==2.0.0
- python-version: 3.4
framework: DJANGO_VERSION=2.1.15
framework: DJANGO_VERSION=2.1.7 mock==2.0.0
- python-version: 3.4
framework: DJANGO_VERSION=2.1.15 mock==2.0.0
- python-version: 3.5
framework: DJANGO_VERSION=2.1.15 mock==2.0.0
- python-version: 3.5
framework: DJANGO_VERSION=2.0.13 mock==2.0.0
- python-version: 3.5
framework: DJANGO_VERSION=2.1.15
framework: DJANGO_VERSION=2.1.7 mock==2.0.0
- python-version: 3.6
framework: DJANGO_VERSION=2.1.15
framework: DJANGO_VERSION=2.1.15 mock==2.0.0
- python-version: 3.7
framework: DJANGO_VERSION=2.1.15
framework: DJANGO_VERSION=2.1.15 mock==2.0.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a result of the comment above these changes are also not required.

Comment on lines -98 to +139
framework: STARLETTE_VERSION=0.12.12 httpx==0.18.1 python-multipart==0.0.5
framework: STARLETTE_VERSION=0.12.12 httpx==0.18.1 python-multipart==0.0.5 mock==3.0.5
- python-version: 2.7
framework: STARLETTE_VERSION=0.12.13 httpx==0.18.1 python-multipart==0.0.5
framework: STARLETTE_VERSION=0.12.13 httpx==0.18.1 python-multipart==0.0.5 mock==3.0.5
- python-version: 2.7
framework: STARLETTE_VERSION=0.14.2 httpx==0.18.1 python-multipart==0.0.5
framework: STARLETTE_VERSION=0.14.2 httpx==0.18.1 python-multipart==0.0.5 mock==3.0.5
- python-version: 3.4
framework: STARLETTE_VERSION=0.12.12 httpx==0.18.1 python-multipart==0.0.5
framework: STARLETTE_VERSION=0.12.12 httpx==0.18.1 python-multipart==0.0.5 mock==3.0.5
- python-version: 3.4
framework: STARLETTE_VERSION=0.12.13 httpx==0.18.1 python-multipart==0.0.5
framework: STARLETTE_VERSION=0.12.13 httpx==0.18.1 python-multipart==0.0.5 mock==3.0.5
- python-version: 3.4
framework: STARLETTE_VERSION=0.14.2 httpx==0.18.1 python-multipart==0.0.5
framework: STARLETTE_VERSION=0.14.2 httpx==0.18.1 python-multipart==0.0.5 mock==3.0.5
- python-version: 3.5
framework: STARLETTE_VERSION=0.12.12 httpx==0.18.1 python-multipart==0.0.5
framework: STARLETTE_VERSION=0.12.12 httpx==0.18.1 python-multipart==0.0.5 mock==3.0.5
- python-version: 3.5
framework: STARLETTE_VERSION=0.12.13 httpx==0.18.1 python-multipart==0.0.5
framework: STARLETTE_VERSION=0.12.13 httpx==0.18.1 python-multipart==0.0.5 mock==3.0.5
- python-version: 3.5
framework: STARLETTE_VERSION=0.14.2 httpx==0.18.1 python-multipart==0.0.5
framework: STARLETTE_VERSION=0.14.2 httpx==0.18.1 python-multipart==0.0.5 mock==3.0.5

- python-version: 2.7
framework: FASTAPI_VERSION=0.40.0 httpx==0.18.1 python-multipart==0.0.5
framework: FASTAPI_VERSION=0.40.0 httpx==0.18.1 python-multipart==0.0.5 mock==3.0.5
- python-version: 2.7
framework: FASTAPI_VERSION=0.50.0 httpx==0.18.1 python-multipart==0.0.5
framework: FASTAPI_VERSION=0.50.0 httpx==0.18.1 python-multipart==0.0.5 mock==3.0.5
- python-version: 2.7
framework: FASTAPI_VERSION=0.63.0 httpx==0.18.1 python-multipart==0.0.5
framework: FASTAPI_VERSION=0.63.0 httpx==0.18.1 python-multipart==0.0.5 mock==3.0.5
- python-version: 3.4
framework: FASTAPI_VERSION=0.40.0 httpx==0.18.1 python-multipart==0.0.5
framework: FASTAPI_VERSION=0.40.0 httpx==0.18.1 python-multipart==0.0.5 mock==3.0.5
- python-version: 3.4
framework: FASTAPI_VERSION=0.50.0 httpx==0.18.1 python-multipart==0.0.5
framework: FASTAPI_VERSION=0.50.0 httpx==0.18.1 python-multipart==0.0.5 mock==3.0.5
- python-version: 3.4
framework: FASTAPI_VERSION=0.63.0 httpx==0.18.1 python-multipart==0.0.5
framework: FASTAPI_VERSION=0.63.0 httpx==0.18.1 python-multipart==0.0.5 mock==3.0.5
- python-version: 3.5
framework: FASTAPI_VERSION=0.40.0 httpx==0.18.1 python-multipart==0.0.5
framework: FASTAPI_VERSION=0.40.0 httpx==0.18.1 python-multipart==0.0.5 mock==3.0.5
- python-version: 3.5
framework: FASTAPI_VERSION=0.50.0 httpx==0.18.1 python-multipart==0.0.5
framework: FASTAPI_VERSION=0.50.0 httpx==0.18.1 python-multipart==0.0.5 mock==3.0.5
- python-version: 3.5
framework: FASTAPI_VERSION=0.63.0 httpx==0.18.1 python-multipart==0.0.5
framework: FASTAPI_VERSION=0.63.0 httpx==0.18.1 python-multipart==0.0.5 mock==3.0.5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

Comment on lines -138 to +186
framework: FLASK_VERSION=0.10.1
framework: FLASK_VERSION=0.10.1 mock==2.0.0
- python-version: 3.3
framework: FLASK_VERSION=0.11.1
framework: FLASK_VERSION=0.11.1 mock==2.0.0
- python-version: 3.3
framework: FLASK_VERSION=0.12.4
framework: FLASK_VERSION=0.12.4 mock==2.0.0
- python-version: 3.3
framework: FLASK_VERSION=1.0.2
framework: FLASK_VERSION=1.0.2 mock==2.0.0
- python-version: 3.3
framework: DJANGO_VERSION=1.6.11
framework: DJANGO_VERSION=1.6.11 mock==2.0.0
- python-version: 3.3
framework: DJANGO_VERSION=1.8.19
framework: DJANGO_VERSION=1.8.19 mock==2.0.0
- python-version: 3.4
framework: DJANGO_VERSION=1.7.11
framework: DJANGO_VERSION=1.7.11 chardet==3.0.4 idna==2.7 mock==3.0.5
- python-version: 3.4
framework: DJANGO_VERSION=1.8.19
framework: DJANGO_VERSION=1.8.19 chardet==3.0.4 idna==2.7 mock==3.0.5
- python-version: 3.4
framework: DJANGO_VERSION=1.9.13
framework: DJANGO_VERSION=1.9.13 chardet==3.0.4 idna==2.7 mock==3.0.5
- python-version: 3.4
framework: DJANGO_VERSION=1.10.8
framework: DJANGO_VERSION=1.10.8 chardet==3.0.4 idna==2.7 mock==3.0.5
- python-version: 3.4
framework: DJANGO_VERSION=2.0.13 chardet==3.0.4 idna==2.7 mock==3.0.5
- python-version: 3.5
framework: DJANGO_VERSION=1.8.19 mock==3.0.5
- python-version: 3.5
framework: DJANGO_VERSION=1.9.13 mock==3.0.5
- python-version: 3.5
framework: DJANGO_VERSION=1.8.19
framework: DJANGO_VERSION=1.10.8 mock==3.0.5
- python-version: 3.5
framework: DJANGO_VERSION=1.9.13
framework: DJANGO_VERSION=2.0.13 mock==3.0.5
- python-version: 3.5
framework: DJANGO_VERSION=1.10.8
framework: DJANGO_VERSION=2.1.7 mock==3.0.5
- python-version: 3.7
framework: TWISTED_VERSION=18.9.0 treq==20.4.1 zope.interface==4.5.0
framework: TWISTED_VERSION=18.9.0 treq==20.4.1 zope.interface==4.5.0 mock==3.0.5
- python-version: 3.7
framework: TWISTED_VERSION=19.10.0 treq==20.4.1 zope.interface==4.6.0
framework: TWISTED_VERSION=19.10.0 treq==20.4.1 zope.interface==4.6.0 mock==3.0.5
- python-version: 3.7
framework: TWISTED_VERSION=20.3.0 treq==20.4.1 zope.interface==4.7.0
framework: TWISTED_VERSION=20.3.0 treq==20.4.1 zope.interface==4.7.0 mock==3.0.5
- python-version: 3.8
framework: TWISTED_VERSION=18.9.0 treq==20.4.1 zope.interface==4.5.0
framework: TWISTED_VERSION=18.9.0 treq==20.4.1 zope.interface==4.5.0 mock==3.0.5
- python-version: 3.8
framework: TWISTED_VERSION=19.10.0 treq==20.4.1 zope.interface==4.6.0
framework: TWISTED_VERSION=19.10.0 treq==20.4.1 zope.interface==4.6.0 mock==3.0.5
- python-version: 3.8
framework: TWISTED_VERSION=20.3.0 treq==20.4.1 zope.interface==4.7.0
framework: TWISTED_VERSION=20.3.0 treq==20.4.1 zope.interface==4.7.0 mock==3.0.5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Python 3.3+ includes the mock module. I don't think it is necessary.

rollbar/test/test_telemetry.py Outdated Show resolved Hide resolved
rollbar/__init__.py Outdated Show resolved Hide resolved
def test_telemetry_request(self, timestamp):
timestamp.return_value = 1000000

requests.get("http://example.com")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can stub the actual HTTP connection since you don't return the response object.

rollbar/test/test_telemetry.py Outdated Show resolved Hide resolved
rollbar/__init__.py Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants