Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove obsolete app insights functionality #550

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;

#pragma warning disable 1591
#pragma warning disable 1591
namespace Arcus.Observability.Telemetry.Core
{
public static class ContextProperties
Expand Down Expand Up @@ -38,9 +36,6 @@ public static class EventTracking
{
public const string EventLogEntry = "Event";
public const string EventName = "EventName";

[Obsolete("Use " + nameof(ContextProperties) + "." + nameof(TelemetryContext) + " instead")]
public const string EventContext = "EventDescription";
}

public static class General
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,6 @@ public abstract class CustomTelemetryConverter<TEntry> : TelemetryConverterBase
private readonly OperationContextConverter _operationContextConverter;
private readonly CloudContextConverter _cloudContextConverter = new CloudContextConverter();

/// <summary>
/// Initializes a new instance of the <see cref="CustomTelemetryConverter{TEntry}" /> class.
/// </summary>
[Obsolete("Use the constructor overload with the Application Insights options instead")]
protected CustomTelemetryConverter() : this(new ApplicationInsightsSinkOptions())
{
}

/// <summary>
/// Initializes a new instance of the <see cref="CustomTelemetryConverter{TEntry}" /> class.
/// </summary>
Expand Down Expand Up @@ -58,18 +50,12 @@ public override IEnumerable<ITelemetry> Convert(LogEvent logEvent, IFormatProvid

TEntry telemetryEntry = CreateTelemetryEntry(logEvent, formatProvider);

#pragma warning disable 618 // Until we go to a new major.
AssignTelemetryContextProperties(logEvent, telemetryEntry);
#pragma warning restore 618
_cloudContextConverter.EnrichWithAppInfo(logEvent, telemetryEntry);

RemoveIntermediaryProperties(logEvent);
logEvent.RemovePropertyIfPresent(ContextProperties.TelemetryContext);

#pragma warning disable 618 // Until we remove the obsolete 'EventDescription'.
logEvent.RemovePropertyIfPresent(ContextProperties.EventTracking.EventContext);
#pragma warning restore 618

ForwardPropertiesToTelemetryProperties(logEvent, telemetryEntry, formatProvider);
_operationContextConverter.EnrichWithCorrelationInfo(telemetryEntry);
_operationContextConverter.EnrichWithOperationName(telemetryEntry);
Expand All @@ -85,10 +71,6 @@ public override IEnumerable<ITelemetry> Convert(LogEvent logEvent, IFormatProvid
protected void AssignTelemetryContextProperties(LogEvent logEvent, ISupportProperties telemetry)
{
AssignContextPropertiesFromDictionaryProperty(logEvent, telemetry, ContextProperties.TelemetryContext);

#pragma warning disable 618 // Until we remove obsolete 'EventDescription'.
AssignContextPropertiesFromDictionaryProperty(logEvent, telemetry, ContextProperties.EventTracking.EventContext);
#pragma warning restore 618
}

private static void AssignContextPropertiesFromDictionaryProperty(LogEvent logEvent, ISupportProperties telemetry, string propertyName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@ namespace Arcus.Observability.Telemetry.Serilog.Sinks.ApplicationInsights.Conver
/// </summary>
public class DependencyTelemetryConverter : CustomTelemetryConverter<DependencyTelemetry>
{
/// <summary>
/// Initializes a new instance of the <see cref="DependencyTelemetryConverter" /> class.
/// </summary>
[Obsolete("Use the constructor overload with the Application Insights options instead")]
public DependencyTelemetryConverter()
{
}

/// <summary>
/// Initializes a new instance of the <see cref="DependencyTelemetryConverter" /> class.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@ namespace Arcus.Observability.Telemetry.Serilog.Sinks.ApplicationInsights.Conver
/// </summary>
public class EventTelemetryConverter : CustomTelemetryConverter<EventTelemetry>
{
/// <summary>
/// Initializes a new instance of the <see cref="EventTelemetryConverter" /> class.
/// </summary>
[Obsolete("Use the constructor overload with the Application Insights options instead")]
public EventTelemetryConverter()
{
}

/// <summary>
/// Initializes a new instance of the <see cref="EventTelemetryConverter" /> class.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Linq;
using System.Reflection;
using Arcus.Observability.Telemetry.Serilog.Sinks.ApplicationInsights.Configuration;
using GuardNet;
Expand All @@ -13,20 +12,6 @@ namespace Arcus.Observability.Telemetry.Serilog.Sinks.ApplicationInsights.Conver
/// </summary>
public class ExceptionTelemetryConverter : CustomTelemetryConverter<ExceptionTelemetry>
{
private readonly ApplicationInsightsSinkExceptionOptions _options;

/// <summary>
/// Initializes a new instance of the <see cref="ExceptionTelemetryConverter" /> class.
/// </summary>
/// <param name="options">The consumer-configurable options to influence how the exception should be tracked.</param>
/// <exception cref="ArgumentNullException">Thrown when the <paramref name="options"/> is <c>null</c>.</exception>
[Obsolete("Use the constructor overload with the Application Insights options instead")]
public ExceptionTelemetryConverter(ApplicationInsightsSinkExceptionOptions options)
{
Guard.NotNull(options, nameof(options), "Requires a set of user-configurable options to influence the behavior of how exceptions are tracked");
_options = options;
}

/// <summary>
/// Initializes a new instance of the <see cref="ExceptionTelemetryConverter" /> class.
/// </summary>
Expand All @@ -50,7 +35,7 @@ protected override ExceptionTelemetry CreateTelemetryEntry(LogEvent logEvent, IF

var exceptionTelemetry = new ExceptionTelemetry(logEvent.Exception);

if (Options?.Exception.IncludeProperties == true || _options?.IncludeProperties == true)
if (Options?.Exception.IncludeProperties == true)
{
EnrichWithExceptionProperties(logEvent, exceptionTelemetry);
}
Expand Down Expand Up @@ -80,11 +65,6 @@ private string DeterminePropertyFormat()
return Options.Exception.PropertyFormat;
}

if (_options != null)
{
return _options.PropertyFormat;
}

throw new InvalidOperationException(
"Could not determine exception property format because the Application Insights exception converter was not initialized with any options");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@ namespace Arcus.Observability.Telemetry.Serilog.Sinks.ApplicationInsights.Conver
/// </summary>
public class MetricTelemetryConverter : CustomTelemetryConverter<MetricTelemetry>
{
/// <summary>
/// Initializes a new instance of the <see cref="MetricTelemetryConverter" /> class.
/// </summary>
[Obsolete("Use the constructor overload with the Application Insights options instead")]
public MetricTelemetryConverter()
{
}

/// <summary>
/// Initializes a new instance of the <see cref="MetricTelemetryConverter" /> class.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,6 @@ public class OperationContextConverter
{
private readonly ApplicationInsightsSinkOptions _options;

/// <summary>
/// Initializes a new instance of the <see cref="OperationContextConverter" /> class.
/// </summary>
[Obsolete("Use the constructor overload with the Application Insights options instead")]
public OperationContextConverter()
{
}

/// <summary>
/// Initializes a new instance of the <see cref="OperationContextConverter" /> class.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,6 @@ public class TraceTelemetryConverter : global::Serilog.Sinks.ApplicationInsights
private readonly OperationContextConverter _operationContextConverter;
private readonly CloudContextConverter _cloudContextConverter = new CloudContextConverter();

/// <summary>
/// Initializes a new instance of the <see cref="TraceTelemetryConverter" /> class.
/// </summary>
[Obsolete("Use the constructor overload with the Application Insights options instead")]
public TraceTelemetryConverter()
{
_operationContextConverter = new OperationContextConverter();
}

/// <summary>
/// Initializes a new instance of the <see cref="TraceTelemetryConverter" /> class.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,102 +15,6 @@ namespace Serilog.Configuration
/// </summary>
public static class LoggerSinkConfigurationExtensions
{
/// <summary>
/// Adds a Serilog sink that writes <see cref="T:Serilog.Events.LogEvent">log events</see> to Azure Application Insights.
/// See also synonym: <see cref="AzureApplicationInsightsWithInstrumentationKey(LoggerSinkConfiguration,string)"/>
/// </summary>
/// <remarks>
/// Supported telemetry types are Traces, Dependencies, Events, Requests and Metrics for which we provide extensions on <see cref="ILogger" />.
/// </remarks>
/// <param name="loggerSinkConfiguration">The logger configuration.</param>
/// <param name="instrumentationKey">The required Application Insights key.</param>
/// <exception cref="ArgumentNullException">Thrown when the <paramref name="loggerSinkConfiguration"/> is <c>null</c>.</exception>
/// <exception cref="ArgumentException">Thrown when the <paramref name="instrumentationKey"/> is blank.</exception>
[Obsolete("Use the " + nameof(AzureApplicationInsightsWithInstrumentationKey) + " overload instead")]
public static LoggerConfiguration AzureApplicationInsights(
this LoggerSinkConfiguration loggerSinkConfiguration,
string instrumentationKey)
{
Guard.NotNull(loggerSinkConfiguration, nameof(loggerSinkConfiguration), "Requires a logger configuration to add the Azure Application Insights sink to");
Guard.NotNullOrWhitespace(instrumentationKey, nameof(instrumentationKey), "Requires an instrumentation key to authenticate with Azure Application Insights while sinking telemetry");

return AzureApplicationInsightsWithInstrumentationKey(loggerSinkConfiguration, instrumentationKey, configureOptions: null);
}

/// <summary>
/// Adds a Serilog sink that writes <see cref="T:Serilog.Events.LogEvent">log events</see> to Azure Application Insights.
/// See also synonym: <see cref="AzureApplicationInsightsWithInstrumentationKey(LoggerSinkConfiguration,string,Action{ApplicationInsightsSinkOptions})"/>
/// </summary>
/// <remarks>
/// Supported telemetry types are Traces, Dependencies, Events, Requests and Metrics for which we provide extensions on <see cref="ILogger" />.
/// </remarks>
/// <param name="loggerSinkConfiguration">The logger configuration.</param>
/// <param name="instrumentationKey">The required Application Insights key.</param>
/// <param name="configureOptions">The optional function to configure additional options to influence the behavior of how the telemetry is logged to Azure Application Insights.</param>
/// <exception cref="ArgumentNullException">Thrown when the <paramref name="loggerSinkConfiguration"/> is <c>null</c>.</exception>
/// <exception cref="ArgumentException">Thrown when the <paramref name="instrumentationKey"/> is blank.</exception>
[Obsolete("Use the " + nameof(AzureApplicationInsightsWithInstrumentationKey) + " overload instead")]
public static LoggerConfiguration AzureApplicationInsights(
this LoggerSinkConfiguration loggerSinkConfiguration,
string instrumentationKey,
Action<ApplicationInsightsSinkOptions> configureOptions)
{
Guard.NotNull(loggerSinkConfiguration, nameof(loggerSinkConfiguration), "Requires a logger configuration to add the Azure Application Insights sink to");
Guard.NotNullOrWhitespace(instrumentationKey, nameof(instrumentationKey), "Requires an instrumentation key to authenticate with Azure Application Insights while sinking telemetry");

return AzureApplicationInsightsWithInstrumentationKey(loggerSinkConfiguration, instrumentationKey, LogEventLevel.Verbose, configureOptions);
}

/// <summary>
/// Adds a Serilog sink that writes <see cref="T:Serilog.Events.LogEvent">log events</see> to Azure Application Insights.
/// See also synonym: <see cref="AzureApplicationInsightsWithInstrumentationKey(LoggerSinkConfiguration,string,LogEventLevel)"/>
/// </summary>
/// <remarks>
/// Supported telemetry types are Traces, Dependencies, Events, Requests and Metrics for which we provide extensions on <see cref="ILogger" />.
/// </remarks>
/// <param name="loggerSinkConfiguration">The logger configuration.</param>
/// <param name="instrumentationKey">The required Application Insights key.</param>
/// <param name="restrictedToMinimumLevel">The minimum log event level required in order to write an event to the sink.</param>
/// <exception cref="ArgumentNullException">Thrown when the <paramref name="loggerSinkConfiguration"/> is <c>null</c>.</exception>
/// <exception cref="ArgumentException">Thrown when the <paramref name="instrumentationKey"/> is blank.</exception>
[Obsolete("Use the " + nameof(AzureApplicationInsightsWithInstrumentationKey) + " overload instead")]
public static LoggerConfiguration AzureApplicationInsights(
this LoggerSinkConfiguration loggerSinkConfiguration,
string instrumentationKey,
LogEventLevel restrictedToMinimumLevel)
{
Guard.NotNull(loggerSinkConfiguration, nameof(loggerSinkConfiguration), "Requires a logger configuration to add the Azure Application Insights sink to");
Guard.NotNullOrWhitespace(instrumentationKey, nameof(instrumentationKey), "Requires an instrumentation key to authenticate with Azure Application Insights while sinking telemetry");

return AzureApplicationInsightsWithInstrumentationKey(loggerSinkConfiguration, instrumentationKey, restrictedToMinimumLevel, configureOptions: null);
}

/// <summary>
/// Adds a Serilog sink that writes <see cref="T:Serilog.Events.LogEvent">log events</see> to Azure Application Insights.
/// See also synonym: <see cref="AzureApplicationInsightsWithInstrumentationKey(LoggerSinkConfiguration,string,LogEventLevel,Action{ApplicationInsightsSinkOptions})"/>
/// </summary>
/// <remarks>
/// Supported telemetry types are Traces, Dependencies, Events, Requests and Metrics for which we provide extensions on <see cref="ILogger" />.
/// </remarks>
/// <param name="loggerSinkConfiguration">The logger configuration.</param>
/// <param name="instrumentationKey">The required Application Insights key.</param>
/// <param name="restrictedToMinimumLevel">The minimum log event level required in order to write an event to the sink.</param>
/// <param name="configureOptions">The optional function to configure additional options to influence the behavior of how the telemetry is logged to Azure Application Insights.</param>
/// <exception cref="ArgumentNullException">Thrown when the <paramref name="loggerSinkConfiguration"/> is <c>null</c>.</exception>
/// <exception cref="ArgumentException">Thrown when the <paramref name="instrumentationKey"/> is blank.</exception>
[Obsolete("Use the " + nameof(AzureApplicationInsightsWithInstrumentationKey) + " overload instead")]
public static LoggerConfiguration AzureApplicationInsights(
this LoggerSinkConfiguration loggerSinkConfiguration,
string instrumentationKey,
LogEventLevel restrictedToMinimumLevel,
Action<ApplicationInsightsSinkOptions> configureOptions)
{
Guard.NotNull(loggerSinkConfiguration, nameof(loggerSinkConfiguration), "Requires a logger configuration to add the Azure Application Insights sink to");
Guard.NotNullOrWhitespace(instrumentationKey, nameof(instrumentationKey), "Requires an instrumentation key to authenticate with Azure Application Insights while sinking telemetry");

return AzureApplicationInsightsWithInstrumentationKey(loggerSinkConfiguration, instrumentationKey, restrictedToMinimumLevel, configureOptions);
}

/// <summary>
/// Adds a Serilog sink that writes <see cref="T:Serilog.Events.LogEvent">log events</see> to Azure Application Insights.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,54 +120,6 @@ public void AzureApplicationInsightsWithConnectionStringWithLevelAndOptions_With
() => config.WriteTo.AzureApplicationInsightsWithConnectionString(provider, "<connection-string>", level, options => { }));
}

[Theory]
[ClassData(typeof(Blanks))]
public void AzureApplicationInsights_WithoutInstrumentationKey_Fails(string instrumentationKey)
{
// Arrange
var config = new LoggerConfiguration();

// Act / Assert
Assert.Throws<ArgumentException>(
() => config.WriteTo.AzureApplicationInsights(instrumentationKey));
}

[Theory]
[ClassData(typeof(Blanks))]
public void AzureApplicationInsightsWithConfigOptions_WithoutInstrumentationKey_Fails(string instrumentationKey)
{
// Arrange
var config = new LoggerConfiguration();

// Act / Assert
Assert.Throws<ArgumentException>(
() => config.WriteTo.AzureApplicationInsights(instrumentationKey, options => { }));
}

[Theory]
[ClassData(typeof(Blanks))]
public void AzureApplicationInsightsWithMinLogLevel_WithoutInstrumentationKey_Fails(string instrumentationKey)
{
// Arrange
var config = new LoggerConfiguration();

// Act / Assert
Assert.Throws<ArgumentException>(
() => config.WriteTo.AzureApplicationInsights(instrumentationKey, LogEventLevel.Debug));
}

[Theory]
[ClassData(typeof(Blanks))]
public void AzureApplicationInsightsWithMinLogLevelWithConfigOptions_WithoutInstrumentationKey_Fails(string instrumentationKey)
{
// Arrange
var config = new LoggerConfiguration();

// Act / Assert
Assert.Throws<ArgumentException>(
() => config.WriteTo.AzureApplicationInsights(instrumentationKey, LogEventLevel.Debug, options => { }));
}

[Theory]
[ClassData(typeof(Blanks))]
public void AzureApplicationInsightsWithInstrumentationKey_WithoutInstrumentationKey_Fails(string instrumentationKey)
Expand Down
Loading