Azure / Azure/azure-functions-host

No Application Insights entry created when Function Timeout hit

Open
#4,233 2 comments 5 reactions 0 assignees View on GitHub
needs-investigation
Dominant language
C#
Stars
2k
Forks
482
Avg merge
2d 10h
Merged PRs (30d)
36

Description

#### Investigative information

Please provide the following:

- Timestamp: 2019-03-25T00:25:49.474
- Function App version (1.0 or 2.0): 2.0
- Function App name: swtestimeoute
- Function name(s) (as appropriate): TimeoutTester
- Invocation ID: adec0bf4-d126-4b45-bb36-1ab9310e6806
- Region: West US 2
- Language: .Net

#### Repro steps

Executed the HTTP Triggered Function and it began running as expected. This simple Function was designed to test the behaviour when a Function hits its timeout, primarily around what hooks we might have to be notified of the failure with the expectation that Application Insights would be the go-to. See Source for sample.

#### Expected behavior

Function App times out and a log entry is written to Application Insights.

#### Actual behavior

Function App times out and *NO* log entry is written to Application Insights, though an entry does appear in the Function streaming logs:

2019-03-25T00:25:49.474 [Error] Timeout value of 00:05:00 exceeded by function 'Functions.TimeoutTester' (Id: 'adec0bf4-d126-4b45-bb36-1ab9310e6806'). Initiating cancellation.
2019-03-25T00:25:49.552 [Error] Executed 'Functions.TimeoutTester' (Failed, Id=adec0bf4-d126-4b45-bb36-1ab9310e6806)
Timeout value of 00:05:00 was exceeded by function: Functions.TimeoutTester

#### Known workarounds

None.

#### Related information

Source

```csharp
#r "Newtonsoft.Json"

using System.Net;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Primitives;
using System.Threading;
using Newtonsoft.Json;

public static async Task Run(HttpRequest req, ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request.");

string name = req.Query["name"];

for(int x = 0; x < 32; x++)
{
log.LogInformation("Sleeping for 20 seconds");
Thread.Sleep(20000);
}

string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
dynamic data = JsonConvert.DeserializeObject(requestBody);
name = name ?? data?.name;

return name != null
? (ActionResult)new OkObjectResult($"Hello, {name}")
: new BadRequestObjectResult("Please pass a name on the query string or in the request body");
}

```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the C# HTTP-triggered Function with the supplied five-minute timeout and compare the Function streaming logs with Application Insights. The work is done when a timed-out invocation produces an Application Insights log entry containing the failure, matching the streaming-log behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, csharp
Domain
backend, observability
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.