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

Exception while exporting metrics invalid literal for int() with base 10: 'None' #35633

Closed
Guiforge opened this issue May 15, 2024 · 2 comments · Fixed by #35762
Closed

Exception while exporting metrics invalid literal for int() with base 10: 'None' #35633

Guiforge opened this issue May 15, 2024 · 2 comments · Fixed by #35762
Assignees
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. Monitor - Exporter Monitor OpenTelemetry Exporter needs-team-attention This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention This issue is responsible by Azure service team.

Comments

@Guiforge
Copy link

  • Package Name: azure-monitor-opentelemetry
  • Package Version:
  • Operating System:
  • Python Version:

Describe the bug
Crash during export metrics


2024-05-15T07:38:51.619185568Z [2024-05-15 07:38:51,618: ERROR/MainProcess] Exception while exporting metrics invalid literal for int() with base 10: 'None'
2024-05-15T07:38:51.619240368Z Traceback (most recent call last):
2024-05-15T07:38:51.619246768Z   File "/app/.venv/lib/python3.12/site-packages/opentelemetry/sdk/metrics/_internal/export/__init__.py", line 534, in _receive_metrics
2024-05-15T07:38:51.619251068Z     self._exporter.export(
2024-05-15T07:38:51.619255468Z   File "/app/.venv/lib/python3.12/site-packages/azure/monitor/opentelemetry/exporter/export/metrics/_exporter.py", line 96, in export
2024-05-15T07:38:51.619260069Z     envelope = self._point_to_envelope(
2024-05-15T07:38:51.619264069Z                ^^^^^^^^^^^^^^^^^^^^^^^^
2024-05-15T07:38:51.619267569Z   File "/app/.venv/lib/python3.12/site-packages/azure/monitor/opentelemetry/exporter/export/metrics/_exporter.py", line 144, in _point_to_envelope
2024-05-15T07:38:51.619271769Z     envelope = _handle_std_metric_envelope(envelope, name, point.attributes) # type: ignore
2024-05-15T07:38:51.619276269Z                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-05-15T07:38:51.619280569Z   File "/app/.venv/lib/python3.12/site-packages/azure/monitor/opentelemetry/exporter/export/metrics/_exporter.py", line 236, in _handle_std_metric_envelope
2024-05-15T07:38:51.619285469Z     properties["Dependency.Success"] = str(_is_status_code_success(status_code, 400)) # type: ignore
2024-05-15T07:38:51.619289469Z                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-05-15T07:38:51.619293769Z   File "/app/.venv/lib/python3.12/site-packages/azure/monitor/opentelemetry/exporter/export/metrics/_exporter.py", line 277, in _is_status_code_success
2024-05-15T07:38:51.619298469Z     return status_code is not None and int(status_code) < threshold

As you can see the Exception is here:
https://github.com/Azure/azure-sdk-for-python/blob/ac47fa8cf5e5976e5e7308a0e76ee4adf06a31db/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/metrics/_exporter.py#L276C1-L277C68

def _is_status_code_success(status_code: Optional[str], threshold: int) -> bool:
    return status_code is not None and int(status_code) < threshold

The exception is due to status_code can be 'None'

In urllib the status code is pack in str
https://github.com/open-telemetry/opentelemetry-python-contrib/blob/460fc335836c395db8472ecf464e7ecd94c08925/instrumentation/opentelemetry-instrumentation-urllib/src/opentelemetry/instrumentation/urllib/__init__.py#L247C1-L248C69

The status code can be None when urllib open File. (In my case weasyprint + file:///style.css)

@github-actions github-actions bot added Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. Monitor - Exporter Monitor OpenTelemetry Exporter needs-team-attention This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention This issue is responsible by Azure service team. labels May 15, 2024
Copy link

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @jeremydvoss @lzchen.

@lzchen
Copy link
Member

lzchen commented May 24, 2024

@Guiforge

Thanks for reporting this. I've put out a fix that should be going out in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. Monitor - Exporter Monitor OpenTelemetry Exporter needs-team-attention This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention This issue is responsible by Azure service team.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants