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

Cancelled Requests Fail to Report Correct Status Code #3600

Closed
RehanSaeed opened this issue Aug 24, 2022 · 5 comments
Closed

Cancelled Requests Fail to Report Correct Status Code #3600

RehanSaeed opened this issue Aug 24, 2022 · 5 comments
Labels
bug Something isn't working Stale Issues and pull requests which have been flagged for closing due to inactivity

Comments

@RehanSaeed
Copy link

Bug Report

  • OpenTelemetry.Exporter.Console 1.3.0
  • OpenTelemetry.Extensions.Hosting 1.0.0-rc9.6
  • OpenTelemetry.Instrumentation.AspNetCore 1.0.0-rc9.6
  • OpenTelemetry.Instrumentation.StackExchangeRedis 1.0.0-rc9.7

Runtime version: net6.0

Symptom

When a client cancels a request, I want to be able to set a 499 'Client Closed Request' status code for logging/telemetry purposes and shortcut the ASP.NET middle-ware pipeline to save time. This is described further in Andrew Lock's blog post here:

https://andrewlock.net/using-cancellationtokens-in-asp-net-core-minimal-apis/

What is the expected behavior?

I expect Open Telemetry to log the correct status code in http.status_code, so I can view telemetry and see all cancelled 499 responses.

What is the actual behavior?

A status code of zero is logged by Open Telemetry while Serilog is correctly logging 499.

image

Reproduce

Add this controller to an open telemetry project with a console exporter.

public class SomeController : ControllerBase
{
    [HttpGet("/foo")]
    public async Task Foo(CancellationToken cancellationToken)
    {
        try
        {
            await Task.Delay(10_000, cancellationToken);
        }
        catch (OperationCanceledException)
        when (cancellationToken.IsCancellationRequested)
        {
            this.HttpContext.Response.StatusCode = 499;
            this.HttpContext.Features.Get<IHttpActivityFeature>()?.Activity.AddEvent(new ActivityEvent("Cancelled"));
        }
    }
}
@RehanSaeed RehanSaeed added the bug Something isn't working label Aug 24, 2022
@DavidStevensWillow
Copy link

This has purposely been removed in the following fix: #2904

@RehanSaeed
Copy link
Author

@DavidStevensWillow That PR is talking about SpanStatus and seems to say nothing about the StatusCode.

@AlexandruRus23
Copy link

AlexandruRus23 commented Aug 30, 2022

I'm getting something similar as OpenTelemetry Status Code is 0 when Serilog Request logging reports it as a 302.
I don't have replication steps at the moment.

Edit: also noting that the status code is Error.

Copy link
Contributor

This issue was marked stale due to lack of activity and will be closed in 7 days. Commenting will instruct the bot to automatically remove the label. This bot runs once per day.

@github-actions github-actions bot added the Stale Issues and pull requests which have been flagged for closing due to inactivity label Sep 25, 2024
Copy link
Contributor

github-actions bot commented Oct 3, 2024

Closed as inactive. Feel free to reopen if this issue is still a concern.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Stale Issues and pull requests which have been flagged for closing due to inactivity
Projects
None yet
Development

No branches or pull requests

3 participants