diff --git a/CHANGELOG.md b/CHANGELOG.md
index b731e24a1e..cf7f971bf9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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))
diff --git a/samples/Sentry.Samples.Console.Metrics/Program.cs b/samples/Sentry.Samples.Console.Metrics/Program.cs
index 058e9b1f2b..e506fc36d1 100644
--- a/samples/Sentry.Samples.Console.Metrics/Program.cs
+++ b/samples/Sentry.Samples.Console.Metrics/Program.cs
@@ -1,3 +1,4 @@
+#pragma warning disable CS0618 // Obsolete Warning
using System.Diagnostics.Metrics;
using System.Text.RegularExpressions;
@@ -137,3 +138,4 @@ private static async Task CallSampleApiAsync()
System.Console.WriteLine($"GET {url} {result.StatusCode}");
}
}
+#pragma warning restore CS0618
diff --git a/src/Sentry/Extensibility/HubAdapter.cs b/src/Sentry/Extensibility/HubAdapter.cs
index 3bf48f74c3..fbb2dbab7b 100644
--- a/src/Sentry/Extensibility/HubAdapter.cs
+++ b/src/Sentry/Extensibility/HubAdapter.cs
@@ -288,6 +288,9 @@ public Task FlushAsync(TimeSpan timeout)
=> SentrySdk.FlushAsync(timeout);
///
+ [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;
diff --git a/src/Sentry/Internal/Hub.cs b/src/Sentry/Internal/Hub.cs
index 1cd46f4d64..3a23aaecc3 100644
--- a/src/Sentry/Internal/Hub.cs
+++ b/src/Sentry/Internal/Hub.cs
@@ -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();
}
catch (Exception e)
{
diff --git a/src/Sentry/Internal/SystemDiagnosticsMetricsListener.cs b/src/Sentry/Internal/SystemDiagnosticsMetricsListener.cs
index af8fe4fbbd..f717f1d7f4 100644
--- a/src/Sentry/Internal/SystemDiagnosticsMetricsListener.cs
+++ b/src/Sentry/Internal/SystemDiagnosticsMetricsListener.cs
@@ -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
{
}
+
///
/// Overload for testing purposes - allows us to supply a mock IMetricAggregator
///
diff --git a/src/Sentry/SentrySdk.cs b/src/Sentry/SentrySdk.cs
index 0c3fd52a43..bf32c20d6c 100644
--- a/src/Sentry/SentrySdk.cs
+++ b/src/Sentry/SentrySdk.cs
@@ -668,6 +668,9 @@ public static TransactionContext ContinueTrace(
=> CurrentHub.ContinueTrace(traceHeader, baggageHeader, name, operation);
///
+ [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;
diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet6_0.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet6_0.verified.txt
index 9d3f44a7aa..af37b896ac 100644
--- a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet6_0.verified.txt
+++ b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet6_0.verified.txt
@@ -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? data = null, Sentry.BreadcrumbLevel level = 0) { }
@@ -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? 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? data = null, Sentry.BreadcrumbLevel level = 0) { }
diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet7_0.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet7_0.verified.txt
index 9d3f44a7aa..af37b896ac 100644
--- a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet7_0.verified.txt
+++ b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet7_0.verified.txt
@@ -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? data = null, Sentry.BreadcrumbLevel level = 0) { }
@@ -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? 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? data = null, Sentry.BreadcrumbLevel level = 0) { }
diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt
index 5fa4dfbeed..40d046e335 100644
--- a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt
+++ b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt
@@ -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? data = null, Sentry.BreadcrumbLevel level = 0) { }
@@ -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? 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? data = null, Sentry.BreadcrumbLevel level = 0) { }
diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt
index b60f14938d..5c0d7b38ac 100644
--- a/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt
+++ b/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt
@@ -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? data = null, Sentry.BreadcrumbLevel level = 0) { }
@@ -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? 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? data = null, Sentry.BreadcrumbLevel level = 0) { }