ApplicationInsights-dotnet: DependencyMetricsExtractor.ExtractMetrics threw exceptions

We observed the behavior in some ETL traces we collected. I attached one sample call stack.

“ExceptionMessage Cannot execute ExtractMetrics because this metrics extractor has not been initialized (no metrics manager).”

 + Thread (9800) CPU=72ms (.NET ThreadPool)
  + ntdll!?
   + kernel32!?
    + clr!Thread::intermediateThreadProc
     + clr!ThreadpoolMgr::ExecuteWorkRequest
      + clr!UnManagedPerAppDomainTPCount::DispatchWorkItem
       + picohelper!?
        + webengine4!?
         + ?!?
          + clr!UM2MDoADCallBack
           + clr!??Thread::DoADCallBack
            + clr!UM2MThunk_Wrapper
             + ?!?
              + system.web!PipelineRuntime.ProcessRequestNotification
               + system.web!PipelineRuntime.ProcessRequestNotificationHelper
                + system.web!dynamicClass.IL_STUB_PInvoke(int,value class System.Web.RequestNotificationStatus&)
                 + webengine4!?
                  + iiscore!?
                   + webengine4!?
                    + ?!?
                     + system.web!PipelineRuntime.ProcessRequestNotification
                      + system.web!PipelineRuntime.ProcessRequestNotificationHelper
                       + system.web!HttpRuntime.ProcessRequestNotificationPrivate
                        + system.web!HttpApplication.BeginProcessRequestNotification
                         + system.web!System.Web.HttpApplication+PipelineStepManager.ResumeSteps(class System.Exception)
                          + system.web!HttpApplication.ExecuteStep
                           + system.web!System.Web.HttpApplication+CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
                            + system.web.mvc!IHttpAsyncHandler.EndProcessRequest
                             + system.web.mvc!MvcHandler.EndProcessRequest
                              + system.web.mvc!System.Web.Mvc.Async.AsyncResultWrapper+<>c__DisplayClass4.<MakeVoidDelegate>b__3(class System.IAsyncResult)
                               + system.web.mvc!System.Web.Mvc.MvcHandler+<>c__DisplayClass8.<BeginProcessRequest>b__3(class System.IAsyncResult)
                                + system.web.mvc!IAsyncController.EndExecute
                                 + system.web.mvc!Controller.EndExecute
                                  + system.web.mvc!System.Web.Mvc.Async.AsyncResultWrapper+<>c__DisplayClass4.<MakeVoidDelegate>b__3(class System.IAsyncResult)
                                   + system.web.mvc!Controller.EndExecuteCore
                                    + system.web.mvc!System.Web.Mvc.Async.AsyncResultWrapper+<>c__DisplayClass4.<MakeVoidDelegate>b__3(class System.IAsyncResult)
                                     + system.web.mvc!System.Web.Mvc.Controller+<>c__DisplayClass1d.<BeginExecuteCore>b__18(class System.IAsyncResult)
                                      + system.web.mvc!AsyncControllerActionInvoker.EndInvokeAction
                                       + system.web.mvc!System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncResult`1[System.Boolean].End()
                                        + system.web.mvc!System.Web.Mvc.Async.AsyncControllerActionInvoker+<>c__DisplayClass25.<BeginInvokeAction>b__22(class System.IAsyncResult)
                                         + system.web.mvc!System.Web.Mvc.Async.AsyncControllerActionInvoker+<>c__DisplayClass25+<>c__DisplayClass2a.<BeginInvokeAction>b__20()
                                          + system.web.mvc!AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters
                                           + system.web.mvc!System.Web.Mvc.Async.AsyncControllerActionInvoker+<>c__DisplayClass37.<BeginInvokeActionMethodWithFilters>b__36(class System.IAsyncResult)
                                            + system.web.mvc!System.Web.Mvc.Async.AsyncControllerActionInvoker+<>c__DisplayClass4f.<InvokeActionMethodFilterAsynchronously>b__49()
                                             + system.web.mvc!System.Web.Mvc.Async.AsyncControllerActionInvoker+<>c__DisplayClass37+<>c__DisplayClass39.<BeginInvokeActionMethodWithFilters>b__33()
                                              + system.web.mvc!AsyncControllerActionInvoker.EndInvokeActionMethod
                                               + system.web.mvc!System.Web.Mvc.Async.AsyncResultWrapper+<>c__DisplayClass8`1[System.__Canon].<BeginSynchronous>b__7(class System.IAsyncResult)
                                                + system.web.mvc!System.Web.Mvc.Async.AsyncControllerActionInvoker+<>c__DisplayClass42.<BeginInvokeSynchronousActionMethod>b__41()
                                                 + system.web.mvc!ControllerActionInvoker.InvokeActionMethod
                                                  + anonymously hosted dynamicmethods assembly!dynamicClass.lambda_method(pMT: 19E0A4A4,pMT: 19DD4388,class System.Object[])
                                                   + fabrikamfiber.web!HomeController.Index
                                                    + fabrikamfiber.web!HomeController.InitializeMetaData
                                                     + fabrikamfiber.web!FabrikamFiberAzureStorage.GetStorageBlobData
                                                      + microsoft.windowsazure.storage!CloudBlobContainer.CreateIfNotExists
                                                       + microsoft.windowsazure.storage!CloudBlobContainer.CreateIfNotExists
                                                        + microsoft.windowsazure.storage!CloudBlobContainer.Create
                                                         + microsoft.windowsazure.storage!Executor.ExecuteSync
                                                          + system!HttpWebRequest.GetResponse
                                                           + mscorlib!DebuggerHiddenAttribute.ApplicationInsights_OnException
                                                            + microsoft.ai.dependencycollector!ProfilerHttpProcessing.OnExceptionForGetResponse
                                                             + microsoft.ai.dependencycollector!HttpProcessing.OnEnd
                                                              + microsoft.ai.dependencycollector!ClientServerDependencyTracker.EndTracking
                                                               + microsoft.applicationinsights!TelemetryClient.Track
                                                                + microsoft.ai.perfcountercollector!QuickPulseTelemetryProcessor.Process
                                                                 + microsoft.applicationinsights.exceptionexemplification!ExceptionExemplificationTelemetryProcessor.Process
                                                                  + microsoft.applicationinsights!AutocollectedMetricsExtractor.Process
                                                                   + microsoft.applicationinsights!AutocollectedMetricsExtractor.ExtractMetrics
                                                                    + microsoft.applicationinsights!DependencyMetricsExtractor.ExtractMetrics
                                                                     + clr!IL_Throw
                                                                      + clr!RaiseTheExceptionInternalOnly
                                                                       + ntdll!?
                                                                        + clr!COMPlusNestedExceptionHandler
                                                                         + clr!COMPlusFrameHandler
                                                                          + clr!CPFH_FirstPassHandler
                                                                           + clr!CPFH_RealFirstPassHandler
                                                                            + clr!Thread::StackWalkFrames
                                                                             + clr!Thread::StackWalkFramesEx
                                                                              + clr!COMPlusThrowCallback
                                                                               + clr!??ETW::ExceptionLog::ExceptionThrown
                                                                                + clr!CoTemplate_zzpqhh
                                                                                 + clr!EtwCallout
                                                                                  + EventData ExceptionType System.InvalidOperationException
                                                                                   + EventData ExceptionMessage Cannot execute ExtractMetrics because this metrics extractor has not been initialized (no metrics manager).
                                                                                    + Event Microsoft-Windows-DotNETRuntime/Exception/Start

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 23 (17 by maintainers)

