-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #99 from christianhelle/development
Enable Error Logging to Azure Application Insights
- Loading branch information
Showing
12 changed files
with
92 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using System.Diagnostics.CodeAnalysis; | ||
using Microsoft.ApplicationInsights; | ||
using Microsoft.ApplicationInsights.Extensibility; | ||
|
||
namespace ChristianHelle.DeveloperTools.CodeGenerators.Resw.VSPackage.CustomTool | ||
{ | ||
[ExcludeFromCodeCoverage] | ||
public class AppInsightsClient | ||
{ | ||
private readonly TelemetryClient telemetryClient = null; | ||
|
||
public AppInsightsClient() | ||
{ | ||
try | ||
{ | ||
var configuration = TelemetryConfiguration.CreateDefault(); | ||
configuration.InstrumentationKey = "eba88f76-06da-4ef8-a0fe-162b1a70f871"; | ||
//// configuration.ConnectionString = "InstrumentationKey=eba88f76-06da-4ef8-a0fe-162b1a70f871;IngestionEndpoint=https://westeurope-5.in.applicationinsights.azure.com/;LiveEndpoint=https://westeurope.livediagnostics.monitor.azure.com/"; | ||
|
||
telemetryClient = new TelemetryClient(configuration); | ||
} | ||
catch (Exception ex1) | ||
{ | ||
Trace.WriteLine(ex1); | ||
|
||
try | ||
{ | ||
telemetryClient = new TelemetryClient(); | ||
#pragma warning disable CS0618 // Type or member is obsolete | ||
telemetryClient.InstrumentationKey = "eba88f76-06da-4ef8-a0fe-162b1a70f871"; | ||
#pragma warning restore CS0618 // Type or member is obsolete | ||
} | ||
catch (Exception ex2) | ||
{ | ||
Trace.WriteLine(ex2); | ||
return; | ||
} | ||
} | ||
|
||
telemetryClient.Context.Session.Id = Guid.NewGuid().ToString(); | ||
telemetryClient.Context.Device.OperatingSystem = Environment.OSVersion.ToString(); | ||
telemetryClient.Context.Component.Version = GetType().Assembly.GetName().Version.ToString(); | ||
} | ||
|
||
public static AppInsightsClient Instance { get; } = new AppInsightsClient(); | ||
|
||
public void TrackFeatureUsage(string featureName, params string[] tags) | ||
{ | ||
telemetryClient?.TrackEvent(featureName); | ||
telemetryClient?.Flush(); | ||
} | ||
|
||
public void TrackError(Exception exception) | ||
{ | ||
telemetryClient?.TrackException(exception); | ||
telemetryClient?.Flush(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters