-
Notifications
You must be signed in to change notification settings - Fork 644
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5f88eec
commit 4d8c2ec
Showing
15 changed files
with
348 additions
and
92 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
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,18 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace NuGetGallery | ||
{ | ||
/// <summary> | ||
/// Interface for the Application Insights TelemetryClient class, for unit tests. | ||
/// </summary> | ||
public interface ITelemetryClient | ||
{ | ||
void TrackEvent(string eventName, IDictionary<string, string> properties = null, IDictionary<string, double> metrics = null); | ||
|
||
void TrackException(Exception exception, IDictionary<string, string> properties = null, IDictionary<string, double> metrics = null); | ||
} | ||
} |
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,56 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using Microsoft.ApplicationInsights; | ||
|
||
namespace NuGetGallery | ||
{ | ||
/// <summary> | ||
/// Wrapper for the Application Insights TelemetryClient class. | ||
/// </summary> | ||
public class TelemetryClientWrapper : ITelemetryClient | ||
{ | ||
private static Lazy<TelemetryClientWrapper> Singleton = new Lazy<TelemetryClientWrapper>(() => new TelemetryClientWrapper()); | ||
|
||
internal static TelemetryClientWrapper Instance | ||
{ | ||
get | ||
{ | ||
return Singleton.Value; | ||
} | ||
} | ||
|
||
private TelemetryClientWrapper() | ||
{ | ||
UnderlyingClient = new TelemetryClient(); | ||
} | ||
|
||
internal TelemetryClient UnderlyingClient { get; } | ||
|
||
public void TrackEvent(string eventName, IDictionary<string, string> properties = null, IDictionary<string, double> metrics = null) | ||
{ | ||
try | ||
{ | ||
UnderlyingClient.TrackEvent(eventName, properties, metrics); | ||
} | ||
catch | ||
{ | ||
// logging failed, don't allow exception to escape | ||
} | ||
} | ||
|
||
public void TrackException(Exception exception, IDictionary<string, string> properties = null, IDictionary<string, double> metrics = null) | ||
{ | ||
try | ||
{ | ||
UnderlyingClient.TrackException(exception, properties, metrics); | ||
} | ||
catch | ||
{ | ||
// logging failed, don't allow exception to escape | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.