Coder Social home page Coder Social logo

applicationinsights-sdk-labs's Introduction

ApplicationInsights-SDK-Labs

Application Insights experimental projects repository. Note that Azure Monitor only provides support when using the supported SDKs. We’re constantly assessing opportunities to expand our support for other languages, so follow our GitHub Announcements page to receive the latest SDK news.

How to use

All NuGet packages from this repository being hosted in the SDK Labs NuGet gallery.

Install NuGet in Visual Studio

If you’re using Visual Studio to manage NuGet package in your project, here’s what to do:

  1. Add the Application Insights SDK Labs package source to NuGet. Source: https://www.myget.org/F/applicationinsights-sdk-labs/nuget

nuget

  1. Check "Include prerelease" as all packages are marked as pre-release
  2. Find the NuGet you want to try out:

020

Install NuGet in command line package manager

If you are using the command line package manager this is all you need:

> Install-Package "Microsoft.ApplicationInsights.DependencyCallstacks" -Source "https://www.myget.org/F/applicationinsights-sdk-labs/" -Pre

applicationinsights-sdk-labs's People

Contributors

abaranch avatar alexfera avatar capfei avatar frackleton avatar jawn avatar macrogreg avatar mateoatr avatar mattmccleary avatar osvaldorosado avatar sergeykanzhelev avatar tomasr avatar upendras avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

applicationinsights-sdk-labs's Issues

How can i log data from the request in the request telemetry

I have a need to log some of the details of the request in Application Insights which will help me better track the web service requests.

I thought of logging it as CustomData in the request. I found the way to do so is by setting Context properties in the telemetry client.

I did so with the code below.

telemetry.Context.Properties["CustomGuid"] = data;
telemetry.TrackRequest(request);

But this logged a duplicate request with all the data i needed. But i dont want duplicate requests to be logged. I would like to get the custom data to be logged as part of the request telemetry originally logged.

Is there any way i can do this ?

WCF with AI SDK 2.2 uses some obsolete properties

@tomasr some of the properties got obsolete in 2.2. This needs to be fixed:

WCF\Shared\RequestTrackingTelemetryModule.cs(47):WCF\Shared\RequestTrackingTelemetryModule.cs(47,17): Error CS0618: 'RequestTelemetry.HttpMethod' is obsolete: 'Include http verb into request telemetry name and use custom properties to report http method as a dimension.'
WCF\Shared\ExceptionTrackingTelemetryModule.cs(52):WCF\Shared\ExceptionTrackingTelemetryModule.cs(52,17): Error CS0618: 'ExceptionTelemetry.HandledAt' is obsolete: 'Use custom properties to report exception handling layer'
WCF\Shared\ExceptionTrackingTelemetryModule.cs(52):WCF\Shared\ExceptionTrackingTelemetryModule.cs(52,39): Error CS0618: 'ExceptionHandledAt' is obsolete: 'Use custom properties to report exception handling layer'
WCF\Shared\ExceptionTrackingTelemetryModule.cs(56):WCF\Shared\ExceptionTrackingTelemetryModule.cs(56,17): Error CS0618: 'ExceptionTelemetry.HandledAt' is obsolete: 'Use custom properties to report exception handling layer'
WCF\Shared\ExceptionTrackingTelemetryModule.cs(56):WCF\Shared\ExceptionTrackingTelemetryModule.cs(56,39): Error CS0618: 'ExceptionHandledAt' is obsolete: 'Use custom properties to report exception handling layer'
WCF\Shared\RequestTrackingTelemetryModule.cs(47):WCF\Shared\RequestTrackingTelemetryModule.cs(47,17): Error CS0618: 'RequestTelemetry.HttpMethod' is obsolete: 'Include http verb into request telemetry name and use custom properties to report http method as a dimension.'
WCF\Shared\ExceptionTrackingTelemetryModule.cs(52):WCF\Shared\ExceptionTrackingTelemetryModule.cs(52,17): Error CS0618: 'ExceptionTelemetry.HandledAt' is obsolete: 'Use custom properties to report exception handling layer'
WCF\Shared\ExceptionTrackingTelemetryModule.cs(52):WCF\Shared\ExceptionTrackingTelemetryModule.cs(52,39): Error CS0618: 'ExceptionHandledAt' is obsolete: 'Use custom properties to report exception handling layer'
WCF\Shared\ExceptionTrackingTelemetryModule.cs(56):WCF\Shared\ExceptionTrackingTelemetryModule.cs(56,17): Error CS0618: 'ExceptionTelemetry.HandledAt' is obsolete: 'Use custom properties to report exception handling layer'
WCF\Shared\ExceptionTrackingTelemetryModule.cs(56):WCF\Shared\ExceptionTrackingTelemetryModule.cs(56,39): Error CS0618: 'ExceptionHandledAt' is obsolete: 'Use custom properties to report exception handling layer'

Log SQL command

When I've used Application Insights with ASP.NET applications, the SQL dependency logs include the actual SQL command/query that was sent to SQL Server. When using this package for a WCF service I see SQL dependencies being logged, but the command property only contains the server and database my app is hitting and not the actual SQL command/query. I get timing and frequency data, but that information isn't helpful without knowing what the source was. Is there a way to enable this or is this something that needs developed for this package?

OnBeginRequest Change

In order to log full message body with errors, IWcfTelemetryModule.OnBeginRequest should include Message request parameter. Here is the proposed change:

void OnBeginRequest(IOperationContext operation, Message request);

The parameters to the Event method do not match the parameters to the WriteEvent method - error

Hi, I cant see all requests on azure dashboard. When i attached debuger to service i discovered this message in Output Window:

The parameters to the Event method do not match the parameters to the WriteEvent method. This may cause the event to be displayed incorrectly.

Case study:

  • Every request have the same parameters
  • One request per 2 seconds
  • Only maybe 1 of 10 request is sended to azure correctly, other have error described above.
    I have newest version of SDK. .NET 4.0.

Getting System.NullReferenceException

I just added this package to my service and tested it. I am getting following exception just by adding this package dependency.

System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.ApplicationInsights.Wcf.Implementation.WcfOperationContext.DiscoverOperationName(OperationContext operationContext)
at Microsoft.ApplicationInsights.Wcf.Implementation.WcfOperationContext..ctor(OperationContext operationContext)
at Microsoft.ApplicationInsights.Wcf.Implementation.WcfOperationContext.GetContext()
at Microsoft.ApplicationInsights.Wcf.Implementation.WcfInterceptor.BeforeSendReply(Message& reply, Object correlationState)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.BeforeSendReplyCore(MessageRpc& rpc, Exception& exception, Boolean& thereIsAnUnhandledException)

VS2015: System.ArgumentNullException: Value cannot be null. Parameter name: service Provider at Microsoft.AppInsights.GettingStarted.Telemetry.SKUHelper.GetSKU

Hello,

I get this error each time, when I start VS2015 and opening a VB class file (.aspx.vb or .vb) the first time after starting VS2015. The error is only showing one time after each start of VS2015. The error only appears in version 7.18 of AppInsight, regardless if CodeLens is enabled or not. With version 7.12 this error doesn't appear.

The following entry is written in the ActivityLog.xml:

<entry>
    <record>1114</record>
    <time>2017/03/06 12:36:50.132</time>
    <type>Error</type>
    <source>Editor or Editor Extension</source>
    <description>System.ArgumentNullException: Value cannot be null.&#x000D;&#x000A;Parameter name: serviceProvider&#x000D;&#x000A;   
at Microsoft.AppInsights.GettingStarted.Telemetry.SKUHelper.GetSKU(IServiceProvider serviceProvider)&#x000D;&#x000A;   
at Microsoft.AppInsights.GettingStarted.CodeLens.CodeLensVBMarginProvider.CreateMargin(IWpfTextViewHost wpfTextViewHost, IWpfTextViewMargin marginContainer)&#x000D;&#x000A;   
at Microsoft.VisualStudio.Text.Utilities.ContainerMargin.&lt;AddMargins&gt;b__25_1(IWpfTextViewMarginProvider mp)&#x000D;&#x000A;   
at Microsoft.VisualStudio.Text.Utilities.GuardedOperations.InstantiateExtension[TExtension,TMetadata,TExtensionInstance](Object errorSource, Lazy`2 provider, Func`2 getter)</description>
  </entry>

Issue with self-hosted WCF

Hello!

I'm having an issue when using AI.WCF with a self-hosted WCF Service.
In my Service method, I'm using OperationContext.Current.GetRequestTelemetry() to get the current RequestTelemetry object so that I can add custom properties.
If I call the method in short intervals, I getting the same RequestTelemetry object from the previous call instead of a new object. The Service is set to InstanceContextMode.PerCall.
The exact same Service when run as an IIS-hosted WCF-Service does not show this behaviour.

Any ideas?

Thanks
Alexander

Wcf DependencyTracking and regular Dependency Tracking TelemetryModule

Hi,

