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

fix: Marked SentrySdk.Metrics as obsolete #3619

Merged
merged 6 commits into from
Sep 24, 2024
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## Unreleased

### API Changes

- The `SentrySdk.Metrics` module is deprecated and will be removed in the next major release.
Sentry will reject all metrics sent after October 7, 2024.
Learn more: https://sentry.zendesk.com/hc/en-us/articles/26369339769883-Upcoming-API-Changes-to-Metrics ([#3619](https://github.com/getsentry/sentry-dotnet/pull/3619))

### Dependencies

- Bump CLI from v2.36.1 to v2.36.2 ([#3624](https://github.com/getsentry/sentry-dotnet/pull/3624))
Expand Down
2 changes: 2 additions & 0 deletions samples/Sentry.Samples.Console.Metrics/Program.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pragma warning disable CS0618 // Obsolete Warning
using System.Diagnostics.Metrics;
using System.Text.RegularExpressions;

Expand Down Expand Up @@ -137,3 +138,4 @@ private static async Task CallSampleApiAsync()
System.Console.WriteLine($"GET {url} {result.StatusCode}");
}
}
#pragma warning restore CS0618
3 changes: 3 additions & 0 deletions src/Sentry/Extensibility/HubAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,9 @@ public Task FlushAsync(TimeSpan timeout)
=> SentrySdk.FlushAsync(timeout);

/// <inheritdoc cref="IMetricAggregator"/>
[Obsolete("The SentrySdk.Metrics module is deprecated and will be removed in the next major release. " +
"Sentry will reject all metrics sent after October 7, 2024." +
"Learn more: https://sentry.zendesk.com/hc/en-us/articles/26369339769883-Upcoming-API-Changes-to-Metrics")]
public IMetricAggregator Metrics
=> SentrySdk.Metrics;

Expand Down
4 changes: 1 addition & 3 deletions src/Sentry/Internal/Hub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -659,9 +659,7 @@ public void Dispose()

