diff --git a/libraries/Microsoft.Bot.Builder.ApplicationInsights/AppInsightsTelemetryClient.cs b/libraries/Microsoft.Bot.Builder.ApplicationInsights/AppInsightsTelemetryClient.cs index 2d3e6a8af..23f3cd151 100644 --- a/libraries/Microsoft.Bot.Builder.ApplicationInsights/AppInsightsTelemetryClient.cs +++ b/libraries/Microsoft.Bot.Builder.ApplicationInsights/AppInsightsTelemetryClient.cs @@ -11,7 +11,7 @@ namespace Microsoft.Bot.Builder.ApplicationInsights /// /// A logging client for bot telemetry. /// - public class AppInsightsTelemetryClient : LogTelemetryClient + public class AppInsightsTelemetryClient : LogTelemetryClientBase { private readonly TelemetryClient _telemetryClient; @@ -35,7 +35,7 @@ namespace Microsoft.Bot.Builder.ApplicationInsights /// Error message on availability test run failure. /// Named string values you can use to classify and search for this availability telemetry. /// Additional values associated with this availability telemetry. - public virtual void TrackAvailability(string name, DateTimeOffset timeStamp, TimeSpan duration, string runLocation, bool success, string message = null, IDictionary properties = null, IDictionary metrics = null) + public override void TrackAvailability(string name, DateTimeOffset timeStamp, TimeSpan duration, string runLocation, bool success, string message = null, IDictionary properties = null, IDictionary metrics = null) { var telemetry = new AvailabilityTelemetry(name, timeStamp, duration, runLocation, success, message); if (properties != null) @@ -71,7 +71,7 @@ namespace Microsoft.Bot.Builder.ApplicationInsights /// The time taken by the external dependency to handle the call. /// Result code of dependency call execution. /// True if the dependency call was handled successfully. - public virtual void TrackDependency(string dependencyTypeName, string target, string dependencyName, string data, DateTimeOffset startTime, TimeSpan duration, string resultCode, bool success) + public override void TrackDependency(string dependencyTypeName, string target, string dependencyName, string data, DateTimeOffset startTime, TimeSpan duration, string resultCode, bool success) { var telemetry = new DependencyTelemetry { @@ -94,7 +94,7 @@ namespace Microsoft.Bot.Builder.ApplicationInsights /// A name for the event. /// Named string values you can use to search and classify events. /// Measurements associated with this event. - public virtual void TrackEvent(string eventName, IDictionary properties = null, IDictionary metrics = null) + public override void TrackEvent(string eventName, IDictionary properties = null, IDictionary metrics = null) { var telemetry = new EventTelemetry(eventName); if (properties != null) @@ -122,7 +122,7 @@ namespace Microsoft.Bot.Builder.ApplicationInsights /// The exception to log. /// Named string values you can use to classify and search for this exception. /// Additional values associated with this exception. - public virtual void TrackException(Exception exception, IDictionary properties = null, IDictionary metrics = null) + public override void TrackException(Exception exception, IDictionary properties = null, IDictionary metrics = null) { var telemetry = new ExceptionTelemetry(exception); if (properties != null) @@ -150,7 +150,7 @@ namespace Microsoft.Bot.Builder.ApplicationInsights /// Message to display. /// Trace severity level . /// Named string values you can use to search and classify events. - public virtual void TrackTrace(string message, Severity severityLevel, IDictionary properties) + public override void TrackTrace(string message, Severity severityLevel, IDictionary properties) { var telemetry = new TraceTelemetry(message) { @@ -171,10 +171,10 @@ namespace Microsoft.Bot.Builder.ApplicationInsights /// /// Logs a an Application Insights page view. /// - /// The name of the page view to log. + /// The name of the dialog view to log. /// Named string values you can use to search and classify events. /// Measurements associated with this event. - public virtual void TrackPageView(string name, IDictionary properties = null, IDictionary metrics = null) + public override void TrackDialogView(string name, IDictionary properties = null, IDictionary metrics = null) { var telemetry = new PageViewTelemetry(name); @@ -200,6 +200,6 @@ namespace Microsoft.Bot.Builder.ApplicationInsights /// /// Flushes the in-memory buffer and any metrics being pre-aggregated. /// - public virtual void Flush() => _telemetryClient.Flush(); + public override void Flush() => _telemetryClient.Flush(); } } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs/ComponentDialog.cs b/libraries/Microsoft.Bot.Builder.Dialogs/ComponentDialog.cs index 68aa96ea9..a91c6fe35 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs/ComponentDialog.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs/ComponentDialog.cs @@ -38,7 +38,6 @@ namespace Microsoft.Bot.Builder.Dialogs /// /// The to use when logging. /// - [Obsolete("TelemetryClient is now obselete. Please use LogTelemetryClient instead.", false)] public override IBotTelemetryClient TelemetryClient { get @@ -60,7 +59,7 @@ namespace Microsoft.Bot.Builder.Dialogs /// /// The to use when logging. /// - public override LogTelemetryClient LogTelemetryClient + public override LogTelemetryClientBase LogTelemetryClient { get { @@ -110,7 +109,7 @@ namespace Microsoft.Bot.Builder.Dialogs return await EndComponentAsync(outerDc, turnResult.Result, cancellationToken).ConfigureAwait(false); } - LogTelemetryClient.TrackPageView(Id); + LogTelemetryClient.TrackDialogView(Id); // Just signal waiting return Dialog.EndOfTurn; diff --git a/libraries/Microsoft.Bot.Builder.Dialogs/Dialog.cs b/libraries/Microsoft.Bot.Builder.Dialogs/Dialog.cs index 2a646e551..d1a1e13d6 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs/Dialog.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs/Dialog.cs @@ -24,7 +24,7 @@ namespace Microsoft.Bot.Builder.Dialogs public static readonly DialogTurnResult EndOfTurn = new DialogTurnResult(DialogTurnStatus.Waiting); private IBotTelemetryClient _telemetryClient; - private LogTelemetryClient _logTelemetryClient; + private LogTelemetryClientBase _logTelemetryClient; [JsonProperty("id")] private string id; @@ -68,7 +68,6 @@ namespace Microsoft.Bot.Builder.Dialogs /// The to use for logging. /// [JsonIgnore] - [Obsolete("TelemetryClient is now obselete. Please use LogTelemetryClient instead.", false)] public virtual IBotTelemetryClient TelemetryClient { get @@ -88,7 +87,7 @@ namespace Microsoft.Bot.Builder.Dialogs /// The to use for logging. /// [JsonIgnore] - public virtual LogTelemetryClient LogTelemetryClient + public virtual LogTelemetryClientBase LogTelemetryClient { get { diff --git a/libraries/Microsoft.Bot.Builder.Dialogs/DialogSet.cs b/libraries/Microsoft.Bot.Builder.Dialogs/DialogSet.cs index fc56330b7..bd617d86f 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs/DialogSet.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs/DialogSet.cs @@ -18,7 +18,7 @@ namespace Microsoft.Bot.Builder.Dialogs private readonly IDictionary _dialogs = new Dictionary(); private IBotTelemetryClient _telemetryClient; - private LogTelemetryClient _logTelemetryClient; + private LogTelemetryClientBase _logTelemetryClient; /// /// Initializes a new instance of the class. @@ -50,7 +50,6 @@ namespace Microsoft.Bot.Builder.Dialogs /// When this property is set, it sets the of each /// dialog in the set to the new value. [JsonIgnore] - [Obsolete("TelemetryClient is now obselete. Please use LogTelemetryClient instead.", false)] public IBotTelemetryClient TelemetryClient { get @@ -75,7 +74,7 @@ namespace Microsoft.Bot.Builder.Dialogs /// When this property is set, it sets the of each /// dialog in the set to the new value. [JsonIgnore] - public LogTelemetryClient LogTelemetryClient + public LogTelemetryClientBase LogTelemetryClient { get { diff --git a/libraries/Microsoft.Bot.Builder.Dialogs/WaterfallDialog.cs b/libraries/Microsoft.Bot.Builder.Dialogs/WaterfallDialog.cs index d9e2886c5..5fd108b5c 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs/WaterfallDialog.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs/WaterfallDialog.cs @@ -78,7 +78,7 @@ namespace Microsoft.Bot.Builder.Dialogs }; TrackTelemetryEvent("WaterfallStart", properties); - LogTelemetryClient.TrackPageView(Id); + LogTelemetryClient.TrackDialogView(Id); // Run first step return await RunStepAsync(dc, 0, DialogReason.BeginCalled, null, cancellationToken).ConfigureAwait(false); diff --git a/libraries/Microsoft.Bot.Builder/LogTelemetryClient.cs b/libraries/Microsoft.Bot.Builder/LogTelemetryClientBase.cs similarity index 74% rename from libraries/Microsoft.Bot.Builder/LogTelemetryClient.cs rename to libraries/Microsoft.Bot.Builder/LogTelemetryClientBase.cs index 75fe88800..4d5ee1db6 100644 --- a/libraries/Microsoft.Bot.Builder/LogTelemetryClient.cs +++ b/libraries/Microsoft.Bot.Builder/LogTelemetryClientBase.cs @@ -9,7 +9,7 @@ namespace Microsoft.Bot.Builder /// /// A logging client for bot telemetry. /// - public abstract class LogTelemetryClient + public abstract class LogTelemetryClientBase { /// /// Send information about availability of an application. @@ -22,9 +22,7 @@ namespace Microsoft.Bot.Builder /// Error message on availability test run failure. /// Named string values you can use to classify and search for this availability telemetry. /// Additional values associated with this availability telemetry. - public virtual void TrackAvailability(string name, DateTimeOffset timeStamp, TimeSpan duration, string runLocation, bool success, string message = null, IDictionary properties = null, IDictionary metrics = null) - { - } + public abstract void TrackAvailability(string name, DateTimeOffset timeStamp, TimeSpan duration, string runLocation, bool success, string message = null, IDictionary properties = null, IDictionary metrics = null); /// /// Send information about an external dependency (outgoing call) in the application. @@ -40,9 +38,7 @@ namespace Microsoft.Bot.Builder /// The time taken by the external dependency to handle the call. /// Result code of dependency call execution. /// True if the dependency call was handled successfully. - public virtual void TrackDependency(string dependencyTypeName, string target, string dependencyName, string data, DateTimeOffset startTime, TimeSpan duration, string resultCode, bool success) - { - } + public abstract void TrackDependency(string dependencyTypeName, string target, string dependencyName, string data, DateTimeOffset startTime, TimeSpan duration, string resultCode, bool success); /// /// Logs custom events with extensible named fields. @@ -50,9 +46,7 @@ namespace Microsoft.Bot.Builder /// A name for the event. /// Named string values you can use to search and classify events. /// Measurements associated with this event. - public virtual void TrackEvent(string eventName, IDictionary properties = null, IDictionary metrics = null) - { - } + public abstract void TrackEvent(string eventName, IDictionary properties = null, IDictionary metrics = null); /// /// Logs a system exception. @@ -60,9 +54,7 @@ namespace Microsoft.Bot.Builder /// The exception to log. /// Named string values you can use to classify and search for this exception. /// Additional values associated with this exception. - public virtual void TrackException(Exception exception, IDictionary properties = null, IDictionary metrics = null) - { - } + public abstract void TrackException(Exception exception, IDictionary properties = null, IDictionary metrics = null); /// /// Send a trace message. @@ -70,25 +62,19 @@ namespace Microsoft.Bot.Builder /// Message to display. /// Trace severity level . /// Named string values you can use to search and classify events. - public virtual void TrackTrace(string message, Severity severityLevel, IDictionary properties) - { - } + public abstract void TrackTrace(string message, Severity severityLevel, IDictionary properties); /// /// Logs a page view. /// - /// The name of the page view to log. + /// The name of the dialog view to log. /// Named string values you can use to search and classify events. /// Measurements associated with this event. - public virtual void TrackPageView(string name, IDictionary properties = null, IDictionary metrics = null) - { - } + public abstract void TrackDialogView(string name, IDictionary properties = null, IDictionary metrics = null); /// /// Flushes the in-memory buffer and any metrics being pre-aggregated. /// - public virtual void Flush() - { - } + public abstract void Flush(); } } diff --git a/libraries/Microsoft.Bot.Builder/NullLogTelemetryClient.cs b/libraries/Microsoft.Bot.Builder/NullLogTelemetryClient.cs index 88130012b..62466592b 100644 --- a/libraries/Microsoft.Bot.Builder/NullLogTelemetryClient.cs +++ b/libraries/Microsoft.Bot.Builder/NullLogTelemetryClient.cs @@ -1,6 +1,36 @@ -namespace Microsoft.Bot.Builder +using System; +using System.Collections.Generic; + +namespace Microsoft.Bot.Builder { - public class NullLogTelemetryClient : LogTelemetryClient + public class NullLogTelemetryClient : LogTelemetryClientBase { + public override void Flush() + { + } + + public override void TrackAvailability(string name, DateTimeOffset timeStamp, TimeSpan duration, string runLocation, bool success, string message = null, IDictionary properties = null, IDictionary metrics = null) + { + } + + public override void TrackDependency(string dependencyTypeName, string target, string dependencyName, string data, DateTimeOffset startTime, TimeSpan duration, string resultCode, bool success) + { + } + + public override void TrackEvent(string eventName, IDictionary properties = null, IDictionary metrics = null) + { + } + + public override void TrackException(Exception exception, IDictionary properties = null, IDictionary metrics = null) + { + } + + public override void TrackDialogView(string name, IDictionary properties = null, IDictionary metrics = null) + { + } + + public override void TrackTrace(string message, Severity severityLevel, IDictionary properties) + { + } } } diff --git a/libraries/Microsoft.Bot.Builder/TelemetryLoggerMiddleware.cs b/libraries/Microsoft.Bot.Builder/TelemetryLoggerMiddleware.cs index d692a88a2..733e21559 100644 --- a/libraries/Microsoft.Bot.Builder/TelemetryLoggerMiddleware.cs +++ b/libraries/Microsoft.Bot.Builder/TelemetryLoggerMiddleware.cs @@ -33,7 +33,7 @@ namespace Microsoft.Bot.Builder /// /// The telemetry client to send telemetry events to. /// `true` to include personally identifiable information; otherwise, `false`. - public TelemetryLoggerMiddleware(LogTelemetryClient logTelemetryClient, bool logPersonalInformation = false) + public TelemetryLoggerMiddleware(LogTelemetryClientBase logTelemetryClient, bool logPersonalInformation = false) { LogTelemetryClient = logTelemetryClient ?? new NullLogTelemetryClient(); LogPersonalInformation = logPersonalInformation; @@ -66,7 +66,7 @@ namespace Microsoft.Bot.Builder /// The this middleware uses to log events. /// [JsonIgnore] - public LogTelemetryClient LogTelemetryClient { get; } + public LogTelemetryClientBase LogTelemetryClient { get; } /// /// Logs events for incoming, outgoing, updated, or deleted message activities, using the .