Skip to content

Commit

Permalink
Code cleanup (#1503)
Browse files Browse the repository at this point in the history
  • Loading branch information
srikanthccv authored Jan 4, 2021
1 parent 336af87 commit 90db9dc
Showing 1 changed file with 2 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,34 +40,13 @@ def http_status_to_status_code(
Args:
status (int): HTTP status code
"""
# pylint:disable=too-many-branches,too-many-return-statements
# See: https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/semantic_conventions/http.md#status
if status < 100:
return StatusCode.ERROR
if status <= 299:
return StatusCode.UNSET
if status <= 399:
if allow_redirect:
return StatusCode.UNSET
return StatusCode.ERROR
if status <= 499:
if status == 401: # HTTPStatus.UNAUTHORIZED:
return StatusCode.ERROR
if status == 403: # HTTPStatus.FORBIDDEN:
return StatusCode.ERROR
if status == 404: # HTTPStatus.NOT_FOUND:
return StatusCode.ERROR
if status == 429: # HTTPStatus.TOO_MANY_REQUESTS:
return StatusCode.ERROR
return StatusCode.ERROR
if status <= 599:
if status == 501: # HTTPStatus.NOT_IMPLEMENTED:
return StatusCode.ERROR
if status == 503: # HTTPStatus.SERVICE_UNAVAILABLE:
return StatusCode.ERROR
if status == 504: # HTTPStatus.GATEWAY_TIMEOUT:
return StatusCode.ERROR
return StatusCode.ERROR
if status <= 399 and allow_redirect:
return StatusCode.UNSET
return StatusCode.ERROR


Expand Down

0 comments on commit 90db9dc

Please sign in to comment.