Skip to content

FastAPI instrumentation reports response code as 0 #40130

Closed
@cecheta

Description

@cecheta
  • Package Name: azure-monitor-opentelemetry
  • Package Version: 1.6.5
  • Operating System: Windows (WSL2)
  • Python Version: 3.12.9

Describe the bug
I noticed that the FastAPI instrumentation reports the response status code as 0 when an exception is thrown.

To Reproduce
Steps to reproduce the behavior:

  1. Run https://github.com/Azure/azure-sdk-for-python/blob/23163bcb045d3564f8419fdf99eaef99e0642e5b/sdk/monitor/azure-monitor-opentelemetry/samples/tracing/http_fastapi.py
  2. Send request to http://127.0.0.1:8008/exception

Expected behavior
Request with Response Code 500 is logged in Application Insights

Actual behavior
Response code is 0

Screenshots
Image

Metadata

Metadata

Assignees

Labels

MonitorMonitor, Monitor Ingestion, Monitor QueryMonitor - ExporterMonitor OpenTelemetry ExporterService AttentionWorkflow: This issue is responsible by Azure service team.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions