none
Nothing is related to the request by Operation Id

    Question

  • I have an Azure Cloud Service with Application Insights enabled. Dependencies, Trace and Request messages are correctly logged but they are not related to each other with the Operation Id.

    Installed NuGet packages:

      <package id="Microsoft.ApplicationInsights" version="2.0.0" targetFramework="net461" />
      <package id="Microsoft.ApplicationInsights.Agent.Intercept" version="1.2.1" targetFramework="net461" />
      <package id="Microsoft.ApplicationInsights.DependencyCollector" version="2.0.0" targetFramework="net461" />
      <package id="Microsoft.ApplicationInsights.JavaScript" version="0.22.9-build00167" targetFramework="net461" />
      <package id="Microsoft.ApplicationInsights.PerfCounterCollector" version="2.0.0" targetFramework="net461" />
      <package id="Microsoft.ApplicationInsights.TraceListener" version="2.0.0" targetFramework="net461" />
      <package id="Microsoft.ApplicationInsights.Web" version="2.0.0" targetFramework="net461" />
      <package id="Microsoft.ApplicationInsights.WindowsServer" version="2.0.0" targetFramework="net461" />
      <package id="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel" version="2.0.0" targetFramework="net461" />
      <package id="Microsoft.Azure.KeyVault.Core" version="1.0.0" targetFramework="net452" />
      <package id="Microsoft.Data.Edm" version="5.7.0" targetFramework="net452" />
      <package id="Microsoft.Data.OData" version="5.7.0" targetFramework="net452" />
      <package id="Microsoft.Data.Services.Client" version="5.7.0" targetFramework="net452" />
      <package id="Newtonsoft.Json" version="8.0.2" targetFramework="net452" />
      <package id="System.Spatial" version="5.7.0" targetFramework="net452" />
      <package id="WindowsAzure.Storage" version="6.2.0" targetFramework="net452" />


    My AI config:

    <?xml version="1.0" encoding="utf-8"?>
    <ApplicationInsights xmlns="http://schemas.microsoft.com/ApplicationInsights/2013/Settings">
      <TelemetryModules>
        <Add Type="Microsoft.ApplicationInsights.DependencyCollector.DependencyTrackingTelemetryModule, Microsoft.AI.DependencyCollector" />
        <Add Type="Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.PerformanceCollectorModule, Microsoft.AI.PerfCounterCollector">
          <!--
          Use the following syntax here to collect additional performance counters:
          
          <Counters>
            <Add PerformanceCounter="\Process(??APP_WIN32_PROC??)\Handle Count" ReportAs="Process handle count" />
            ...
          </Counters>
          
          PerformanceCounter must be either \CategoryName(InstanceName)\CounterName or \CategoryName\CounterName
          
          Counter names may only contain letters, round brackets, forward slashes, hyphens, underscores, spaces and dots.
          You may provide an optional ReportAs attribute which will be used as the metric name when reporting counter data.
          For the purposes of reporting, metric names will be sanitized by removing all invalid characters from the resulting metric name.
          
          NOTE: performance counters configuration will be lost upon NuGet upgrade.
          
          The following placeholders are supported as InstanceName:
            ??APP_WIN32_PROC?? - instance name of the application process  for Win32 counters.
            ??APP_W3SVC_PROC?? - instance name of the application IIS worker process for IIS/ASP.NET counters.
            ??APP_CLR_PROC?? - instance name of the application CLR process for .NET counters.
          -->
        </Add>
        <Add Type="Microsoft.ApplicationInsights.WindowsServer.DeveloperModeWithDebuggerAttachedTelemetryModule, Microsoft.AI.WindowsServer" />
        <Add Type="Microsoft.ApplicationInsights.WindowsServer.UnhandledExceptionTelemetryModule, Microsoft.AI.WindowsServer" />
        <Add Type="Microsoft.ApplicationInsights.WindowsServer.UnobservedExceptionTelemetryModule, Microsoft.AI.WindowsServer" />
        <Add Type="Microsoft.ApplicationInsights.Web.RequestTrackingTelemetryModule, Microsoft.AI.Web">
          <Handlers>
            <!-- 
            Add entries here to filter out additional handlers: 
            
            NOTE: handler configuration will be lost upon NuGet upgrade.
            -->
            <Add>System.Web.Handlers.TransferRequestHandler</Add>
            <Add>Microsoft.VisualStudio.Web.PageInspector.Runtime.Tracing.RequestDataHttpHandler</Add>
            <Add>System.Web.StaticFileHandler</Add>
            <Add>System.Web.Handlers.AssemblyResourceLoader</Add>
            <Add>System.Web.Optimization.BundleHandler</Add>
            <Add>System.Web.Script.Services.ScriptHandlerFactory</Add>
            <Add>System.Web.Handlers.TraceHandler</Add>
            <Add>System.Web.Services.Discovery.DiscoveryRequestHandler</Add>
            <Add>System.Web.HttpDebugHandler</Add>
          </Handlers>
        </Add>
        <Add Type="Microsoft.ApplicationInsights.Web.ExceptionTrackingTelemetryModule, Microsoft.AI.Web" />
      </TelemetryModules>
      <TelemetryChannel Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.ServerTelemetryChannel, Microsoft.AI.ServerTelemetryChannel" />
      <TelemetryProcessors>
        <Add Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.AdaptiveSamplingTelemetryProcessor, Microsoft.AI.ServerTelemetryChannel">
          <MaxTelemetryItemsPerSecond>5</MaxTelemetryItemsPerSecond>
        </Add>
      </TelemetryProcessors>
      <!-- 
        Learn more about Application Insights configuration with ApplicationInsights.config here: 
        http://go.microsoft.com/fwlink/?LinkID=513840
        
        Note: If not present, please add <InstrumentationKey>Your Key</InstrumentationKey> to the top of this file.
      -->
      <TelemetryInitializers>
        <Add Type="Microsoft.ApplicationInsights.WindowsServer.AzureRoleEnvironmentTelemetryInitializer, Microsoft.AI.WindowsServer" />
        <Add Type="Microsoft.ApplicationInsights.WindowsServer.DomainNameRoleInstanceTelemetryInitializer, Microsoft.AI.WindowsServer" />
        <Add Type="Microsoft.ApplicationInsights.WindowsServer.BuildInfoConfigComponentVersionTelemetryInitializer, Microsoft.AI.WindowsServer" />
        <Add Type="Microsoft.ApplicationInsights.Web.WebTestTelemetryInitializer, Microsoft.AI.Web" />
        <Add Type="Microsoft.ApplicationInsights.Web.SyntheticUserAgentTelemetryInitializer, Microsoft.AI.Web">
          <Filters>
            <Add Pattern="(YottaaMonitor|BrowserMob|HttpMonitor|YandexBot|BingPreview|PagePeeker|ThumbShotsBot|WebThumb|URL2PNG|ZooShot|GomezA|Catchpoint bot|Willow Internet Crawler|Google SketchUp|Read%20Later|KTXN|Pingdom|AlwaysOn)" />
            <Add Pattern="Slurp" SourceName="Yahoo Bot" />
            <Add Pattern="(bot|zao|borg|Bot|oegp|silk|Xenu|zeal|^NING|crawl|Crawl|htdig|lycos|slurp|teoma|voila|yahoo|Sogou|CiBra|Nutch|^Java/|^JNLP/|Daumoa|Genieo|ichiro|larbin|pompos|Scrapy|snappy|speedy|spider|Spider|vortex|favicon|indexer|Riddler|scooter|scraper|scrubby|WhatWeb|WinHTTP|^voyager|archiver|Icarus6j|mogimogi|Netvibes|altavista|charlotte|findlinks|Retreiver|TLSProber|WordPress|wsr\-agent|Squrl Java|A6\-Indexer|netresearch|searchsight|http%20client|Python-urllib|dataparksearch|Screaming Frog|AppEngine-Google|YahooCacheSystem|semanticdiscovery|facebookexternalhit|Google.*/\+/web/snippet|Google-HTTP-Java-Client)" SourceName="Spider" />
          </Filters>
        </Add>
        <Add Type="Microsoft.ApplicationInsights.Web.ClientIpHeaderTelemetryInitializer, Microsoft.AI.Web" />
        <Add Type="Microsoft.ApplicationInsights.Web.OperationNameTelemetryInitializer, Microsoft.AI.Web" />
        <Add Type="Microsoft.ApplicationInsights.Web.OperationCorrelationTelemetryInitializer, Microsoft.AI.Web" />
        <Add Type="Microsoft.ApplicationInsights.Web.UserTelemetryInitializer, Microsoft.AI.Web" />
        <Add Type="Microsoft.ApplicationInsights.Web.AuthenticatedUserIdTelemetryInitializer, Microsoft.AI.Web" />
        <Add Type="Microsoft.ApplicationInsights.Web.AccountIdTelemetryInitializer, Microsoft.AI.Web" />
        <Add Type="Microsoft.ApplicationInsights.Web.SessionTelemetryInitializer, Microsoft.AI.Web" />
      </TelemetryInitializers>
      <!-- This key is for Application Insights resource '[REMOVED]' in resource group '[REMOVED]' -->
      <InstrumentationKey>[REMOVED]</InstrumentationKey>
    </ApplicationInsights>


    I am stuck. According to the internet relations between telemetrics in the same request should happen for me automagically ?

    I have a standard WCF service I connect to

    var client = new SomeWcfServiceClient();
    var result = client.Get(
                    "foo",
                    "bar",
                    true,
                    false);

    In the Azure Portal both the request and dependency are logged but I cannot see any relationship between them (Calls to Remote Dependencies or Related Items on the Request details).

    Using TelemetryClient and TrackException / TrackTrace yields the same results, telemetrics are logged but not related to the request. All properties of the TelemetryClient have null fields


    O

    Thursday, April 28, 2016 8:34 PM

