Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Not getting App Insights Requests #6

Closed
SharpDude opened this issue Mar 8, 2016 · 3 comments
Closed

Not getting App Insights Requests #6

SharpDude opened this issue Mar 8, 2016 · 3 comments

Comments

@SharpDude
Copy link

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.

@tomasr
Copy link
Contributor

tomasr commented Mar 8, 2016

Did you also add the WCF service behavior to your service that enables it? This can be done in two ways:

  • Code: Adding the [Microsoft.ApplicationInsights.Wcf.ServiceTelemetry] attribute to your service definition class.
  • Configuration: Add the <serviceTelemetry/> behavior through config. The NuGet package will register the behavior in <behaviorExtensions/> but it will not modify any existing service behavior definitions automatically at this time.

@SharpDude
Copy link
Author

I added the ServiceTelemetry attribute to my class. I couldn't figure out how to add it through the config as I have never used a behavior extension before. That attribute fixed it so I am now getting the Request events and they are correctly linked to the Dependency events. Thanks for the quick response!

One last question, which may be more app insights than this library, is how can I set the response code for the request event?

@tomasr
Copy link
Contributor

tomasr commented Mar 8, 2016

The NuGet package will register the service behavior by default. You'll see something like this in the <system.serviceModel> section of your web.config file:

<extensions>
  <behaviorExtensions>
    <add name="serviceTelemetry"
         type="Microsoft.ApplicationInsights.Wcf.ServiceTelemetryExtensionElement, Microsoft.AI.Wcf"/>
  </behaviorExtensions>
</extensions>

To add the behavior itself, you need to add the <serviceTelemetry/> tag to a Service Behavior. If you're using mostly doing the default configuration that Visual Studio generates for WCF services, you should have an unnamed service behavior where you could add it, and it would look something like this:

<behaviors>
  <serviceBehaviors>
    <behavior>
      <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
      <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="false"/>
      <!-- Enable Application Insights telemetry-->
      <serviceTelemetry/>
    </behavior>
  </serviceBehaviors>
</behaviors>

Of course, if you're using a named behavior, you'll need to add <serviceTelemetry/> to the right one :).

As for your last question, I'm not quite sure what you mean by "setting the response code for the request event". Can you clarify this?

By default, the library will notice if your service call returns a fault (that is, throws an unhandled exception or throws an exception derived from FaultException) and will mark the request as failed. If your service is exposed over an HTTP-based binding, we'll also include the HTTP response code in the Request telemetry event.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants