Skip to content

Commit

Permalink
updates to telemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
lauren-mills committed Nov 21, 2018
1 parent 61e35af commit 36819ea
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,7 @@ public static void Main(string[] args)

public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.ConfigureLogging((hostingContext, logging) =>
{
// Add Azure Logging
logging.AddAzureWebAppDiagnostics();

// Other Loggers.
// There are other logging options available:
// https://docs.microsoft.com/en-us/aspnet/core/fundamentals/logging/?view=aspnetcore-2.1
// logging.AddDebug();
// logging.AddConsole();
})
.UseApplicationInsights()
.UseStartup<Startup>() // Note: Application Insights is added in Startup. Disabling is also handled there.
.Build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ namespace $safeprojectname$
public class Startup
{
private ILoggerFactory _loggerFactory;
private ILogger _logger;
private bool _isProduction = false;

public Startup(IHostingEnvironment env, ILoggerFactory loggerFactory)
Expand All @@ -46,17 +45,6 @@ public Startup(IHostingEnvironment env, ILoggerFactory loggerFactory)

public void ConfigureServices(IServiceCollection services)
{
// Enable distributed tracing.
services.AddApplicationInsightsTelemetry(o =>
{
o.RequestCollectionOptions.EnableW3CDistributedTracing = true;
o.RequestCollectionOptions.InjectResponseHeaders = true;
o.RequestCollectionOptions.TrackExceptions = true;
});
services.AddSingleton<ITelemetryInitializer>(new OperationCorrelationTelemetryInitializer());
_logger = _loggerFactory.CreateLogger<Startup>();
_logger.LogInformation($"Configuring services for {nameof($safeprojectname$)}. IsProduction: {_isProduction}.");

// Load the connected services from .bot file.
var botFilePath = Configuration.GetSection("botFilePath")?.Value;
var botFileSecret = Configuration.GetSection("botFileSecret")?.Value;
Expand Down Expand Up @@ -89,8 +77,6 @@ public void ConfigureServices(IServiceCollection services)
// Add the bot with options
services.AddBot<$safeprojectname$>(options =>
{
_logger.LogInformation($"Adding bot {nameof($safeprojectname$)}");

// Load the connected services from .bot file.
var environment = _isProduction ? "production" : "development";
var service = botConfig.Services.FirstOrDefault(s => s.Type == ServiceTypes.Endpoint && s.Name == environment);
Expand Down Expand Up @@ -126,7 +112,6 @@ public void ConfigureServices(IServiceCollection services)
options.Middleware.Add(typingMiddleware);

options.Middleware.Add(new AutoSaveStateMiddleware(userState, conversationState));
_logger.LogTrace($"Bot added successfully.");
});
}

Expand All @@ -137,9 +122,9 @@ public void ConfigureServices(IServiceCollection services)
/// <param name="env">Hosting Environment.</param>
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
// Uncomment to disable Application Insights.
// var configuration = app.ApplicationServices.GetService<Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration>();
// configuration.DisableTelemetry = true;
// Configure Application Insights
_loggerFactory.AddApplicationInsights(app.ApplicationServices, LogLevel.Warning);

if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
Expand Down

0 comments on commit 36819ea

Please sign in to comment.