try
{
Metrics.FlushAsync().ContinueWith(_ =>
CurrentClient.FlushAsync(_options.ShutdownTimeout).ConfigureAwait(false).GetAwaiter().GetResult()
).ConfigureAwait(false).GetAwaiter().GetResult();
CurrentClient.FlushAsync(_options.ShutdownTimeout).ConfigureAwait(false).GetAwaiter().GetResult();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we marking it as obsolete or removing the functionality in this PR? This change is removing metrics functionality right?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see in the PR description:

While marking the API as obsolete I also removed the shutdown flushing. I think it's fairly low risk and it fixes the deadlocking situation in getsentry/sentry-unity#1779

}
catch (Exception e)
{
Expand Down
3 changes: 3 additions & 0 deletions src/Sentry/Internal/SystemDiagnosticsMetricsListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ internal class SystemDiagnosticsMetricsListener : IDisposable

internal readonly MeterListener _sentryListener = new();

#pragma warning disable CS0618 // Obsolete Warning
private SystemDiagnosticsMetricsListener(ExperimentalMetricsOptions metricsOptions)
: this(metricsOptions, () => SentrySdk.Metrics)
#pragma warning restore CS0618
{
}


/// <summary>
/// Overload for testing purposes - allows us to supply a mock IMetricAggregator
/// </summary>
Expand Down
3 changes: 3 additions & 0 deletions src/Sentry/SentrySdk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,9 @@ public static TransactionContext ContinueTrace(
=> CurrentHub.ContinueTrace(traceHeader, baggageHeader, name, operation);

/// <inheritdoc cref="IMetricAggregator"/>
[Obsolete("The SentrySdk.Metrics module is deprecated and will be removed in the next major release. " +
"Sentry will reject all metrics sent after October 7, 2024." +
"Learn more: https://sentry.zendesk.com/hc/en-us/articles/26369339769883-Upcoming-API-Changes-to-Metrics")]
public static IMetricAggregator Metrics
=> CurrentHub.Metrics;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,10 @@ namespace Sentry
{
public static bool IsEnabled { get; }
public static Sentry.SentryId LastEventId { get; }
[System.Obsolete("The SentrySdk.Metrics module is deprecated and will be removed in the next major " +
"release. Sentry will reject all metrics sent after October 7, 2024.Learn more: h" +
"ttps://sentry.zendesk.com/hc/en-us/articles/26369339769883-Upcoming-API-Changes-" +
"to-Metrics")]
public static Sentry.IMetricAggregator Metrics { get; }
public static void AddBreadcrumb(Sentry.Breadcrumb breadcrumb, Sentry.SentryHint? hint = null) { }
public static void AddBreadcrumb(string message, string? category = null, string? type = null, System.Collections.Generic.IDictionary<string, string>? data = null, Sentry.BreadcrumbLevel level = 0) { }
Expand Down Expand Up @@ -1322,6 +1326,10 @@ namespace Sentry.Extensibility
public static readonly Sentry.Extensibility.HubAdapter Instance;
public bool IsEnabled { get; }
public Sentry.SentryId LastEventId { get; }
[System.Obsolete("The SentrySdk.Metrics module is deprecated and will be removed in the next major " +
"release. Sentry will reject all metrics sent after October 7, 2024.Learn more: h" +
"ttps://sentry.zendesk.com/hc/en-us/articles/26369339769883-Upcoming-API-Changes-" +
"to-Metrics")]
public Sentry.IMetricAggregator Metrics { get; }
public void AddBreadcrumb(string message, string? category = null, string? type = null, System.Collections.Generic.IDictionary<string, string>? data = null, Sentry.BreadcrumbLevel level = 0) { }
public void AddBreadcrumb(Sentry.Infrastructure.ISystemClock clock, string message, string? category = null, string? type = null, System.Collections.Generic.IDictionary<string, string>? data = null, Sentry.BreadcrumbLevel level = 0) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,10 @@ namespace Sentry
{
public static bool IsEnabled { get; }
public static Sentry.SentryId LastEventId { get; }
[System.Obsolete("The SentrySdk.Metrics module is deprecated and will be removed in the next major " +
"release. Sentry will reject all metrics sent after October 7, 2024.Learn more: h" +
"ttps://sentry.zendesk.com/hc/en-us/articles/26369339769883-Upcoming-API-Changes-" +
"to-Metrics")]
public static Sentry.IMetricAggregator Metrics { get; }
public static void AddBreadcrumb(Sentry.Breadcrumb breadcrumb, Sentry.SentryHint? hint = null) { }
public static void AddBreadcrumb(string message, string? category = null, string? type = null, System.Collections.Generic.IDictionary<string, string>? data = null, Sentry.BreadcrumbLevel level = 0) { }
Expand Down Expand Up @@ -1322,6 +1326,10 @@ namespace Sentry.Extensibility
public static readonly Sentry.Extensibility.HubAdapter Instance;
public bool IsEnabled { get; }
public Sentry.SentryId LastEventId { get; }
[System.Obsolete("The SentrySdk.Metrics module is deprecated and will be removed in the next major " +
"release. Sentry will reject all metrics sent after October 7, 2024.Learn more: h" +
"ttps://sentry.zendesk.com/hc/en-us/articles/26369339769883-Upcoming-API-Changes-" +
"to-Metrics")]
public Sentry.IMetricAggregator Metrics { get; }
public void AddBreadcrumb(string message, string? category = null, string? type = null, System.Collections.Generic.IDictionary<string, string>? data = null, Sentry.BreadcrumbLevel level = 0) { }
public void AddBreadcrumb(Sentry.Infrastructure.ISystemClock clock, string message, string? category = null, string? type = null, System.Collections.Generic.IDictionary<string, string>? data = null, Sentry.BreadcrumbLevel level = 0) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,10 @@ namespace Sentry
{
public static bool IsEnabled { get; }
public static Sentry.SentryId LastEventId { get; }
[System.Obsolete("The SentrySdk.Metrics module is deprecated and will be removed in the next major " +
"release. Sentry will reject all metrics sent after October 7, 2024.Learn more: h" +
"ttps://sentry.zendesk.com/hc/en-us/articles/26369339769883-Upcoming-API-Changes-" +
"to-Metrics")]
public static Sentry.IMetricAggregator Metrics { get; }
public static void AddBreadcrumb(Sentry.Breadcrumb breadcrumb, Sentry.SentryHint? hint = null) { }
public static void AddBreadcrumb(string message, string? category = null, string? type = null, System.Collections.Generic.IDictionary<string, string>? data = null, Sentry.BreadcrumbLevel level = 0) { }
Expand Down Expand Up @@ -1324,6 +1328,10 @@ namespace Sentry.Extensibility
public static readonly Sentry.Extensibility.HubAdapter Instance;
public bool IsEnabled { get; }
public Sentry.SentryId LastEventId { get; }
[System.Obsolete("The SentrySdk.Metrics module is deprecated and will be removed in the next major " +
"release. Sentry will reject all metrics sent after October 7, 2024.Learn more: h" +
"ttps://sentry.zendesk.com/hc/en-us/articles/26369339769883-Upcoming-API-Changes-" +
"to-Metrics")]
public Sentry.IMetricAggregator Metrics { get; }
public void AddBreadcrumb(string message, string? category = null, string? type = null, System.Collections.Generic.IDictionary<string, string>? data = null, Sentry.BreadcrumbLevel level = 0) { }
public void AddBreadcrumb(Sentry.Infrastructure.ISystemClock clock, string message, string? category = null, string? type = null, System.Collections.Generic.IDictionary<string, string>? data = null, Sentry.BreadcrumbLevel level = 0) { }
Expand Down
8 changes: 8 additions & 0 deletions test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,10 @@ namespace Sentry
{
public static bool IsEnabled { get; }
public static Sentry.SentryId LastEventId { get; }
[System.Obsolete("The SentrySdk.Metrics module is deprecated and will be removed in the next major " +
"release. Sentry will reject all metrics sent after October 7, 2024.Learn more: h" +
"ttps://sentry.zendesk.com/hc/en-us/articles/26369339769883-Upcoming-API-Changes-" +
"to-Metrics")]
public static Sentry.IMetricAggregator Metrics { get; }
public static void AddBreadcrumb(Sentry.Breadcrumb breadcrumb, Sentry.SentryHint? hint = null) { }
public static void AddBreadcrumb(string message, string? category = null, string? type = null, System.Collections.Generic.IDictionary<string, string>? data = null, Sentry.BreadcrumbLevel level = 0) { }
Expand Down Expand Up @@ -1319,6 +1323,10 @@ namespace Sentry.Extensibility
public static readonly Sentry.Extensibility.HubAdapter Instance;
public bool IsEnabled { get; }
public Sentry.SentryId LastEventId { get; }
[System.Obsolete("The SentrySdk.Metrics module is deprecated and will be removed in the next major " +
"release. Sentry will reject all metrics sent after October 7, 2024.Learn more: h" +
"ttps://sentry.zendesk.com/hc/en-us/articles/26369339769883-Upcoming-API-Changes-" +
"to-Metrics")]
public Sentry.IMetricAggregator Metrics { get; }
public void AddBreadcrumb(string message, string? category = null, string? type = null, System.Collections.Generic.IDictionary<string, string>? data = null, Sentry.BreadcrumbLevel level = 0) { }
public void AddBreadcrumb(Sentry.Infrastructure.ISystemClock clock, string message, string? category = null, string? type = null, System.Collections.Generic.IDictionary<string, string>? data = null, Sentry.BreadcrumbLevel level = 0) { }
Expand Down
Loading