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

opentelemetry-instrumentation-urllib log warning on None status code #1401

Closed
jaroslawporada opened this issue Oct 24, 2022 · 4 comments
Closed
Assignees
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed instrumentation triaged

Comments

@jaroslawporada
Copy link

Describe your environment Describe any aspect of your environment relevant to the problem, including your Python version, platform, version numbers of installed dependencies, information about your cloud hosting provider, etc. If you're reporting a problem with a specific version of a library in this repo, please check whether the problem has been fixed on main.

python:3.10.7

WeasyPrint==52.4
opentelemetry-instrumentation-urllib==0.33b0

'Linux-5.15.0-52-generic-x86_64-with-glibc2.28'

Steps to reproduce
Describe exactly how to reproduce the error. Include a code sample if applicable.

In my code following log occured Invalid type NoneType for attribute value. Expected one of ['bool', 'str', 'bytes', 'int', 'float'] or a sequence of those types.

It was caused by

from urllib.request import Request, urlopen

response = urlopen(
   ...:     Request(
   ...:         'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0yMSA2LjI4NWwtMTEuMTYgMTIuNzMzLTYuODQtNi4wMTggMS4zMTktMS40OSA1LjM0MSA0LjY4NiA5Ljg2NS0xMS4xOTYgMS40NzUgMS4yODV6Ii8+PC9zdmc+',
   ...:         {'User-Agent': 'WeasyPrint 52.4 (http://weasyprint.org/)',
   ...:          'Accept': '*/*',
   ...:          'Accept-Encoding': 'gzip, deflate'},
   ...:     ),
   ...:     timeout=2,
   ...:     context=None,
)

response.code is None. I think that in this case we should not assume that status code is not None.

What is the expected behavior?
Invalid type NoneType for attribute value. Expected one of ['bool', 'str', 'bytes', 'int', 'float'] or a sequence of those types should not be logged in this case.

What is the actual behavior?
What did you see instead?

Invalid type NoneType for attribute value. Expected one of ['bool', 'str', 'bytes', 'int', 'float'] or a sequence of those types is logged.

Additional context
Add any other context about the problem here.

@jaroslawporada jaroslawporada added the bug Something isn't working label Oct 24, 2022
@srikanthccv srikanthccv added good first issue Good for newcomers help wanted Extra attention is needed instrumentation triaged labels Oct 26, 2022
@shalevr
Copy link
Member

shalevr commented Oct 27, 2022

Can you assign it to me?

@shalevr
Copy link
Member

shalevr commented Oct 31, 2022

I'm not sure if we should add the response.code to the span in this case.
I think there is no reason to add an attribute that doesn't exist(None)
BTW the check if any attribute value is valid is a global check, so it will be more complicated to change this only for the response.code.

@srikanthccv
Copy link
Member

so it will be more complicated to change this only for the response.code.

This issue is specially about the urllib instrumentation and the fix is to not set the status code where there is None.

@srikanthccv
Copy link
Member

Fixed in #1430

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed instrumentation triaged
Projects
None yet
Development

No branches or pull requests

3 participants