@@ -569,6 +569,32 @@ public void SetBeforeSendLog(Func<SentryLog, SentryLog?> beforeSendLog)
569569 _beforeSendLog = beforeSendLog ;
570570 }
571571
572+ /// <summary>
573+ /// When set to <see langword="false"/>, the SDK does not generate and send metrics to Sentry via <see cref="SentrySdk.Metrics"/>.
574+ /// Defaults to <see langword="true"/>.
575+ /// </summary>
576+ /// <seealso href="https://develop.sentry.dev/sdk/telemetry/metrics/"/>
577+ public bool EnableMetrics { get ; set ; } = true ;
578+
579+ private Func < SentryMetric , SentryMetric ? > ? _beforeSendMetric ;
580+
581+ internal Func < SentryMetric , SentryMetric ? > ? BeforeSendMetricInternal => _beforeSendMetric ;
582+
583+ /// <summary>
584+ /// Sets a callback function to be invoked before sending the metric to Sentry.
585+ /// When the delegate throws an <see cref="Exception"/> during invocation, the metric will not be captured.
586+ /// </summary>
587+ /// <remarks>
588+ /// It can be used to modify the metric object before being sent to Sentry.
589+ /// To prevent the metric from being sent to Sentry, return <see langword="null"/>.
590+ /// Supported numeric value types are <see langword="byte"/>, <see langword="short"/>, <see langword="int"/>, <see langword="long"/>, <see langword="float"/>, and <see langword="double"/>.
591+ /// </remarks>
592+ /// <seealso href="https://develop.sentry.dev/sdk/telemetry/metrics/"/>
593+ public void SetBeforeSendMetric ( Func < SentryMetric , SentryMetric ? > beforeSendMetric )
594+ {
595+ _beforeSendMetric = beforeSendMetric ;
596+ }
597+
572598 private int _maxQueueItems = 30 ;
573599
574600 /// <summary>
@@ -1907,51 +1933,4 @@ internal static List<StringOrRegex> GetDefaultInAppExclude() =>
19071933 InAppExcludeRegexes . LibMonoSgen ,
19081934 InAppExcludeRegexes . LibXamarin
19091935 ] ;
1910-
1911- /// <summary>
1912- /// Sentry features that are currently in an experimental state.
1913- /// </summary>
1914- /// <remarks>
1915- /// Experimental features are subject to binary, source and behavioral breaking changes in future updates.
1916- /// </remarks>
1917- public ExperimentalSentryOptions Experimental { get ; } = new ExperimentalSentryOptions ( ) ;
1918-
1919- /// <summary>
1920- /// Sentry features that are currently in an experimental state.
1921- /// </summary>
1922- /// <remarks>
1923- /// Experimental features are subject to binary, source and behavioral breaking changes in future updates.
1924- /// </remarks>
1925- public class ExperimentalSentryOptions
1926- {
1927- private Func < SentryMetric , SentryMetric ? > ? _beforeSendMetric ;
1928-
1929- internal ExperimentalSentryOptions ( )
1930- {
1931- }
1932-
1933- internal Func < SentryMetric , SentryMetric ? > ? BeforeSendMetricInternal => _beforeSendMetric ;
1934-
1935- /// <summary>
1936- /// When set to <see langword="false"/>, the SDK does not generate and send metrics to Sentry via <see cref="SentrySdk"/>.
1937- /// Defaults to <see langword="true"/>.
1938- /// </summary>
1939- /// <seealso href="https://develop.sentry.dev/sdk/telemetry/metrics/"/>
1940- public bool EnableMetrics { get ; set ; } = true ;
1941-
1942- /// <summary>
1943- /// Sets a callback function to be invoked before sending the metric to Sentry.
1944- /// When the delegate throws an <see cref="Exception"/> during invocation, the metric will not be captured.
1945- /// </summary>
1946- /// <remarks>
1947- /// It can be used to modify the metric object before being sent to Sentry.
1948- /// To prevent the metric from being sent to Sentry, return <see langword="null"/>.
1949- /// Supported numeric value types are <see langword="byte"/>, <see langword="short"/>, <see langword="int"/>, <see langword="long"/>, <see langword="float"/>, and <see langword="double"/>.
1950- /// </remarks>
1951- /// <seealso href="https://develop.sentry.dev/sdk/telemetry/metrics/"/>
1952- public void SetBeforeSendMetric ( Func < SentryMetric , SentryMetric ? > beforeSendMetric )
1953- {
1954- _beforeSendMetric = beforeSendMetric ;
1955- }
1956- }
19571936}
0 commit comments