Azure / Azure/azure-functions-dotnet-extensions

Url is missing from appinsights logs for requests if use FunctionStartup

Open
#63 9 comments 0 reactions 0 assignees View on GitHub
Needs: attention :wave:
Dominant language
C#
Stars
81
Forks
50
PR merge metrics
No merged PRs in 30d

Description

1. Run any number of load on sandbox
2. Go to appinsights -> Logs
3. Query for the following -
requests | where cloud_RoleName contains "test" | order by duration desc | project itemType, cloud_RoleName, url, appName, timestamp, name, cloud_RoleInstance.

What we have observed - If Startup class inherit IWebJobStartup then we are getting URL in appinsights logs for request, but if Startup class inherit FunctionStartup then we are not getting Url in appinsights logs.

We want to use Startup class Inherit FunctionStartup as we have written so much code based upon that in so many services. And we want to use constructor DI which is not possible in IWebJobStartup (as per sample which I have).

![URL_Missing_AppInsights](https://user-images.githubusercontent.com/8199853/130759737-4bd5568f-b5c6-42c3-8685-12c23dec3c4b.png)

1. Getting URL in appinsight logs if we use below code in startup class

[assembly: WebJobsStartup(typeof(Startup))]
namespace TestApplicationWebJob.Infrastructure
{
[ExcludeFromCodeCoverage]
internal class Startup : IWebJobsStartup
{
static string appInstanceId = Guid.NewGuid().ToString();
public void Configure(IWebJobsBuilder builder)
{
#pragma warning disable CS0618 // Type or member is obsolete
builder.AddDependencyInjection(ConfigureServices);
builder.AddSwashBuckle(Assembly.GetExecutingAssembly(), opts =>
{

2. Not getting URL in appinsights logs, if we use below code in startup class

[assembly: FunctionsStartup(typeof(Startup))]
namespace TestApplicationFunc.Infrastructure
{
[ExcludeFromCodeCoverage]
public class Startup : FunctionsStartup
{
public override void Configure(IFunctionsHostBuilder builder)
{
RegisterServices(builder.Services);

builder.AddSwashBuckle(Assembly.GetExecutingAssembly(), opts =>
{
opts.SpecVersion = OpenApiSpecVersion.OpenApi3_0;
opts.Documents = new[]
{
new SwaggerDocument
{

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by comparing the two startup configurations shown in the issue: IWebJobsStartup and FunctionsStartup. Reproduce the request query in Application Insights with each configuration, then trace how request URLs are recorded and how dependency injection is registered. Done means URLs appear for requests when using FunctionsStartup without losing the required constructor DI 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
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.