Skip to content

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 April 11, 2022 10:48
@nicholasgribanov nicholasgribanov force-pushed the HH-148830 branch 3 times, most recently from 6dbb031 to ea8967c Compare April 11, 2022 12:43
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

@nicholasgribanov nicholasgribanov force-pushed the HH-148830 branch 2 times, most recently from 0f7d1be to 1188986 Compare April 12, 2022 08:12
@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

## [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

## [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