Answers

  • We also use App Insights in a WCF application (although not in Azure) and the Core/Web SDK's won't work if your looking for a simple plug and play setup.

    We have had success with a small WCF app using their new Labs SDK that has a dedicated WCF nuget package. It enables the kind of ease of setup and use that you would expect and works how they describe it. It is still relatively new but the code seems solid. I have included a link below to their GitHub project.

    https://github.com/Microsoft/ApplicationInsights-SDK-Labs/tree/master/WCF

    For a little extra background, we jumped on the App Insights bandwagon pretty early (pre 1.0) with a large internal hosted WCF application. This was before they did a lot of recent great work on telemetry correlation so we custom coded a WCF Behavior (MessageInspector) to create an instance of the TelemetryClient inside the AfterReceiveRequest method and assign the OperationId's at the Context level. We then used that TelemetryClient instance to track our Requests/Exceptions/Traces so all of the items would be related. We also piggy backed on WCF's OperationContext extensions that allows you to add custom objects that live throughout the WCF request/response lifecycle so that we could store the instance of the TelemetryClient on the incoming request and pull it back out during the BeforeSendReply method to record the outgoing response as well. The SDK-Labs WCF package similarly follows this kind of pattern but it does not do any tracing for you automatically.

    Even though I love the flexibility and control that this pattern gives us, if I had to do it over again now or start a new WCF project, I would use their Labs SDK.

    Hope that helps and good luck!


    --Josh

    Friday, April 29, 2016 2:49 PM

All replies

  • Hello Oscar,

    There are certain cases when automatic correlation does not work (e.g. some asynchronous dependency calls), you might've hit one of those cases.

    You may give a try to Operations API available in the latest AI SDK to manually correlate those telemetry items.

    You can find the usage example in AI SDK tests on GitHub.


    Dmitry Matveev

    Thursday, April 28, 2016 10:09 PM
    Owner
  • Thank you, but manual operations like TrackException and TrackTrace are the same, they are not related to the request and as I tried to show in the last screenshot, TelemetryClient has no Operation Id in its contect when I initialize it.

    O

    Friday, April 29, 2016 8:37 AM
  • I never mentioned that my Azure Cloud Service was a WCF service..... might this be related to my issues ?

    http://www.paasmag.com/2016/03/07/wcf-monitoring-with-application-insights/


    O

    Friday, April 29, 2016 9:11 AM
  • We also use App Insights in a WCF application (although not in Azure) and the Core/Web SDK's won't work if your looking for a simple plug and play setup.

    We have had success with a small WCF app using their new Labs SDK that has a dedicated WCF nuget package. It enables the kind of ease of setup and use that you would expect and works how they describe it. It is still relatively new but the code seems solid. I have included a link below to their GitHub project.

    https://github.com/Microsoft/ApplicationInsights-SDK-Labs/tree/master/WCF

    For a little extra background, we jumped on the App Insights bandwagon pretty early (pre 1.0) with a large internal hosted WCF application. This was before they did a lot of recent great work on telemetry correlation so we custom coded a WCF Behavior (MessageInspector) to create an instance of the TelemetryClient inside the AfterReceiveRequest method and assign the OperationId's at the Context level. We then used that TelemetryClient instance to track our Requests/Exceptions/Traces so all of the items would be related. We also piggy backed on WCF's OperationContext extensions that allows you to add custom objects that live throughout the WCF request/response lifecycle so that we could store the instance of the TelemetryClient on the incoming request and pull it back out during the BeforeSendReply method to record the outgoing response as well. The SDK-Labs WCF package similarly follows this kind of pattern but it does not do any tracing for you automatically.

    Even though I love the flexibility and control that this pattern gives us, if I had to do it over again now or start a new WCF project, I would use their Labs SDK.

    Hope that helps and good luck!


    --Josh

    Friday, April 29, 2016 2:49 PM