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 ability to extract span attributes from tornado request objects #1178

Merged
merged 8 commits into from
Oct 8, 2020

Conversation

owais
Copy link
Contributor

@owais owais commented Sep 29, 2020

Description

OTEL_PYTHON_TORNADO_TRACED_REQUEST_ATTRS env var can be set to a command
separated list of attributes names that will be extracted from Tornado's
request object and set as attributes on spans.

Also fixes #1176

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 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

  • Unit Tests

Checklist:

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

@owais owais requested a review from a team September 29, 2020 13:43
@owais owais force-pushed the tornado-request-attrs branch 3 times, most recently from 1bb0016 to 5a91eb2 Compare September 29, 2020 14:57
@owais owais changed the title Tornado request attrs Added ability to extract span attributes from falcon request objects Sep 29, 2020
@owais owais changed the title Added ability to extract span attributes from falcon request objects Added ability to extract span attributes from tornado request objects Sep 29, 2020
Copy link
Contributor

@NathanielRN NathanielRN left a comment

Choose a reason for hiding this comment

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

This change looks good to me! I added a few small comments.

_excluded_urls = get_excluded_urls()
_traced_attrs = get_traced_request_attrs()
Copy link
Contributor

Choose a reason for hiding this comment

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

What about this to not have the function above?

Suggested change
_traced_attrs = get_traced_request_attrs()
_traced_attrs = [attr.strip() for attr in configuration.Configuration().TORNADO_TRACED_REQUEST_ATTRS.split(",")] if configuration.Configuration().TORNADO_TRACED_REQUEST_ATTRS else []

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Very similar functionality above uses a function so I think it's better to be consistent with existing code.

@owais owais force-pushed the tornado-request-attrs branch from 48f3240 to 4bdb84e Compare September 29, 2020 17:49
@codeboten codeboten added the instrumentation Related to the instrumentation of third party libraries or frameworks label Oct 1, 2020
Copy link
Contributor

@lzchen lzchen left a comment

Choose a reason for hiding this comment

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

Please add an entry to CHANGELOG

@owais owais force-pushed the tornado-request-attrs branch from 72350c4 to fbbba1f Compare October 2, 2020 17:49
owais and others added 3 commits October 2, 2020 23:20
OTEL_PYTHON_TONADO_TRACED_REQUEST_ATTRS env var can be set to a command
separated list of attributes names that will be extracted from Tornado's
request object and set as attributes on spans.
@owais owais force-pushed the tornado-request-attrs branch 2 times, most recently from aa607fc to badd8d6 Compare October 2, 2020 18:01
…st_instrumentation.py

Co-authored-by: (Eliseo) Nathaniel Ruiz Nowell <[email protected]>
@owais owais force-pushed the tornado-request-attrs branch from badd8d6 to 5c0bc91 Compare October 2, 2020 19:42
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.

Just one non-blocking comment, otherwise it looks good 👍

Comment on lines +75 to +81
def get_traced_request_attrs():
attrs = configuration.Configuration().TORNADO_TRACED_REQUEST_ATTRS or ""
if attrs:
attrs = [attr.strip() for attr in attrs.split(",")]
else:
attrs = []
return attrs
Copy link
Contributor

Choose a reason for hiding this comment

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

is it worth moving this code into the utils package as well since it seems likely to be repeated?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree. I think it might be better to have convenience methods on the configuration class itself for common config items. Something like,

cfg = configuration.Configuration()
cfg.traced_methods("django")
cfg.excluded_urls("django")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Created an issue for it. #1217

@codeboten codeboten merged commit 4a66652 into open-telemetry:master Oct 8, 2020
@owais owais deleted the tornado-request-attrs branch October 8, 2020 11:36
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.

Added generic mechanism to provide the ability to extract span attributes
4 participants