I have question regarding the two dependency tracking modules that exist in both AI.WCF and regular Application Insight. First of all I am wondering whether the two modules are built to live together? I have read some comments that the two are not working together very well .(#72). It this still the situation as of now? It looks to be a very viable scenario that one would need both WCF and SQL depenedency tracking.

What I do see is that I get double dependencies tracked if I enable both. (WCF Channel Open, WCF Service Call, WCF Service). WCF Service is originating from the original AI dependency tracking and the others by AI.WCF.

I could ofcourse disable the default Dependency module but losing tracking of non-wcf dependencies (like SQL, REST). Is there any (future) way to have the best of both worlds (no double dependencies but still trace SQL and REST) ?

Regards,

Martin

WCF limitation - actual?

Hi @tomasr

Is this limitation is still actual:

Tracking WCF services in a single application where you're already using the Web Applications SDK is not supported

I thought it is gone and can be removed from readme

build break

@tomasr can you pls take a look

WCF\Shared.Tests\WcfEventSourceTests.cs(25):WCF\Shared.Tests\WcfEventSourceTests.cs(25,0): Error CA1305: Microsoft.Globalization : Because the behavior of 'string.Format(string, object)' could vary based on the current user's locale settings, replace this call in 'WcfEventSourceTests.InitializationFailure_Message()' with a call to 'string.Format(IFormatProvider, string, params object[])'. If the result of 'string.Format(IFormatProvider, string, params object[])' will be displayed to the user, specify 'CultureInfo.CurrentCulture' as the 'IFormatProvider' parameter. Otherwise, if the result will be stored and accessed by software, such as when it is persisted to disk or to a database, specify 'CultureInfo.InvariantCulture'.
WCF\Shared.Tests\WcfEventSourceTests.cs(107):WCF\Shared.Tests\WcfEventSourceTests.cs(107,0): Error CA1305: Microsoft.Globalization : Because the behavior of 'string.Format(string, object)' could vary based on the current user's locale settings, replace this call in 'WcfEventSourceTests.LocationIdSet_Message()' with a call to 'string.Format(IFormatProvider, string, params object[])'. If the result of 'string.Format(IFormatProvider, string, params object[])' will be displayed to the user, specify 'CultureInfo.CurrentCulture' as the 'IFormatProvider' parameter. Otherwise, if the result will be stored and accessed by software, such as when it is persisted to disk or to a database, specify 'CultureInfo.InvariantCulture'.
WCF\Shared.Tests\WcfEventSourceTests.cs(119):WCF\Shared.Tests\WcfEventSourceTests.cs(119,0): Error CA1305: Microsoft.Globalization : Because the behavior of 'string.Format(string, object, object)' could vary based on the current user's locale settings, replace this call in 'WcfEventSourceTests.OperationContextCreated_Message()' with a call to 'string.Format(IFormatProvider, string, params object[])'. If the result of 'string.Format(IFormatProvider, string, params object[])' will be displayed to the user, specify 'CultureInfo.CurrentCulture' as the 'IFormatProvider' parameter. Otherwise, if the result will be stored and accessed by software, such as when it is persisted to disk or to a database, specify 'CultureInfo.InvariantCulture'.
WCF\Shared.Tests\WcfEventSourceTests.cs(85):WCF\Shared.Tests\WcfEventSourceTests.cs(85,0): Error CA1305: Microsoft.Globalization : Because the behavior of 'string.Format(string, object, object, object)' could vary based on the current user's locale settings, replace this call in 'WcfEventSourceTests.OperationIgnored_Message()' with a call to 'string.Format(IFormatProvider, string, params object[])'. If the result of 'string.Format(IFormatProvider, string, params object[])' will be displayed to the user, specify 'CultureInfo.CurrentCulture' as the 'IFormatProvider' parameter. Otherwise, if the result will be stored and accessed by software, such as when it is persisted to disk or to a database, specify 'CultureInfo.InvariantCulture'.
WCF\Shared.Tests\WcfEventSourceTests.cs(131):WCF\Shared.Tests\WcfEventSourceTests.cs(131,0): Error CA1305: Microsoft.Globalization : Because the behavior of 'string.Format(string, object, object)' could vary based on the current user's locale settings, replace this call in 'WcfEventSourceTests.RequestMessageClosed_Message()' with a call to 'string.Format(IFormatProvider, string, params object[])'. If the result of 'string.Format(IFormatProvider, string, params object[])' will be displayed to the user, specify 'CultureInfo.CurrentCulture' as the 'IFormatProvider' parameter. Otherwise, if the result will be stored and accessed by software, such as when it is persisted to disk or to a database, specify 'CultureInfo.InvariantCulture'.
WCF\Shared.Tests\WcfEventSourceTests.cs(143):WCF\Shared.Tests\WcfEventSourceTests.cs(143,0): Error CA1305: Microsoft.Globalization : Because the behavior of 'string.Format(string, object, object)' could vary based on the current user's locale settings, replace this call in 'WcfEventSourceTests.ResponseMessageClosed_Message()' with a call to 'string.Format(IFormatProvider, string, params object[])'. If the result of 'string.Format(IFormatProvider, string, params object[])' will be displayed to the user, specify 'CultureInfo.CurrentCulture' as the 'IFormatProvider' parameter. Otherwise, if the result will be stored and accessed by software, such as when it is persisted to disk or to a database, specify 'CultureInfo.InvariantCulture'.
WCF\Shared.Tests\WcfEventSourceTests.cs(62):WCF\Shared.Tests\WcfEventSourceTests.cs(62,0): Error CA1305: Microsoft.Globalization : Because the behavior of 'string.Format(string, object, object, object)' could vary based on the current user's locale settings, replace this call in 'WcfEventSourceTests.TelemetryModuleExecutionFailed_Message()' with a call to 'string.Format(IFormatProvider, string, params object[])'. If the result of 'string.Format(IFormatProvider, string, params object[])' will be displayed to the user, specify 'CultureInfo.CurrentCulture' as the 'IFormatProvider' parameter. Otherwise, if the result will be stored and accessed by software, such as when it is persisted to disk or to a database, specify 'CultureInfo.InvariantCulture'.
WCF\Shared.Tests\WcfEventSourceTests.cs(37):WCF\Shared.Tests\WcfEventSourceTests.cs(37,0): Error CA1305: Microsoft.Globalization : Because the behavior of 'string.Format(string, object, object)' could vary based on the current user's locale settings, replace this call in 'WcfEventSourceTests.TelemetryModuleExecutionStarted_Message()' with a call to 'string.Format(IFormatProvider, string, params object[])'. If the result of 'string.Format(IFormatProvider, string, params object[])' will be displayed to the user, specify 'CultureInfo.CurrentCulture' as the 'IFormatProvider' parameter. Otherwise, if the result will be stored and accessed by software, such as when it is persisted to disk or to a database, specify 'CultureInfo.InvariantCulture'.
WCF\Shared.Tests\WcfEventSourceTests.cs(49):WCF\Shared.Tests\WcfEventSourceTests.cs(49,0): Error CA1305: Microsoft.Globalization : Because the behavior of 'string.Format(string, object, object)' could vary based on the current user's locale settings, replace this call in 'WcfEventSourceTests.TelemetryModuleExecutionStopped_Message()' with a call to 'string.Format(IFormatProvider, string, params object[])'. If the result of 'string.Format(IFormatProvider, string, params object[])' will be displayed to the user, specify 'CultureInfo.CurrentCulture' as the 'IFormatProvider' parameter. Otherwise, if the result will be stored and accessed by software, such as when it is persisted to disk or to a database, specify 'CultureInfo.InvariantCulture'.
WCF\Shared.Tests\WcfEventSourceTests.cs(96):WCF\Shared.Tests\WcfEventSourceTests.cs(96,0): Error CA1305: Microsoft.Globalization : Because the behavior of 'string.Format(string, object)' could vary based on the current user's locale settings, replace this call in 'WcfEventSourceTests.WcfTelemetryInitializerLoaded_Message()' with a call to 'string.Format(IFormatProvider, string, params object[])'. If the result of 'string.Format(IFormatProvider, string, params object[])' will be displayed to the user, specify 'CultureInfo.CurrentCulture' as the 'IFormatProvider' parameter. Otherwise, if the result will be stored and accessed by software, such as when it is persisted to disk or to a database, specify 'CultureInfo.InvariantCulture'.
WCF\Shared.Tests\WcfEventSourceTests.cs(164):WCF\Shared.Tests\WcfEventSourceTests.cs(164,0): Error CA1305: Microsoft.Globalization : Because the behavior of 'string.Format(string, params object[])' could vary based on the current user's locale settings, replace this call in 'WcfEventSourceTests.WcfEventListener.OnEventWritten(EventWrittenEventArgs)' with a call to 'string.Format(IFormatProvider, string, params object[])'. If the result of 'string.Format(IFormatProvider, string, params object[])' will be displayed to the user, specify 'CultureInfo.CurrentCulture' as the 'IFormatProvider' parameter. Otherwise, if the result will be stored and accessed by software, such as when it is persisted to disk or to a database, specify 'CultureInfo.InvariantCulture'.

[AzureWeAppCounters] CPU counters seems to be incorrect

There are two CPU counters:

\Processor(_Total)% Processor Time
\Process(??APP_WIN32_PROC??)% Processor Time

Looking in the code it seems we only support the first one: https://github.com/Microsoft/ApplicationInsights-SDK-Labs/blob/azureWebAppCounters/AggregateMetrics/AggregateMetrics/AzureWebApp/Implementation/CounterFactory.cs#L40 However I believe it may be incorrect and values we get from JSON are for the current process, not for the entire sandbox.

Please validate which one we can actually collect for Azure

App Insights should provide a PowerShell Module

Opened from AppInsights Home Issue

As a developer, I would like to use Application Insights from PowerShell, so that I can combine my applications telemetry with any infrastructure telemetry. I also would like to start instrumenting my scripts with Application Insights, so that I can get more insights into how people are using the code I share.

I think there is a lot of value in using App Insights from PowerShell scripts, but there are two areas that could be improved for a more natural PowerShell experience

  1. Creating a new telemetry client
# Today
Add-Type -Path "$Path\lib\net45\Microsoft.ApplicationInsights.dll" 
$ai = New-Object -TypeName Microsoft.ApplicationInsights.TelemetryClient
$ai.InstrumentationKey = "iKey"
# Ideal
$ai = New-TelemetryClient -InstrumentationKey "iKey"
  1. Using Hashtables is more natural in PowerShell, but not supported in the native SDK.
# Today
$ai.TrackEvent('event', @{customProperty='PowerShell!'})

Cannot find an overload for "TrackEvent" and the argument count: "2".
At line:1 char:1
+ $ai.TrackEvent('event', @{customProperty='PowerShell!'})
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
# Ideal
$ai.TrackEvent('event', @{customProperty='PowerShell!'})

I think that App Insights should provide a PowerShell Module that allows developers / IT pros to more easily collaborate for application telemetry.

Custom Dependency Tracking in Application Insights

I am using ApplicationInsights WCF SDK for monitoring my service. There are some dependency calls in the service like SQL, HTTP calls etc and they are automatically getting tracked. I was trying to track more dependencies to the request like the cache calls using the below code

         client = new TelemetryClient();
         try
        {
            dependencyCall;
        }
        finally
        {
            client.TrackDependency("DependencyName", "CommandName", startTime, stopwatch.Elapsed, true);
        }

I can see the dependency getting tracked in Application Insights. When i made the service request, only the automatic dependencies are linked to the original request. The custom dependencies are not linked to the original request and i showing as a new request.

How can i make the custom dependency to get linked to the main request.? Is it because the TelemetryClient is getting initialized at the class/method level.

Framework installed on server :4.6.2
Target Framework of the service : 4.5.2

App Insights and .NET 4.6.1 in a Worker Role in emulator -- exception

Hi,
First thanks for answering my question about NetMessagingBinding, etc.

I started with a worker role built targeting .NET 4.6.1 that successfully installs .NET 4.6.1 and can run OK in the emulator or in Azure.

Then I added app Insights Window Server assemblies via nuget to it, including manually upgrading App Insights Agent Intercept to 2.0.1 (in trying to get it to run). No luck. It crashes in the emulator with the following exception message:

System.IO.FileLoadException was unhandled
Message: An unhandled exception of type 'System.IO.FileLoadException' occurred in Microsoft.WindowsAzure.ServiceRuntime.dll
Additional information: Could not load file or assembly 'Microsoft.ApplicationInsights, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Then I removed all the App Insight assemblies via NuGet and reinstalled them and got the same error message.

Can you point me in the right direction to using .NET 4.6.1, and eventually using a worker role to host a WCF service using the NetMessagingBinding and .NET 4.6.1, plus use App Insights (which is quite useful!). FYI I have successfully done all of that except when I add the App Insights assemblies the emulator crashes!

Thanks,
George

Catching handeled exceptions

Consider OperationContract, where Exception are catched and logged. By default, Application Insights SDK WCF Telemetry will mark this as succeeded request.

What would be best way to modify this behavior and mark this telemetry event as Exception? And also attach details about exception to this event?

Thanks.

// When called with 0, telemetry AppInsights event should be Exception.
public string GetData(int value)
{
     try
     {
          if (value ==0)
          {
               throw new ArgumentException();
          }
          return string.Format("You entered: {0}");
      }
      catch (Exception ex)
      {
            Logger.Log(ex);
            return string.Format("Request failed");
      }            
}

ArgumentNullException on Telemetry Initialize

I am using AppInsights WCF in my service. I am noticing exceptions getting thrown from AppInsights while initializing telemetry. Exception happens in the IsClientSideContext method where context is going as null.

The error happens for the following

  • OperationNameTelemetryInitializer
  • OperationCorrelationTelemetryInitializer
  • UserTelemetryInitializer
  • UserAgentTelemetryInitializer
  • ClientIpTelemetryInitializer

Application Insights WCF Version : 0.26.0.16866

Can you please help me with this issue

Please find the StackTrace below for OperationNameTelemetryInitializer.

[msg=Log Error];[msg=Exception while initializing Microsoft.ApplicationInsights.Wcf.OperationNameTelemetryInitializer, exception message - System.ArgumentNullException: Value cannot be null.
Parameter name: context
at Microsoft.ApplicationInsights.Wcf.OperationContextExtensions.IsClientSideContext(OperationContext context) in D:\A_work\35\s\WCF\Shared\OperationContextExtensions.cs:line 43
at Microsoft.ApplicationInsights.Wcf.Implementation.WcfOperationContext.GetContext() in D:\A_work\35\s\WCF\Shared\Implementation\WcfOperationContext.cs:line 108
at Microsoft.ApplicationInsights.Wcf.Implementation.WcfOperationContext.get_Current() in D:\A_work\35\s\WCF\Shared\Implementation\WcfOperationContext.cs:line 44
at Microsoft.ApplicationInsights.Wcf.WcfTelemetryInitializer.Initialize(ITelemetry telemetry) in D:\A_work\35\s\WCF\Shared\WcfTelemetryInitializer.cs:line 28
at Microsoft.ApplicationInsights.TelemetryClient.Initialize(ITelemetry telemetry)]

Works with Live Stream?

Will this package work with/support the latest Live Stream features of AppInsights 2.1?
I cannot determine if those features are a part of the Web SDK (which this "replaces") or not.

Operation name shows up as * for webHttpBinding service

We are using the Application Insights WCF nuget package for two services in our application. One services is HTTP and the other is HTTPS. The telemetry for our HTTP service shows both the services name and the operation name, which is what we need. For example:

SafeService.GetWorksheetDto

However the HTTPS WCF service will not show the operation name - only "*". For example:

SafeMobileService.*

WCF Client Dependency Tracking failing on catch-all operations

On the dependency tracking, if the call is through the catch all ("*") operation of a service contract, the call with fail with the following exception:

System.ServiceModel.FaultException`1[System.ServiceModel.ExceptionDetail]: Value cannot be null.
Parameter name: telemetry (Fault Detail is equal to An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:
System.ArgumentNullException: Value cannot be null.
Parameter name: telemetry

Server stack trace:
   at Microsoft.ApplicationInsights.Wcf.Implementation.MessageCorrelator.Add(UniqueId messageId, DependencyTelemetry telemetry, TimeSpan timeout) in E:\A\_work\24\s\WCF\Shared\Implementation\MessageCorrelator.cs:line 33
   at Microsoft.ApplicationInsights.Wcf.Implementation.ClientTelemetryDuplexChannel.BeginSend(Message message, TimeSpan timeout, AsyncCallback callback, Object state) in E:\A\_work\24\s\WCF\Shared\Implementation\ClientTelemetryDuplexChannel.cs:line 114
   at System.ServiceModel.Dispatcher.DuplexChannelBinder.BeginRequest(Message message, TimeSpan timeout, AsyncCallback callback, Object state)

This is because the ClientContract class is not finding a match for the SoapAction header.

Dependencies not getting linked to the request

I am using ApplicationInsights WCF SDK for monitoring my service. I can see that dependencies of the requests are not getting linked to the original request.

The test service has following remote dependencies.

  • Geocoding using Bing Map service Api
  • Database from data is fetched
  • Service logging into another database

When looking into the AppInsights. i can the request and dependencies. But the dependencies doesn't have link to the request. It looks like an independent telemetry.

See the screenshot attached.
dependenciesinwcf

Attaching the JSON calls captured using fiddler.

request.json.txt
SPdependency.json.txt

Here i cant find anything linking both the requests.

NB:
All the remote calls are asychronous calls using async awaits.
NET Framework: 4.5.2
Status monitor is installed on the server
Version : 0.26.0.16866

System.ObjectDisposedException

There are lots of such traces are getting logged in app insights.

AI (Internal): [msg=Log Error];[msg=Exception while initializing Microsoft.ApplicationInsights.Wcf.UserAgentTelemetryInitializer, exception message - System.ObjectDisposedException: Message is closed.
at System.ServiceModel.Channels.BufferedMessage.get_Properties()
at Microsoft.ApplicationInsights.Wcf.Implementation.WcfOperationContext.HasIncomingMessageProperty(String propertyName)
at Microsoft.ApplicationInsights.Wcf.Implementation.WcfExtensions.GetHttpRequestHeaders(IOperationContext operation)
at Microsoft.ApplicationInsights.Wcf.UserAgentTelemetryInitializer.OnInitialize(ITelemetry telemetry, IOperationContext operation)
at Microsoft.ApplicationInsights.TelemetryClient.Initialize(ITelemetry telemetry)]

[AzureWeAppCounters] Unit tests failing after files renaming

@mateoatr, now unit tests started failing:

Test Name:  RateCounterGaugeGetValueAndResetWorking
Test FullName:  AggregateMetrics.Tests.AzureWebApp.RateCounterTests.RateCounterGaugeGetValueAndResetWorking
Test Source:    C:\src\github\ApplicationInsights-SDK-Labs\AggregateMetrics\AggregateMetrics.Tests\AzureWebApp\RateCounterTests.cs : line 13
Test Outcome:   Failed
Test Duration:  0:00:00.0577524

Result StackTrace:  
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize, Boolean checkHost)
   at System.IO.File.InternalReadAllText(String path, Encoding encoding, Boolean checkHost)
   at System.IO.File.ReadAllText(String path)
   at AggregateMetrics.Tests.AzureWebApp.CacheHelperTests..ctor() in C:\src\github\ApplicationInsights-SDK-Labs\AggregateMetrics\AggregateMetrics.Tests\AzureWebApp\CacheHelperTests.cs:line 12
   at AggregateMetrics.Tests.AzureWebApp.RateCounterTests.RateCounterGaugeGetValueAndResetWorking() in C:\src\github\ApplicationInsights-SDK-Labs\AggregateMetrics\AggregateMetrics.Tests\AzureWebApp\RateCounterTests.cs:line 13
Result Message: 
Test method AggregateMetrics.Tests.AzureWebApp.RateCounterTests.RateCounterGaugeGetValueAndResetWorking threw exception: 
System.IO.FileNotFoundException: Could not find file 'C:\src\github\bin\Release\AggregateMetrics\AggregateMetrics.Tests\AzureWebApp\SampleFiles\RemoteEnvironmentVariablesSampleOne.txt'.

Does this also work with WCF Data Services?

We have a WCF OData service and I tried to install Microsoft.ApplicationInsights.WCF in it. While, there were no errors, I couldn't see any tracking data.

Following the same steps on a vanilla WCF Service works for me.

So does this work on WCF Data Services by changing some configuration? If not, is there a similar package for the same?

Update WCF to v2.3.0 SDK

Should update WCF SDK to target the v2.3.0 SDK recently released.

Also update dependency on Profiler Agent to 2.0.7, which is version required by same SDK.

GetRequestTelemetry() doesn't work with aysnc/await

When OperationContext.Current.GetRequestTelemetry() is used in an asynchronous WCF service, it won't be available after the first await operation. Most WCF services don't have a synchronization context -which is a good thing for scalability and performance- so the operation context won't be restored after an awaited call completes.

It seems that the underlying WcfOperationContext properly uses the CallContext, which flows properly with awaited code, but it is marked as internal and cannot be accessed from the outside. I did some digging around, but the request is available in the call-context after awaited calls.

When I add the following watch, then I can see the request (even after an awaited call):

((Microsoft.ApplicationInsights.Wcf.Implementation.WcfOperationContext)((System.Runtime.Remoting.ObjectHandle)System.Runtime.Remoting.Messaging.CallContext.LogicalGetData("AIWcfOperationContext")).WrappedObject).Request

I don't know about the implementation details of the underlying WcfOperationContext class, so I didn't write a pull-request.

Builds broken in VS2017

Just ran into this: Opening the solutions in VS2017 is currently broken; VS will think that the <IntermediateOutputPath> is not set, causing it to try to modify the project files on open. Builds are broken with the matching MSBuild because <BaseIntermediatePath> does not get set correctly and ends up pointing somewhere under Program Files.

The cause of the issue is a change in MSBuild: dotnet/msbuild#1525

This is triggered by line 70 in Globals.props:

        <BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)' == '' ">$(EnlistmentRoot)\..\obj</BaseIntermediateOutputPath>

Specifically, the condition returns false (since it now has a value by default), so all the intermediate path settings after that yield the wrong result.

Seems like removing the condition would be the simplest fix, as I can't see a case where to avoid setting it always.

Thoughts?

[AzureWeAppCounters] cleanup for Mateo

  1. File names should be the same as class names
  2. Only public class should be PerformanceCollectorModule (and obviously PerformanceCounterCollectionRequest as it's public contract) - everything else internal. Move internal classes into Implementation folder
  3. Populate Counters collection with the default counters in constructor
  4. Rename FlexiblePerformanceCounterGauge to PerformanceCounterFromJsonGauge
  5. Initialize PerformanceCounterFromJsonGauge with both - name of the counter and the name of the environment variable (one of AzureWebApEnvironmentVariables)
  6. Rename ICacheHelper to 'ICachedEnvironmentVariableAccess`
  7. Implement alternative implementation for unit tests that doesn't require access to remoteenvironmentvariables.azurewebsites.net/
  8. Enable StyleCop for the project and fix StyleCop issues

Incomming and outgoing request of a WCF service

Hi,

I have a small question regarding message logging in WCF. Is it possible to log the incomming and outgoing request of a SOAP message? What I have done so far is setup MessageLogging trough the existing diagnostic mechanisms of WCF and try to hook this into application insight.

 <diagnostics>
      <messageLogging logEntireMessage="true"
              logMalformedMessages="true"
              logMessagesAtServiceLevel="true"
              logMessagesAtTransportLevel="false"
              maxMessagesToLog="500"
              maxSizeOfMessageToLog="-1"/>
    </diagnostics>

and

<system.diagnostics>
    <trace autoflush="true" indentsize="0">
      <listeners>
        <add name="myAppInsightsListener"/>
      </listeners>
    </trace>
    <sources>
      <source name="System.ServiceModel.MessageLogging" switchName="sourceSwitch" >
        <listeners>
          <add name="myAppInsightsListener" />
          <remove name="Default"/>
        </listeners>
      </source>
    </sources>
    <switches>
      <add name="sourceSwitch" value="All"/>
    </switches>
    <sharedListeners>
      <add name="myAppInsightsListener" type="Microsoft.ApplicationInsights.TraceListener.ApplicationInsightsTraceListener, Microsoft.ApplicationInsights.TraceListener" />      
    </sharedListeners>
  </system.diagnostics>

What this does is send a whole lot of data to AI and that seems encouraging at first. However, some of the data sent to AI does not contain the ai.operation.name. This seems to result in the message not beeing shown in AI together with the request. Some messages that do contain this ai.operation.name are shown correctly. The reponse of the soap call are in this way logged as a trace, but the incomming request (only way I found was throught ServiceLevelReceiveRequest) does not.

Is there any other way to achieve this? Or maybe i am missing a complete concept here. Is there another way? Our goal here is to be able to trace incomming and outgoing message (SOAP message) of our WCF webservice on our OTA environments.

Hope someone can offer some advice.

Regards, Martin

Not getting App Insights Requests

I just took by newly created WCF service without App Insights, added the SDK, and set up the instrumentation key.

When I look on the Azure portal, I see Dependency events from when I call into SQL Server, and includes the web service method name, however I get no Request events.

WcfDependencyTrackingTelemetryModule has slow leak that causes requests to fail

I've noticed that after using Microsoft.ApplicationInsights.Wcf.WcfDependencyTrackingTelemetryModule for quite some time to track WCF dependency calls that it starts to fail requests. It doesn't fail all requests, only requests on particular services.

  • The services in question don't have anything distinguishing about their ServiceContracts: they're simple, duplex operations with only the name of the operations explicitly specificed and namespace explicitly specified in the Service Contract.
  • Operations in question are async and return Tasks.
  • The bindings in use are BasicHttpRelayBindings with Azure WCF Relays.
  • QuickPulseTelemetry is disabled and 100% of the telemetry is going through to App Insights with no filtering (needed because the developers being used on the project relatively inexperienced with debugging practices)
  • Version in use is 0.27.0-build15663
  • .NET framework version in use is 4.6.2 on all machines, but target in the build is 4.6.1

[AzureWeAppCounters] Trace UserActionable trace message if counter is not supported so it will be easier to troubleshoot

  1. Create an EventSource like this: https://github.com/Microsoft/ApplicationInsights-SDK-Labs/blob/customCounters/AggregateMetrics/AggregateMetrics/AggregateMetricsEventSource.cs Keep Microsoft-ApplicationInsights-Extensibility prefix
  2. Define Error-level event marked as UserActionable that will say something like "Counter {0} is not supported by Azure Web App" and pass the counters name
  3. Report this error from Module

Is there easy way to detect WCF from HttpModule

@tomasr - is there an easy way to detect that the request was processed by WCF infra from HttpModule? I am looking for a way to notify WCF users that they need to install WCF NuGet for better information collection from the standard ApplicationInsights.Web NuGet.

I'm thinking maybe some routing information got stored in HttpContext or something like this.

DependencyCallStacks loading error

I'm getting an error when adding DependencyCallStacks to my ApplicationInsights.config. It looks like AI wont load the DLL, but the Fusion assembly binding log indicates that the Microsoft.AI.DependencyCallstacks.dll was loaded successfully.

The Windows event log contains this stack trace:

Service cannot be started. System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: Type 'Microsoft.ApplicationInsights.DependencyCallstacksTelemetryInitializer, Microsoft.AI.DependencyCallstacks' could not be loaded.
   at Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryConfigurationFactory.CreateInstance(Type interfaceType, String typeName)
   at Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryConfigurationFactory.LoadInstance(XElement definition, Type expectedType, Object instance)
   at Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryConfigurationFactory.LoadInstances[T](XElement definition, ICollection`1 instances)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] a...

How can I trace what's going on? This doesn't happen when running the code in VS, only on the server running the software I want to track.

build error

cc: @tomasr

WCF\Shared\Implementation\ChannelAsyncResult.cs(101):WCF\Shared\Implementation\ChannelAsyncResult.cs(101,1): Error : SA0102 : CSharp.CsParser : A syntax error has been discovered in file E:\A\_work\36\s\WCF\Shared\Implementation\ChannelAsyncResult.cs on line 101.
WCF\Shared\Implementation\ClientTelemetryChannelBase.cs(306):WCF\Shared\Implementation\ClientTelemetryChannelBase.cs(306,1): Error : SA0102 : CSharp.CsParser : A syntax error has been discovered in file E:\A\_work\36\s\WCF\Shared\Implementation\ClientTelemetryChannelBase.cs on line 306.
WCF\Shared\Implementation\ClientTelemetryDuplexChannel.cs(68):WCF\Shared\Implementation\ClientTelemetryDuplexChannel.cs(68,72): Error : SA1126 : CSharp.Readability : The call to nameof must begin with the 'this.', 'base.', 'object.' or 'ClientTelemetryDuplexChannel.' or 'ClientTelemetryChannelBase.' prefix to indicate the intended method call. 
WCF\Shared\Implementation\ClientTelemetryDuplexChannel.cs(77):WCF\Shared\Implementation\ClientTelemetryDuplexChannel.cs(77,67): Error : SA1126 : CSharp.Readability : The call to nameof must begin with the 'this.', 'base.', 'object.' or 'ClientTelemetryDuplexChannel.' or 'ClientTelemetryChannelBase.' prefix to indicate the intended method call. 
WCF\Shared\Implementation\ClientTelemetryDuplexChannel.cs(86):WCF\Shared\Implementation\ClientTelemetryDuplexChannel.cs(86,61): Error : SA1126 : CSharp.Readability : The call to nameof must begin with the 'this.', 'base.', 'object.' or 'ClientTelemetryDuplexChannel.' or 'ClientTelemetryChannelBase.' prefix to indicate the intended method call. 
WCF\Shared\Implementation\ClientTelemetryDuplexChannel.cs(103):WCF\Shared\Implementation\ClientTelemetryDuplexChannel.cs(103,72): Error : SA1126 : CSharp.Readability : The call to nameof must begin with the 'this.', 'base.', 'object.' or 'ClientTelemetryDuplexChannel.' or 'ClientTelemetryChannelBase.' prefix to indicate the intended method call. 
WCF\Shared\Implementation\ClientTelemetryDuplexChannel.cs(113):WCF\Shared\Implementation\ClientTelemetryDuplexChannel.cs(113,61): Error : SA1126 : CSharp.Readability : The call to nameof must begin with the 'this.', 'base.', 'object.' or 'ClientTelemetryDuplexChannel.' or 'ClientTelemetryChannelBase.' prefix to indicate the intended method call. 
WCF\Shared\Implementation\ClientTelemetryDuplexChannel.cs(125):WCF\Shared\Implementation\ClientTelemetryDuplexChannel.cs(125,72): Error : SA1126 : CSharp.Readability : The call to nameof must begin with the 'this.', 'base.', 'object.' or 'ClientTelemetryDuplexChannel.' or 'ClientTelemetryChannelBase.' prefix to indicate the intended method call. 
WCF\Shared\Implementation\ClientTelemetryDuplexChannel.cs(142):WCF\Shared\Implementation\ClientTelemetryDuplexChannel.cs(142,72): Error : SA1126 : CSharp.Readability : The call to nameof must begin with the 'this.', 'base.', 'object.' or 'ClientTelemetryDuplexChannel.' or 'ClientTelemetryChannelBase.' prefix to indicate the intended method call. 
WCF\Shared\Implementation\ClientTelemetryDuplexChannel.cs(154):WCF\Shared\Implementation\ClientTelemetryDuplexChannel.cs(154,72): Error : SA1126 : CSharp.Readability : The call to nameof must begin with the 'this.', 'base.', 'object.' or 'ClientTelemetryDuplexChannel.' or 'ClientTelemetryChannelBase.' prefix to indicate the intended method call. 
WCF\Shared\Implementation\ClientTelemetryDuplexChannel.cs(166):WCF\Shared\Implementation\ClientTelemetryDuplexChannel.cs(166,72): Error : SA1126 : CSharp.Readability : The call to nameof must begin with the 'this.', 'base.', 'object.' or 'ClientTelemetryDuplexChannel.' or 'ClientTelemetryChannelBase.' prefix to indicate the intended method call. 

New metrics API proposal

Here is a new metrics API proposal: https://github.com/Microsoft/ApplicationInsights-SDK-Labs/blob/master/AggregateMetrics/README.md#usage---second-api

Histograms and timers metric types are not yet implemented. Also there is some differences in how meters metric type works that potentially need some adjustments.

Problems that this API solves:

  1. Super-fast incrementing for a simple metrics
  2. Full control over MetricTelemetry custom properties and ability to set context properties
  3. Once metric created - I see it's value constantly. If ever we will charge per metric - this model has more sense for customer as metrics are created explicitly

What this API doesn't solve:

  1. This API uses the standard MetricTelemetry and it doesn't solve the problem of limiting number of dimensions you can have for a single metric
  2. Batching metrics and sharing context may help reduce monitoring noise. This API doesn't attempt to address this problem

What is missing:

  1. Implement the metric type derived from RerquestTelemetry object. Like a Meter of failed requests or timer of average page execution time.
  2. We need to think how we can share one metric between QuickPulse and regular telemetry. Primarily for the metrics derived from other telemetry types like mentioned above.

Unable to Restore or Install Stable version - 0.25.0 of Microsoft.ApplicationInsights.Wcf package

We had 0.25.0 stable version of ApplicationInsights.Wcf package installed in our solution. From sometime, Restoring nuget started failing. I tried the solution suggested in i.e. by updating Nuget.config -http://docs.myget.org/docs/how-to/package-not-found-during-package-restore. However, restoring or installing nuget failing cos there is no such stable version available.

I have noticed that this stable version is not available anymore, I only see Prerelease versions in https://www.myget.org/F/applicationinsights-sdk-labs/.

I wanted to know how do i go back to stable version.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.