Reputation: 11
When we send Log To Application Insight using Telemetry Configuration and New TelemetryClient with CustomTelemetryInitializer Not using ApplicationInsight SDK Or Worker Service for a Console App.
Just Configured TelemetryConfiguration , create a Telemetry Client with that configuration , also configured a CustomTelemetryInitializer that let me append a global property. Now I use TelemetryClient to track my logs they are even logged at Azure Successfully . I do have one doubt though whether the AdaptiveSampling is Enabled or Disabled cause i don't have any options to configure in TelemetryConfiguration while setting ApplicationInsight Logging in My Console App. So What is default behaviour if i follow this approach.
If i use ApplicationInsight SDK in ASP.NET Core App by default it is enabled by default and we have to disable it manually by passing the configuration in ApplicationInisightsServiceOptions.
I tried Worker Service but seems to slow , maybe i configured incorrectly , I want to disable Adaptive Sampling From Application Side to Log every log my app procures
Upvotes: 1
Views: 51
Reputation: 1197
So What is default behaviour if i follow this approach.
Adaptive Sampling is not enabled by default in a .NET Console Application when you're manually configuring TelemetryConfiguration
and TelemetryClient
.
In ASP.NET Core
, Adaptive Sampling is enabled by default, but in a Console App using manual TelemetryConfiguration, no sampling is applied by default.
If you want to explicitly disable adaptive sampling, you can configure TelemetryProcessorChainBuilder
to exclude any sampling processors.
Program.cs :
using System;
using System.Threading;
using Microsoft.ApplicationInsights;
using Microsoft.ApplicationInsights.Extensibility;
using Microsoft.ApplicationInsights.Extensibility.Implementation;
using Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing;
class Program
{
static void Main(string[] args)
{
var telemetryConfiguration = TelemetryConfiguration.CreateDefault();
telemetryConfiguration.InstrumentationKey = "<instrumentation-key>";
telemetryConfiguration.DefaultTelemetrySink.TelemetryProcessorChainBuilder.Use((next) => next);
telemetryConfiguration.DefaultTelemetrySink.TelemetryProcessorChainBuilder.Build();
var telemetryClient = new TelemetryClient(telemetryConfiguration);
telemetryClient.TrackTrace("This is a test log - Adaptive Sampling is disabled.");
telemetryClient.Flush();
Thread.Sleep(5000);
}
}
Refer this MSdoc to know how to disable adaptive sampling explicitly.
App insight logs:
Upvotes: 0