Skip to content
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
- In MAUI Android apps, generate and inject UUID to APK and upload ProGuard mapping to Sentry with the UUID ([#4532](https://github.com/getsentry/sentry-dotnet/pull/4532))
- Fixed WASM0001 warning when building Blazor WebAssembly projects ([#4519](https://github.com/getsentry/sentry-dotnet/pull/4519))

### API Changes

- Remove `ExperimentalAttribute` from all _Structured Logs_ APIs, and remove `Experimental` property from `SentrySdk`, but keep `Experimental` property on `SentryOptions` ([#4567](https://github.com/getsentry/sentry-dotnet/pull/4567))

### Dependencies

- Bump Cocoa SDK from v8.56.0 to v8.56.1 ([#4555](https://github.com/getsentry/sentry-dotnet/pull/4555))
Expand Down
8 changes: 4 additions & 4 deletions samples/Sentry.Samples.Console.Basic/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
// This option tells Sentry to capture 100% of traces. You still need to start transactions and spans.
options.TracesSampleRate = 1.0;

// This option enables Sentry Logs created via SentrySdk.Experimental.Logger.
// This option enables Sentry Logs created via SentrySdk.Logger.
options.Experimental.EnableLogs = true;
Comment thread
Flash0ver marked this conversation as resolved.
options.Experimental.SetBeforeSendLog(static log =>
{
Expand Down Expand Up @@ -73,7 +73,7 @@ async Task FirstFunction()
var httpClient = new HttpClient(messageHandler, true);
var html = await httpClient.GetStringAsync("https://example.com/");
WriteLine(html);
SentrySdk.Experimental.Logger.LogInfo("HTTP Request completed.");
SentrySdk.Logger.LogInfo("HTTP Request completed.");
}

async Task SecondFunction()
Expand All @@ -94,7 +94,7 @@ async Task SecondFunction()
SentrySdk.CaptureException(exception);
span.Finish(exception);

SentrySdk.Experimental.Logger.LogError(static log => log.SetAttribute("method", nameof(SecondFunction)),
SentrySdk.Logger.LogError(static log => log.SetAttribute("method", nameof(SecondFunction)),
"Error with message: {0}", exception.Message);
}

Expand All @@ -109,7 +109,7 @@ async Task ThirdFunction()
// Simulate doing some work
await Task.Delay(100);

SentrySdk.Experimental.Logger.LogFatal(static log => log.SetAttribute("suppress", true),
SentrySdk.Logger.LogFatal(static log => log.SetAttribute("suppress", true),
"Crash imminent!");

// This is an example of an unhandled exception. It will be captured automatically.
Expand Down
2 changes: 0 additions & 2 deletions src/Sentry/Extensibility/DisabledHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,6 @@ public void CaptureUserFeedback(UserFeedback userFeedback)

/// <summary>
/// Disabled Logger.
/// <para>This API is experimental and it may change in the future.</para>
/// </summary>
[Experimental(Infrastructure.DiagnosticId.ExperimentalFeature)]
public SentryStructuredLogger Logger => DisabledSentryStructuredLogger.Instance;
}
4 changes: 1 addition & 3 deletions src/Sentry/Extensibility/HubAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,8 @@ private HubAdapter() { }

/// <summary>
/// Forwards the call to <see cref="SentrySdk"/>.
/// <para>This API is experimental and it may change in the future.</para>
/// </summary>
[Experimental(DiagnosticId.ExperimentalFeature)]
public SentryStructuredLogger Logger { [DebuggerStepThrough] get => SentrySdk.Experimental.Logger; }
public SentryStructuredLogger Logger { [DebuggerStepThrough] get => SentrySdk.Logger; }

/// <summary>
/// Forwards the call to <see cref="SentrySdk"/>.
Expand Down
2 changes: 0 additions & 2 deletions src/Sentry/IHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public interface IHub : ISentryClient, ISentryScopeManager

/// <summary>
/// Creates and sends logs to Sentry.
/// <para>This API is experimental and it may change in the future.</para>
/// </summary>
/// <remarks>
/// Available options:
Expand All @@ -28,7 +27,6 @@ public interface IHub : ISentryClient, ISentryScopeManager
/// <item><see cref="Sentry.SentryOptions.SentryExperimentalOptions.SetBeforeSendLog(System.Func{SentryLog, SentryLog})"/></item>
/// </list>
/// </remarks>
[Experimental(Infrastructure.DiagnosticId.ExperimentalFeature)]
public SentryStructuredLogger Logger { get; }

/// <summary>
Expand Down
28 changes: 6 additions & 22 deletions src/Sentry/SentryLog.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
using Sentry.Extensibility;
using Sentry.Infrastructure;
using Sentry.Protocol;

namespace Sentry;

/// <summary>
/// Represents the Sentry Log protocol.
/// <para>This API is experimental and it may change in the future.</para>
/// Represents a Sentry Structured Log.
/// </summary>
[Experimental(DiagnosticId.ExperimentalFeature)]
/// <remarks>
/// Sentry Docs: <see href="https://docs.sentry.io/product/explore/logs/"/>.
/// Sentry Developer Documentation: <see href="https://develop.sentry.dev/sdk/telemetry/logs/"/>.
/// Sentry .NET SDK Docs: <see href="https://docs.sentry.io/platforms/dotnet/logs/"/>.
/// </remarks>
[DebuggerDisplay(@"SentryLog \{ Level = {Level}, Message = '{Message}' \}")]
public sealed class SentryLog
{
Expand All @@ -27,59 +29,44 @@ internal SentryLog(DateTimeOffset timestamp, SentryId traceId, SentryLogLevel le

/// <summary>
/// The timestamp of the log.
/// <para>This API is experimental and it may change in the future.</para>
/// </summary>
/// <remarks>
/// Sent as seconds since the Unix epoch.
/// </remarks>
[Experimental(DiagnosticId.ExperimentalFeature)]
public required DateTimeOffset Timestamp { get; init; }

/// <summary>
/// The trace id of the log.
/// <para>This API is experimental and it may change in the future.</para>
/// </summary>
[Experimental(DiagnosticId.ExperimentalFeature)]
public required SentryId TraceId { get; init; }

/// <summary>
/// The severity level of the log.
/// <para>This API is experimental and it may change in the future.</para>
/// </summary>
[Experimental(DiagnosticId.ExperimentalFeature)]
public required SentryLogLevel Level { get; init; }

/// <summary>
/// The formatted log message.
/// <para>This API is experimental and it may change in the future.</para>
/// </summary>
[Experimental(DiagnosticId.ExperimentalFeature)]
public required string Message { get; init; }

/// <summary>
/// The parameterized template string.
/// <para>This API is experimental and it may change in the future.</para>
/// </summary>
[Experimental(DiagnosticId.ExperimentalFeature)]
public string? Template { get; init; }

/// <summary>
/// The parameters to the template string.
/// <para>This API is experimental and it may change in the future.</para>
/// </summary>
[Experimental(DiagnosticId.ExperimentalFeature)]
public ImmutableArray<KeyValuePair<string, object>> Parameters { get; init; }

/// <summary>
/// The span id of the span that was active when the log was collected.
/// <para>This API is experimental and it may change in the future.</para>
/// </summary>
[Experimental(DiagnosticId.ExperimentalFeature)]
public SpanId? ParentSpanId { get; init; }

/// <summary>
/// Gets the attribute value associated with the specified key.
/// <para>This API is experimental and it may change in the future.</para>
/// </summary>
/// <remarks>
/// Returns <see langword="true"/> if the <see cref="SentryLog"/> contains an attribute with the specified key and it's value is not <see langword="null"/>.
Expand Down Expand Up @@ -128,7 +115,6 @@ internal SentryLog(DateTimeOffset timestamp, SentryId traceId, SentryLogLevel le
/// </list>
/// </remarks>
/// <seealso href="https://develop.sentry.dev/sdk/telemetry/logs/"/>
[Experimental(DiagnosticId.ExperimentalFeature)]
public bool TryGetAttribute(string key, [NotNullWhen(true)] out object? value)
{
if (_attributes.TryGetValue(key, out var attribute) && attribute.Value is not null)
Expand All @@ -155,9 +141,7 @@ internal bool TryGetAttribute(string key, [NotNullWhen(true)] out string? value)

/// <summary>
/// Set a key-value pair of data attached to the log.
/// <para>This API is experimental and it may change in the future.</para>
/// </summary>
[Experimental(DiagnosticId.ExperimentalFeature)]
public void SetAttribute(string key, object value)
{
_attributes[key] = new SentryAttribute(value);
Expand Down
3 changes: 0 additions & 3 deletions src/Sentry/SentryLogLevel.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using Sentry.Extensibility;
using Sentry.Infrastructure;

namespace Sentry;

/// <summary>
/// The severity of the structured log.
/// <para>This API is experimental and it may change in the future.</para>
/// </summary>
/// <remarks>
/// The named constants use the value of the lowest severity number per severity level:
Expand Down Expand Up @@ -41,7 +39,6 @@ namespace Sentry;
/// </list>
/// </remarks>
/// <seealso href="https://develop.sentry.dev/sdk/telemetry/logs/"/>
[Experimental(DiagnosticId.ExperimentalFeature)]
public enum SentryLogLevel
{
/// <summary>
Expand Down
4 changes: 0 additions & 4 deletions src/Sentry/SentryOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1864,7 +1864,6 @@ internal static List<StringOrRegex> GetDefaultInAppExclude() =>
/// <remarks>
/// This and related experimental APIs may change in the future.
/// </remarks>
[Experimental(DiagnosticId.ExperimentalFeature)]
public SentryExperimentalOptions Experimental { get; set; } = new();

/// <summary>
Expand All @@ -1873,7 +1872,6 @@ internal static List<StringOrRegex> GetDefaultInAppExclude() =>
/// <remarks>
/// This and related experimental APIs may change in the future.
/// </remarks>
[Experimental(DiagnosticId.ExperimentalFeature)]
public sealed class SentryExperimentalOptions
{
internal SentryExperimentalOptions()
Expand All @@ -1883,7 +1881,6 @@ internal SentryExperimentalOptions()
/// <summary>
/// When set to <see langword="true"/>, logs are sent to Sentry.
/// Defaults to <see langword="false"/>.
/// <para>This API is experimental and it may change in the future.</para>
/// </summary>
/// <seealso href="https://develop.sentry.dev/sdk/telemetry/logs/"/>
public bool EnableLogs { get; set; } = false;
Expand All @@ -1895,7 +1892,6 @@ internal SentryExperimentalOptions()
/// <summary>
/// Sets a callback function to be invoked before sending the log to Sentry.
/// When the delegate throws an <see cref="Exception"/> during invocation, the log will not be captured.
/// <para>This API is experimental and it may change in the future.</para>
/// </summary>
Comment thread
Flash0ver marked this conversation as resolved.
/// <remarks>
/// It can be used to modify the log object before being sent to Sentry.
Expand Down
14 changes: 2 additions & 12 deletions src/Sentry/SentrySdk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -284,18 +284,8 @@ public void Dispose()
/// </summary>
public static bool IsEnabled { [DebuggerStepThrough] get => CurrentHub.IsEnabled; }

/// <summary>
/// Experimental Sentry SDK features.
/// </summary>
/// <remarks>
/// This and related experimental APIs may change in the future.
/// </remarks>
[Experimental(DiagnosticId.ExperimentalFeature)]
public static class Experimental
{
/// <inheritdoc cref="IHub.Logger" />
public static SentryStructuredLogger Logger { [DebuggerStepThrough] get => CurrentHub.Logger; }
}
/// <inheritdoc cref="IHub.Logger" />
Comment thread
Flash0ver marked this conversation as resolved.
public static SentryStructuredLogger Logger { [DebuggerStepThrough] get => CurrentHub.Logger; }

/// <summary>
/// Creates a new scope that will terminate when disposed.
Expand Down
Loading
Loading