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 instrumentation for Tornado 6 and above #1018

Merged
merged 1 commit into from
Sep 17, 2020

Conversation

owais
Copy link
Contributor

@owais owais commented Aug 19, 2020

Description

This commit adds auto-instrumentation for Tornado 6 and above on Python
versions 3.5 and above.

Fixes #627

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Tested manually with a demo Tornado app
  • Ships with automated tests

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@owais owais force-pushed the tornado branch 11 times, most recently from 598eb6d to 4d36cfc Compare August 19, 2020 17:45
@owais owais marked this pull request as ready for review August 19, 2020 17:57
@owais owais requested a review from a team August 19, 2020 17:57
@owais owais force-pushed the tornado branch 4 times, most recently from b6d2754 to 31a616d Compare August 19, 2020 18:45

## Unreleased

- Initial release. Supports Tornado 4.x and 5.x on Python 3.7 and newer.
Copy link
Contributor

Choose a reason for hiding this comment

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

This says tornado 4/5 but the PR title calls for tornado 6+

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea, it's 6+. Need to fix that.

@owais owais force-pushed the tornado branch 4 times, most recently from 66708d7 to 82ba264 Compare August 21, 2020 08:26
Programming Language :: Python :: 3.8

[options]
python_requires = >=3.5
Copy link
Contributor

Choose a reason for hiding this comment

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

Is Python 3.5 supported?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it works for Tornado 6+ for my demo app which uses all possible types of handlers and also passes all the tests. If there are concerns with contextvars based context not being available on 3.5 or other reasons, we can support >=3.6 or even 3.7 officially. That said, so far I've found out that everything works on 3.5 without any errors/warnings and the traces generated are correct as well.

import tornado.web
from opentelemetry.instrumentation.tornado import TornadoInstrumentor

# apply tornado auto-instrumentation
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we should say "auto-instrumentation" since we usually use this to refer to not having to instrument manually.

@owais owais force-pushed the tornado branch 4 times, most recently from 8daa5e6 to b25396a Compare August 25, 2020 09:40
@codeboten codeboten added the instrumentation Related to the instrumentation of third party libraries or frameworks label Sep 3, 2020
@owais
Copy link
Contributor Author

owais commented Sep 8, 2020

@open-telemetry/python-approvers would appreciate if someone could help review this. Thanks.

Copy link
Contributor

@codeboten codeboten left a comment

Choose a reason for hiding this comment

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

Overall this looks pretty good, couple of change requested in the comments.

Copy link
Contributor

@codeboten codeboten left a comment

Choose a reason for hiding this comment

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

LGTM

@owais owais force-pushed the tornado branch 5 times, most recently from da2b60f to 60b3026 Compare September 17, 2020 09:18
This commit adds auto-instrumentation for Tornado 6 and above on Python
versions 3.5 and above.
@codeboten codeboten merged commit 5473200 into open-telemetry:master Sep 17, 2020
@owais owais deleted the tornado branch September 17, 2020 17:05
@IainAdamsLabs
Copy link

Hi,

Great work on the tornado instrumentation. May I ask, why is it specifically for Tornado 6+? What is it doing/using that isn't available in earlier versions or tornado?

Thanks

@owais
Copy link
Contributor Author

owais commented Sep 23, 2020

@IainAdamsLabs I think there are some subtle issues with context management and style of tornado handlers (async/await vs gen.coroutine etc). This was months ago so I don't remember the exact issues right now but I think at least one of them was related to this: tornadoweb/tornado#2716

Also, I think (but I'm not sure) if Tornado <6 was to be supported, we'd probably need a special context manager that is not based on contextvars but again I could be wrong.

Tornado 6 was released on Mar 1, 2019 so it isn't brand new TBH. OpenTracing does support Tornado 4 and 5 so I thought it wasn't worth adding support for Tornado 5 here as people can still use OpenTracing to instrument their tornado app until they migrate to Tornado 6. It might also be possible to use OpenTracing with Tornado 5 suppot with the help of the OpenTracing shim we have in this project but I've never tried using it.

That said, I don't think anyone would object if someone was to add and maintain code for Tornado 5 to this package.

alertedsnake pushed a commit to alertedsnake/opentelemetry-python that referenced this pull request Sep 25, 2020
This commit adds auto-instrumentation for Tornado 6 and above on Python
versions 3.5 and above.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
instrumentation Related to the instrumentation of third party libraries or frameworks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add instrumentor for Tornado
4 participants