Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Niels Swimberghe 21 posts 104 karma points c-trib
    Oct 11, 2022 @ 04:40
    Niels Swimberghe
    0

    Exceptions not recorded in Azure Application Insights

    I added Azure Application Insights (AI) to my Umbraco 10 website:

    public void ConfigureServices(IServiceCollection services)
    {
        services.AddUmbraco(env, config)
            .AddBackOffice()
            .AddWebsite()
            .AddComposers()
            .AddAzureBlobMediaFileSystem()
            .Build();
    
        services.AddApplicationInsightsTelemetry();
    }
    

    I can see exceptions being logged in Umbraco using the Log Viewer, but those exceptions are not being recorded in AI.

    Any idea what I should do to get them into AI?

  • Matthew Wise 269 posts 1351 karma points MVP 3x c-trib
    Oct 11, 2022 @ 09:10
    Matthew Wise
    0

    Hi Niels,

    I have added services.AddApplicationInsightsTelemetry(); before services.AddUmbraco(_env, _config)

    I also set the Serilog sink via the appsettings.json

    "Serilog": {
            "MinimumLevel": {
                "Default": "Information",
                "Override": {
                    "Microsoft": "Warning",
                    "SixLabors.ImageSharp.Web.Middleware": "Warning",
                    "Microsoft.Hosting.Lifetime": "Information",
                    "System": "Warning"
                }
            },
            "Enrich": [
                "FromLogContext",
                "WithEnvironmentName"
            ],
            "WriteTo": [
                {
                    "Name": "ApplicationInsights",
                    "Args": {
                        "telemetryConverter": "Serilog.Sinks.ApplicationInsights.TelemetryConverters.TraceTelemetryConverter, Serilog.Sinks.ApplicationInsights"
                    }
                }
            ]
        },
        "ApplicationInsights": {
            "EnableAdaptiveSampling": false,
            "EnablePerformanceCounterCollectionModule": false
        },
    

    Hope this helps,

    Matt

  • Niels Swimberghe 21 posts 104 karma points c-trib
    Oct 11, 2022 @ 17:11
    Niels Swimberghe
    0

    I'll try putting services.AddApplicationInsightsTelemetry(); in front of adding Umbraco. I put it in this order because that's what the docs for Cloud say.

    I do have the Serilog sink already setup. I'll get back to you after collecting some more telemetry.

  • Niels Swimberghe 21 posts 104 karma points c-trib
    Oct 12, 2022 @ 00:59
    Niels Swimberghe
    0

    Unfortunately, an exception was still logged in Umbraco but not tracked in AI:

    System.FormatException: Input string was not in a correct format.
       at System.Number.ThrowOverflowOrFormatException(ParsingStatus status, TypeCode type)
       at System.Convert.ToDecimal(String value, IFormatProvider provider)
       at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
       at SixLabors.ImageSharp.Web.Commands.Converters.IntegralNumberConverter`1.ConvertFrom(CommandParser parser, CultureInfo culture, String value, Type propertyType)
       at SixLabors.ImageSharp.Web.Processors.QualityWebProcessor.Process(FormattedImage image, ILogger logger, CommandCollection commands, CommandParser parser, CultureInfo culture)
       at SixLabors.ImageSharp.Web.Processors.WebProcessingExtensions.Process(FormattedImage source, ILogger logger, IReadOnlyList`1 processors, CommandCollection commands, CommandParser parser, CultureInfo culture)
       at SixLabors.ImageSharp.Web.Middleware.ImageSharpMiddleware.ProcessRequestAsync(HttpContext httpContext, IImageResolver sourceImageResolver, ImageContext imageContext, CommandCollection commands, Boolean retry)
       at SixLabors.ImageSharp.Web.Middleware.ImageSharpMiddleware.ProcessRequestAsync(HttpContext httpContext, IImageResolver sourceImageResolver, ImageContext imageContext, CommandCollection commands, Boolean retry)
       at SixLabors.ImageSharp.Web.Middleware.ImageSharpMiddleware.Invoke(HttpContext httpContext, Boolean retry)
       at StackExchange.Profiling.MiniProfilerMiddleware.Invoke(HttpContext context) in C:\projects\dotnet\src\MiniProfiler.AspNetCore\MiniProfilerMiddleware.cs:line 121
       at Umbraco.Cms.Web.Common.Middleware.UmbracoRequestMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
       at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext()
    --- End of stack trace from previous location ---
       at Umbraco.Cms.Web.Common.Middleware.PreviewAuthenticationMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
       at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext()
    --- End of stack trace from previous location ---
       at Umbraco.Cms.Web.Common.Middleware.UmbracoRequestLoggingMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
       at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext()
    --- End of stack trace from previous location ---
       at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)
    
  • Jeavon Leopold 3062 posts 13533 karma points MVP 9x admin c-trib
    Oct 11, 2022 @ 10:55
    Jeavon Leopold
    0

    In addition to the configuration Matthew has posted you will need to install the Serilog Sink package - https://github.com/serilog-contrib/serilog-sinks-applicationinsights

    And ensure you have the environment variable APPLICATIONINSIGHTS_CONNECTION_STRING - https://github.com/serilog-contrib/serilog-sinks-applicationinsights#configuring-with-readfromconfiguration

  • Niels Swimberghe 21 posts 104 karma points c-trib
    Oct 11, 2022 @ 17:11
    Niels Swimberghe
    0

    I have this configured already, thank you!

Please Sign in or register to post replies

Write your reply to:

Draft