From eb6c0a50685068c1ddd1a26c54a7b773806cdde0 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Thu, 27 Oct 2016 00:09:55 -0400 Subject: [PATCH] added application insights to api --- src/Api/Properties/AssemblyInfo.cs | 2 +- src/Api/Properties/launchSettings.json | 48 +++++------ src/Api/Startup.cs | 6 ++ src/Api/project.json | 107 +++++++++++++------------ src/Api/settings.json | 47 ++++++----- src/Api/web.config | 12 +-- src/Core/Properties/AssemblyInfo.cs | 2 +- src/Core/project.json | 36 ++++----- 8 files changed, 135 insertions(+), 125 deletions(-) diff --git a/src/Api/Properties/AssemblyInfo.cs b/src/Api/Properties/AssemblyInfo.cs index 40aafd2b2..cace456b9 100644 --- a/src/Api/Properties/AssemblyInfo.cs +++ b/src/Api/Properties/AssemblyInfo.cs @@ -8,7 +8,7 @@ using System.Runtime.InteropServices; [assembly: AssemblyTitle("Bit.Api")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("bitwarden")] +[assembly: AssemblyCompany("8bit Solutions LLC")] [assembly: AssemblyProduct("bitwarden")] [assembly: AssemblyCopyright("Copyright © 2015")] [assembly: AssemblyTrademark("")] diff --git a/src/Api/Properties/launchSettings.json b/src/Api/Properties/launchSettings.json index bd36404d3..41292b5eb 100644 --- a/src/Api/Properties/launchSettings.json +++ b/src/Api/Properties/launchSettings.json @@ -1,27 +1,27 @@ { - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:4000", - "sslPort": 0 - } - }, - "profiles": { - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - } - }, - "Web": { - "commandName": "Project", - "launchBrowser": true, - "launchUrl": "http://localhost:5000", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:4000", + "sslPort": 0 } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + }, + "Web": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "http://localhost:5000", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } } diff --git a/src/Api/Startup.cs b/src/Api/Startup.cs index 64452c7e0..1223c6dc2 100644 --- a/src/Api/Startup.cs +++ b/src/Api/Startup.cs @@ -38,6 +38,7 @@ namespace Bit.Api if(env.IsDevelopment()) { builder.AddUserSecrets(); + builder.AddApplicationInsightsSettings(developerMode: true); } builder.AddEnvironmentVariables(); @@ -49,6 +50,8 @@ namespace Bit.Api public void ConfigureServices(IServiceCollection services) { + services.AddApplicationInsightsTelemetry(Configuration); + var provider = services.BuildServiceProvider(); // Options @@ -164,6 +167,9 @@ namespace Bit.Api globalSettings.Loggr.ApiKey); } + app.UseApplicationInsightsRequestTelemetry(); + app.UseApplicationInsightsExceptionTelemetry(); + // Add static files to the request pipeline. app.UseStaticFiles(); diff --git a/src/Api/project.json b/src/Api/project.json index db73c0942..8f7e0a656 100644 --- a/src/Api/project.json +++ b/src/Api/project.json @@ -1,59 +1,60 @@ { - "userSecretsId": "aspnet5-bitwarden-Api", - "version": "1.0.2", + "userSecretsId": "aspnet5-bitwarden-Api", + "version": "1.0.2", - "dependencies": { - "Core": { - "target": "project" - }, - "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0", - "Microsoft.AspNetCore.Mvc": "1.0.0", - "Microsoft.AspNetCore.Server.Kestrel": "1.0.0", - "Microsoft.AspNetCore.StaticFiles": "1.0.0", - "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0", - "Microsoft.Extensions.Logging": "1.0.0", - "Microsoft.Extensions.Logging.Console": "1.0.0", - "Microsoft.Extensions.Logging.Debug": "1.0.0", - "Microsoft.AspNetCore.Cors": "1.0.0", - "Microsoft.AspNetCore.Diagnostics": "1.0.0", - "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0", - "Microsoft.Extensions.Configuration.Binder": "1.0.0", - "Loggr.Extensions.Logging": "1.0.0" + "dependencies": { + "Core": { + "target": "project" }, + "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0", + "Microsoft.AspNetCore.Mvc": "1.0.0", + "Microsoft.AspNetCore.Server.Kestrel": "1.0.0", + "Microsoft.AspNetCore.StaticFiles": "1.0.0", + "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0", + "Microsoft.Extensions.Logging": "1.0.0", + "Microsoft.Extensions.Logging.Console": "1.0.0", + "Microsoft.Extensions.Logging.Debug": "1.0.0", + "Microsoft.AspNetCore.Cors": "1.0.0", + "Microsoft.AspNetCore.Diagnostics": "1.0.0", + "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0", + "Microsoft.Extensions.Configuration.Binder": "1.0.0", + "Loggr.Extensions.Logging": "1.0.0", + "Microsoft.ApplicationInsights.AspNetCore": "1.0.0" + }, - "tools": { - "Microsoft.AspNetCore.Server.IISIntegration.Tools": { - "version": "1.0.0-preview2-final", - "imports": "portable-net45+win8+dnxcore50" - } - }, - - "frameworks": { - "net461": { } - }, - - "buildOptions": { - "emitEntryPoint": true, - "preserveCompilationContext": true - }, - - "runtimeOptions": { - "gcServer": false, - "gcConcurrent": true - }, - - "publishOptions": { - "include": [ - "wwwroot", - "Views", - "settings.json", - "settings.Production.json", - "settings.Staging.json", - "web.config" - ] - }, - - "scripts": { - "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ] + "tools": { + "Microsoft.AspNetCore.Server.IISIntegration.Tools": { + "version": "1.0.0-preview2-final", + "imports": "portable-net45+win8+dnxcore50" } + }, + + "frameworks": { + "net461": {} + }, + + "buildOptions": { + "emitEntryPoint": true, + "preserveCompilationContext": true + }, + + "runtimeOptions": { + "gcServer": false, + "gcConcurrent": true + }, + + "publishOptions": { + "include": [ + "wwwroot", + "Views", + "settings.json", + "settings.Production.json", + "settings.Staging.json", + "web.config" + ] + }, + + "scripts": { + "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ] + } } diff --git a/src/Api/settings.json b/src/Api/settings.json index 1cafc4628..26b846e48 100644 --- a/src/Api/settings.json +++ b/src/Api/settings.json @@ -1,25 +1,28 @@ { - "globalSettings": { - "siteName": "bitwarden", - "baseVaultUri": "http://localhost:4001", - "jwtSigningKey": "THIS IS A SECRET. IT KEEPS YOUR TOKEN SAFE. :)", - "sqlServer": { - "connectionString": "SECRET" - }, - "mail": { - "apiKey": "SECRET", - "replyToEmail": "do-not-reply@bitwarden.com" - }, - "loggr": { - "logKey": "SECRET", - "apiKey": "SECRET" - }, - "push": { - "apnsCertificateThumbprint": "SECRET", - "apnsCertificatePassword": "SECRET", - "gcmSenderId": "SECRET", - "gcmApiKey": "SECRET", - "gcmAppPackageName": "com.x8bit.bitwarden" - } + "ApplicationInsights": { + "InstrumentationKey": "5e6c8e7c-8a6d-4d4b-866e-4b80e5b9203e" + }, + "globalSettings": { + "siteName": "bitwarden", + "baseVaultUri": "http://localhost:4001", + "jwtSigningKey": "THIS IS A SECRET. IT KEEPS YOUR TOKEN SAFE. :)", + "sqlServer": { + "connectionString": "SECRET" + }, + "mail": { + "apiKey": "SECRET", + "replyToEmail": "do-not-reply@bitwarden.com" + }, + "loggr": { + "logKey": "SECRET", + "apiKey": "SECRET" + }, + "push": { + "apnsCertificateThumbprint": "SECRET", + "apnsCertificatePassword": "SECRET", + "gcmSenderId": "SECRET", + "gcmApiKey": "SECRET", + "gcmAppPackageName": "com.x8bit.bitwarden" } + } } diff --git a/src/Api/web.config b/src/Api/web.config index 7b3cb2073..05ac0e36d 100644 --- a/src/Api/web.config +++ b/src/Api/web.config @@ -1,9 +1,9 @@  - - - - - - + + + + + + diff --git a/src/Core/Properties/AssemblyInfo.cs b/src/Core/Properties/AssemblyInfo.cs index 3508afc0d..df1be204e 100644 --- a/src/Core/Properties/AssemblyInfo.cs +++ b/src/Core/Properties/AssemblyInfo.cs @@ -8,7 +8,7 @@ using System.Runtime.InteropServices; [assembly: AssemblyTitle("Bit.Core")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("bitwarden")] +[assembly: AssemblyCompany("8bit Solutions LLC")] [assembly: AssemblyProduct("bitwarden")] [assembly: AssemblyCopyright("Copyright © 2015")] [assembly: AssemblyTrademark("")] diff --git a/src/Core/project.json b/src/Core/project.json index d47b9cf65..b5d639b19 100644 --- a/src/Core/project.json +++ b/src/Core/project.json @@ -1,22 +1,22 @@ { - "dependencies": { - "Microsoft.AspNetCore.Identity": "1.0.0", - "Microsoft.AspNetCore.Authentication.JwtBearer": "1.0.0", - "OtpSharp": "1.3.0.4", - "Microsoft.AspNetCore.Mvc.Abstractions": "1.0.0", - "Dapper": "1.42.0", - "DataTableProxy": "1.2.0", - "Sendgrid": "6.3.4", - "StackExchange.Redis": "1.0.488", - "PushSharp": "4.0.10" - }, + "dependencies": { + "Microsoft.AspNetCore.Identity": "1.0.0", + "Microsoft.AspNetCore.Authentication.JwtBearer": "1.0.0", + "OtpSharp": "1.3.0.4", + "Microsoft.AspNetCore.Mvc.Abstractions": "1.0.0", + "Dapper": "1.42.0", + "DataTableProxy": "1.2.0", + "Sendgrid": "6.3.4", + "StackExchange.Redis": "1.0.488", + "PushSharp": "4.0.10" + }, - "frameworks": { - "net461": { - "frameworkAssemblies": { - "System.ComponentModel.DataAnnotations": "4.0.0.0", - "System.Data": "4.0.0.0" - } - } + "frameworks": { + "net461": { + "frameworkAssemblies": { + "System.ComponentModel.DataAnnotations": "4.0.0.0", + "System.Data": "4.0.0.0" + } } + } }