Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
d24d165
feat: add Batch Processor for Logs
Flash0ver Jun 26, 2025
aad0599
test: Batch Processor for Logs
Flash0ver Jun 26, 2025
76fcc1b
docs: Batch Processor for Logs
Flash0ver Jun 26, 2025
2ad33f6
test: fix unavailable API on TargetFramework=net48
Flash0ver Jun 27, 2025
38e1c04
test: run all Logs tests on full framework
Flash0ver Jun 27, 2025
f7a43b8
ref: remove usage of System.Threading.Lock
Flash0ver Jun 27, 2025
e6b0b74
ref: rename members for clarity
Flash0ver Jun 30, 2025
a84b78f
Merge branch 'feat/logs' into feat/logs-buffering
Flash0ver Jun 30, 2025
53c90ea
ref: delete Timer-Abstraction and change to System.Threading.Timer
Flash0ver Jul 1, 2025
6580632
ref: delete .ctor only called from tests
Flash0ver Jul 1, 2025
6e2ee9b
ref: switch Buffer-Processor to be lock-free but discarding
Flash0ver Jul 2, 2025
0774709
test: fix BatchBuffer and Tests
Flash0ver Jul 3, 2025
d9ae794
fix: flushing buffer on Timeout
Flash0ver Jul 8, 2025
7e1f5ea
feat: add Backpressure-ClientReport
Flash0ver Jul 10, 2025
365a2fb
ref: make BatchProcessor more resilient
Flash0ver Jul 11, 2025
c478391
Format code
getsentry-bot Jul 11, 2025
211beea
Merge branch 'feat/logs' into feat/logs-buffering
Flash0ver Jul 11, 2025
c699c2d
test: fix on .NET Framework
Flash0ver Jul 11, 2025
b21b537
fix: BatchBuffer flushed on Shutdown/Dispose
Flash0ver Jul 14, 2025
e8850db
ref: minimize locking
Flash0ver Jul 22, 2025
57f9ccc
Merge branch 'feat/logs' into feat/logs-buffering
Flash0ver Jul 22, 2025
c63bc53
ref: rename BatchProcessor to StructuredLogBatchProcessor
Flash0ver Jul 22, 2025
f28cc6d
ref: rename BatchBuffer to StructuredLogBatchBuffer
Flash0ver Jul 22, 2025
79ce02e
ref: remove internal options
Flash0ver Jul 23, 2025
0702796
test: ref
Flash0ver Jul 23, 2025
4e5f097
perf: update Benchmark result
Flash0ver Jul 23, 2025
1276725
ref: make SentryStructuredLogger. Flush abstract
Flash0ver Jul 24, 2025
3816fab
ref: guard an invariant of the Flush-Scope
Flash0ver Jul 24, 2025
28b6654
ref: remove unused values
Flash0ver Jul 24, 2025
1eef330
docs: improve comments
Flash0ver Jul 24, 2025
d72ca5c
perf: update Benchmark after signature change
Flash0ver Jul 25, 2025
49fefc1
ref: discard logs gracefully when Hub is (being) disposed
Flash0ver Jul 28, 2025
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
Prev Previous commit
Next Next commit
test: fix unavailable API on TargetFramework=net48
  • Loading branch information
Flash0ver committed Jun 27, 2025
commit 2ad33f6055a8937562418e2157a63f8b4d1e9a08
36 changes: 34 additions & 2 deletions test/Sentry.Testing/JsonSerializableExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#nullable enable

namespace Sentry.Testing;

internal static class JsonSerializableExtensions
{
private static readonly bool IsWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);

public static string ToJsonString(this ISentryJsonSerializable serializable, IDiagnosticLogger logger = null, bool indented = false) =>
public static string ToJsonString(this ISentryJsonSerializable serializable, IDiagnosticLogger? logger = null, bool indented = false) =>
WriteToJsonString(writer => writer.WriteSerializableValue(serializable, logger), indented);

public static string ToJsonString(this object @object, IDiagnosticLogger logger = null, bool indented = false) =>
public static string ToJsonString(this object @object, IDiagnosticLogger? logger = null, bool indented = false) =>
WriteToJsonString(writer => writer.WriteDynamicValue(@object, logger), indented);

private static string WriteToJsonString(Action<Utf8JsonWriter> writeAction, bool indented)
Expand Down Expand Up @@ -43,4 +45,34 @@ private static string WriteToJsonString(Action<Utf8JsonWriter> writeAction, bool
// Standardize on \n on all platforms, for consistency in tests.
return IsWindows ? result.Replace("\r\n", "\n") : result;
}

public static JsonDocument ToJsonDocument(this ISentryJsonSerializable serializable, IDiagnosticLogger? logger = null) =>
WriteToJsonDocument(writer => writer.WriteSerializableValue(serializable, logger));

public static JsonDocument ToJsonDocument(this object @object, IDiagnosticLogger? logger = null) =>
WriteToJsonDocument(writer => writer.WriteDynamicValue(@object, logger));

private static JsonDocument WriteToJsonDocument(Action<Utf8JsonWriter> writeAction)
{
#if (NETCOREAPP3_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER)
// This implementation is better, as it uses fewer allocations
var buffer = new ArrayBufferWriter<byte>();

using var writer = new Utf8JsonWriter(buffer);
writeAction(writer);
writer.Flush();

return JsonDocument.Parse(buffer.WrittenMemory);
#else
// This implementation is compatible with older targets
using var stream = new MemoryStream();

using var writer = new Utf8JsonWriter(stream);
writeAction(writer);
writer.Flush();

stream.Seek(0, SeekOrigin.Begin);
return JsonDocument.Parse(stream);
#endif
}
}
1 change: 1 addition & 0 deletions test/Sentry.Tests/Internals/DebugStackTraceTests.verify.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ public Task CreateFrame_ForNativeAOT()
IP = 2,
});

Assert.NotNull(frame);
return VerifyJson(frame.ToJsonString());
}
#endif
Expand Down
6 changes: 1 addition & 5 deletions test/Sentry.Tests/Protocol/StructuredLogTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,8 @@ public void WriteTo_Empty_AsJson()
{
var log = new StructuredLog([]);

ArrayBufferWriter<byte> bufferWriter = new();
using Utf8JsonWriter writer = new(bufferWriter);
log.WriteTo(writer, _output);
writer.Flush();
var document = log.ToJsonDocument(_output);

var document = JsonDocument.Parse(bufferWriter.WrittenMemory);
Assert.Equal("""{"items":[]}""", document.RootElement.ToString());
}

Expand Down