Most upvoted comments

The code snippet suggested by @macrogreg resolved the issue for me as well. Here’s a slightly more elegant version:

public static void InitializeProcessorModules()
{
    var telemetryConfig = TelemetryConfiguration.Active;
    foreach (var module in telemetryConfig.TelemetryProcessors.OfType<ITelemetryModule>())
    {
      module.Initialize(telemetryConfig);
    }
}

I’m having the same issue: AI (Internal): [msg=Log Error];[msg=Error in RequestMetricsExtractor: System.InvalidOperationException: Cannot execute ExtractMetrics because this metrics extractor has not been initialized (no metrics manager). at Microsoft.ApplicationInsights.Extensibility.Implementation.Metrics.DependencyMetricsExtractor.ExtractMetrics(ITelemetry fromItem, Boolean& isItemProcessed) at Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor.ExtractMetrics(ITelemetry fromItem)]

No idea what can it be. My references are up to date. Suggestions?

This looks right @macrogreg?

TelemetryConfiguration.Active.TelemetryProcessorChainBuilder
    .Use((tp) => new IgnorePostDeployPrimingTelemetryProcessor(tp))
    .Build();
            
foreach (var processor in TelemetryConfiguration.Active.TelemetryProcessors)
{
    var telemetryModule = processor as ITelemetryModule;
    if (telemetryModule != null)
    {
        telemetryModule.Initialize(TelemetryConfiguration.Active);
    }
}

Yes, we should re-initialize all processors on the chain re-build

There is some serious problem with my configuration after upgrading to 2.4 version, not only AI (Internal) errors showed up in the appinsights from all of a sudden. But the image uploading stopped working (I’m using umbraco CMS with Azure Blong storage). It took me quite some time to find out, I was able to trace it back to update of Appisnights references.

version 2.2 AppinsightsConfig - https://pastebin.com/raw/ngQV7pR9 vesrion 2.4 AppinsightsConfig - https://pastebin.com/raw/Y4YB3Mnw

I aslo use this configuration during stratup

        Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.Active.InstrumentationKey =
            ConfigurationManager.AppSettings["InstrumentationKey"];
        Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.Active.TelemetryInitializers.Add(
            new AppInsightsInitializer());

        var builder = Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.Active.TelemetryProcessorChainBuilder;

        builder.Use(next => new NoSqlDependencies(next));
        builder.Use(next => new NoFastDependencies(next));

        builder.Build();

To eliminate fast dependencies, and also to eliminate SQL dependencies, because of the monthly data cap in azure free tier.

The code above fixed it.

But it feels like this should be handled automatically.