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

Tornado instrumetnation status_code 4ever 500 if error exsist #997

Closed
nicholasgribanov opened this issue Mar 14, 2022 · 4 comments · Fixed by #1048
Closed

Tornado instrumetnation status_code 4ever 500 if error exsist #997

nicholasgribanov opened this issue Mar 14, 2022 · 4 comments · Fixed by #1048

Comments

@nicholasgribanov
Copy link
Contributor

Here https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/instrumentation/opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado/__init__.py#L372-L379, when span finished, status_code is setting to 500, if error exists and status code from handler not equals 404.
Is it correct behavior ?
I see, it needed for setting description in Status. But, in this method, if status_code <=499, Status must be set to UNSET. In our case, if status_code <=499 will set ERROR.

if status <= 499 and server_span:
return StatusCode.UNSET
.
Maybe needed extend this condition https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/instrumentation/opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado/__init__.py#L372 to all 4xx http codes instead of just 404?

@srikanthccv
Copy link
Member

@nicholasgribanov It was unclear from the description what is the problem here? Can you explain what is the issue and how does the proposed solution fixes the issue?

@nicholasgribanov
Copy link
Contributor Author

nicholasgribanov commented Mar 18, 2022

@srikanthccv thank's for a fast answer.
In case, if I want to sampling spans on collector-level by processing with like this config:

  [
    {
      name: error_policy,
      type: numeric_attribute,
      numeric_attribute: { key: "http.status_code", min_value: 500, max_value: 599 }
    }
  ]

I wait spans only with http-status more when 500. But, now, it doesn't work. Beacause, on the Tornado instrumentation level, server spans with error and http-status not equal 404, will forcibly setting http.status_code to 500 https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/instrumentation/opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado/__init__.py#L372-L379.
You can see this here:
Снимок экрана от 2022-03-17 11-14-30

It's not right behavior. If you are waiting spans onlyf with http-status more than 500, you must not getting spans with 400 error.
I see, it needed for setting description in Status. But, in this method, if status_code <=499, Status must be set to UNSET. In our case, if status_code <=499 will set ERROR.

if status <= 499 and server_span:
return StatusCode.UNSET
I propose fix this and not change http.status_code, only for setting description message. Now I see, fix from my previusly message not right. Needed find way set descpription of error and not chage http.status_code.

@ocelotl
Copy link
Contributor

ocelotl commented Mar 21, 2022

Ok, I see there is a discrepancy. I actually wonder why do we change the status code from 4XX to 500, @owais, do you have any input?

@nicholasgribanov
Copy link
Contributor Author

Any updates ?

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 a pull request may close this issue.

3 participants