Skip to content

Commit

Permalink
[AzureMonitorDistro] revert custom events (#45797)
Browse files Browse the repository at this point in the history
* disable tests in net6 and MacOS

* revert pr 45630

* revert change in LogForwarder from pr 45681
  • Loading branch information
TimothyMothra authored Sep 4, 2024
1 parent ad65e49 commit 7116390
Show file tree
Hide file tree
Showing 13 changed files with 5 additions and 400 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
<!-- Depending on monthly deliverables, we may switch between PackageReference or ProjectReference. Keeping both here to make the switch easier. -->

<!-- FOR PUBLIC RELEASES, MUST USE PackageReference. THIS REQUIRES A STAGGERED RELEASE IF SHIPPING A NEW EXPORTER. -->
<!--<PackageReference Include="Azure.Monitor.OpenTelemetry.Exporter" />-->
<PackageReference Include="Azure.Monitor.OpenTelemetry.Exporter" />

<!-- FOR LOCAL DEV, ProjectReference IS PREFERRED. -->
<ProjectReference Include="..\..\Azure.Monitor.OpenTelemetry.Exporter\src\Azure.Monitor.OpenTelemetry.Exporter.csproj" />
<!--<ProjectReference Include="..\..\Azure.Monitor.OpenTelemetry.Exporter\src\Azure.Monitor.OpenTelemetry.Exporter.csproj" />-->
</ItemGroup>

<!-- Shared sources from Azure.Core -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public AzureEventSourceLogForwarder(ILoggerFactory loggerFactory, LoggerFilterOp
foreach (var rule in loggerFilterOptions?.Rules ?? Enumerable.Empty<LoggerFilterRule>())
{
if (!string.IsNullOrEmpty(rule.CategoryName)
&& rule.CategoryName != "Azure.Monitor.OpenTelemetry.CustomEvents" // Exporter defines a custom filter rule to support CustomEvents. We MUST ignore this here.
&& (rule.CategoryName.StartsWith("Azure.") || rule.CategoryName.StartsWith("Microsoft.Azure.")))
{
_hasAzureLoggerFilterOptionsRules = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using Azure.Monitor.OpenTelemetry.AspNetCore.Internals.LiveMetrics;
using Azure.Monitor.OpenTelemetry.AspNetCore.Internals.Profiling;
using Azure.Monitor.OpenTelemetry.AspNetCore.LiveMetrics;
using Azure.Monitor.OpenTelemetry.Events;
using Azure.Monitor.OpenTelemetry.Exporter;
using Azure.Monitor.OpenTelemetry.Exporter.Internals.Platform;
using Microsoft.Extensions.Configuration;
Expand All @@ -29,7 +28,6 @@ namespace Azure.Monitor.OpenTelemetry.AspNetCore
public static class OpenTelemetryBuilderExtensions
{
private const string SqlClientInstrumentationPackageName = "OpenTelemetry.Instrumentation.SqlClient";
private const string EventLoggerName = "Azure.Monitor.OpenTelemetry.CustomEvents";

/// <summary>
/// Configures Azure Monitor for logging, distributed tracing, and metrics.
Expand Down Expand Up @@ -214,34 +212,6 @@ public static OpenTelemetryBuilder UseAzureMonitor(this OpenTelemetryBuilder bui
}
});

// Enable custom events and set filter to enable collection.
builder.Services.TryAddSingleton<IApplicationInsightsEventLogger, ApplicationInsightsEventLogger>();

// The default behavior is to always capture logs for custom events.
// This can achieved with this code level filter -> loggingBuilder.AddFilter<OpenTelemetry.Logs.ApplicationInsightsLoggerProvider>("",LogLevel.Information);
// However, this may run into issues when users try to override this behavior from Configuration like below using appsettings.json:
// {
// "Logging": {
// "OpenTelemetry": {
// "LogLevel": {
// "Azure.Monitor.OpenTelemetry.CustomEvents": "None"
// }
// }
// },
// ...
// }
// The reason is as both rules will match the filter, the last one added wins.
// To ensure that the default filter is in the beginning of filter rules, so that user override from Configuration will always win,
// we add code filter rule to the 0th position as below.
builder.Services.Configure<LoggerFilterOptions>(
options => options.Rules.Insert(
0,
new LoggerFilterRule(
"OpenTelemetry",
EventLoggerName,
LogLevel.Information,
null)));

return builder;
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
namespace Azure.Monitor.OpenTelemetry.Events
{
public sealed partial class ApplicationInsightsEventLogger : Azure.Monitor.OpenTelemetry.Events.IApplicationInsightsEventLogger
{
public ApplicationInsightsEventLogger(Microsoft.Extensions.Logging.ILoggerFactory loggerFactory) { }
public void TrackEvent(string name, System.Collections.Generic.IReadOnlyList<System.Collections.Generic.KeyValuePair<string, object?>>? attributes = null) { }
}
public partial interface IApplicationInsightsEventLogger
{
void TrackEvent(string name, System.Collections.Generic.IReadOnlyList<System.Collections.Generic.KeyValuePair<string, object?>>? attributes = null);
}
}
namespace Azure.Monitor.OpenTelemetry.Exporter
{
public static partial class AzureMonitorExporterExtensions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
namespace Azure.Monitor.OpenTelemetry.Events
{
public sealed partial class ApplicationInsightsEventLogger : Azure.Monitor.OpenTelemetry.Events.IApplicationInsightsEventLogger
{
public ApplicationInsightsEventLogger(Microsoft.Extensions.Logging.ILoggerFactory loggerFactory) { }
public void TrackEvent(string name, System.Collections.Generic.IReadOnlyList<System.Collections.Generic.KeyValuePair<string, object?>>? attributes = null) { }
}
public partial interface IApplicationInsightsEventLogger
{
void TrackEvent(string name, System.Collections.Generic.IReadOnlyList<System.Collections.Generic.KeyValuePair<string, object?>>? attributes = null);
}
}
namespace Azure.Monitor.OpenTelemetry.Exporter
{
public static partial class AzureMonitorExporterExtensions
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ public TelemetryItem(string name, TelemetryItem telemetryItem, ActivitySpanId ac
}
}

public TelemetryItem (string name, LogRecord logRecord, AzureMonitorResource? resource, string instrumentationKey) :
this(name, FormatUtcTimestamp(logRecord.Timestamp))
public TelemetryItem (LogRecord logRecord, AzureMonitorResource? resource, string instrumentationKey) :
this(logRecord.Exception != null ? "Exception" : "Message", FormatUtcTimestamp(logRecord.Timestamp))
{
if (logRecord.TraceId != default)
{
Expand Down
Loading

0 comments on commit 7116390

Please sign in to comment.