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

Fix Tornado errors mapping to 500 #1048

Merged
merged 2 commits into from
Apr 13, 2022
Merged

Conversation

nicholasgribanov
Copy link
Contributor

@nicholasgribanov nicholasgribanov commented Apr 11, 2022

Description

Fix bug in Tornado instrumentation. Current implementation erase http status codes and set 500 for any types of exceptions (tornado.web.HTTPError and others). But in Tornado implemantation setting http status 500 if exception not tornado.web.HTTPError. Otherwise, http status will set from exception. This fix repeat Tornado implementation logic.

Fixes #997

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

  • Just create handler which raise tornado.web.HTTPError with some code. (See unit test)

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

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

@nicholasgribanov nicholasgribanov requested a review from a team as a code owner April 11, 2022 10:48
@@ -369,14 +369,15 @@ def _finish_span(tracer, handler, error=None):
status_code = error.status_code
if not ctx and status_code == 404:
ctx = _start_span(tracer, handler, _time_ns())
if status_code != 404:
Copy link
Contributor

Choose a reason for hiding this comment

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

@owais
Was there a reason for explicitly checking for non-404s previously?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I undertood right, it was needed for not setting traceback if status equals 404, in other case do it. I've changed this behavior, and now traceback will be setted only for server errors - 500s

@lzchen lzchen enabled auto-merge (squash) April 12, 2022 22:56
@lzchen
Copy link
Contributor

lzchen commented Apr 12, 2022

@nicholasgribanov
Please rebase and we can merge :)

auto-merge was automatically disabled April 13, 2022 07:05

Head branch was pushed to by a user without write access

@nicholasgribanov
Copy link
Contributor Author

nicholasgribanov commented Apr 13, 2022

@nicholasgribanov Please rebase and we can merge :)

Done :) Thank you guys so much! @lzchen @owais

@@ -6,7 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased](https://github.com/open-telemetry/opentelemetry-python/compare/v1.10.0-0.29b0...HEAD)

- `opentelemetry-instrumentation-tornado` Fix Tornado errors mapping to 500
([#1048])(https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1048)
Copy link
Member

Choose a reason for hiding this comment

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

Please move this to Fixed section.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -6,7 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased](https://github.com/open-telemetry/opentelemetry-python/compare/v1.10.0-0.29b0...HEAD)

- `opentelemetry-instrumentation-tornado` Fix Tornado errors mapping to 500
([#1048])(https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1048)
Copy link
Member

Choose a reason for hiding this comment

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

Please move this to Fixed section.

@lzchen lzchen merged commit 9d14265 into open-telemetry:main Apr 13, 2022
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.

Tornado instrumetnation status_code 4ever 500 if error exsist
4 participants