0

I'm sure this must be easy, but I can't find any documentation on it.

I have a custom ITelemetryChannel implementation in another assembly. How do I add it to the applicationinsights.config? The examples in Microsoft's documentation assume the class is in the same assembly as the web application.

BanksySan
  • 27,362
  • 33
  • 117
  • 216

1 Answers1

0

You can do it this way:

<TelemetryChannel Type="Namespace.MyTelemetryChannel, OtherAssemblyName" />
  • Namespace.MyTelemetryChannel should be your fully qualified type name for your class
  • It should be followed by the assembly name eg. OtherAssemblyName

Default ITelemetryChannel:

The default channel used by ApplicationInsights.Web is ServerTelemetryChannel which is present by default in the ApplicationInsights.config file:

<TelemetryChannel Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.ServerTelemetryChannel, Microsoft.AI.ServerTelemetryChannel"/>

If you check the references in your project you'll find Microsoft.AI.ServerTelemetryChannel is the assembly from where ServerTelemetryChannel is initialized.

Initializing properties with ITelemetryChannel:

You can also initialize properties (as long as they have public getters and setters) from the ApplicationInsights.config, as shown below:

<TelemetryChannel Type="Namespace.MyTelemetryChannel, OtherAssemblyName">
    <SomeCount>20</SomeCount>
</TelemetryChannel>

assuming your TelemetryChannel includes the property SomeCount:

public class MyTelemetryChannel: ITelemetryChannel
{
    public int SomeCount { get; set; }
    ...
}

Hope this helps!

degant
  • 4,861
  • 1
  • 17
  • 29