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
12 changes: 6 additions & 6 deletions src/Sentry/Protocol/Envelopes/Envelope.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,9 @@ internal void Serialize(Stream stream, IDiagnosticLogger? logger, ISystemClock c
/// </summary>
public static Envelope FromEvent(
SentryEvent @event,
IDiagnosticLogger? logger = null,
IReadOnlyCollection<SentryAttachment>? attachments = null,
SessionUpdate? sessionUpdate = null)
SessionUpdate? sessionUpdate = null,
IDiagnosticLogger? logger = null)
{
var eventId = @event.EventId;
var header = CreateHeader(eventId, @event.DynamicSamplingContext);
Expand Down Expand Up @@ -336,9 +336,9 @@ private static void AddEnvelopeItemFromAttachment(List<EnvelopeItem> items, Sent
/// </summary>
public static Envelope FromFeedback(
SentryEvent @event,
IDiagnosticLogger? logger = null,
IReadOnlyCollection<SentryAttachment>? attachments = null,
SessionUpdate? sessionUpdate = null)
SessionUpdate? sessionUpdate = null,
IDiagnosticLogger? logger = null)
{
if (@event.Contexts.Feedback == null)
{
Expand Down Expand Up @@ -381,8 +381,8 @@ public static Envelope FromFeedback(
/// </summary>
public static Envelope FromTransaction(
SentryTransaction transaction,
IDiagnosticLogger? logger = null,
IReadOnlyCollection<SentryAttachment>? attachments = null)
IReadOnlyCollection<SentryAttachment>? attachments = null,
IDiagnosticLogger? logger = null)
{
var eventId = transaction.EventId;
var header = CreateHeader(eventId, transaction.DynamicSamplingContext);
Expand Down
6 changes: 3 additions & 3 deletions src/Sentry/SentryClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public SentryId CaptureFeedback(SentryFeedback feedback, out CaptureFeedbackResu
processedEvent = feedbackEvent;

var attachments = hint.Attachments.ToList();
var envelope = Envelope.FromFeedback(processedEvent, _options.DiagnosticLogger, attachments, scope.SessionUpdate);
var envelope = Envelope.FromFeedback(processedEvent, attachments, scope.SessionUpdate, _options.DiagnosticLogger);
if (CaptureEnvelope(envelope))
{
result = CaptureFeedbackResult.Success;
Expand Down Expand Up @@ -247,7 +247,7 @@ public void CaptureTransaction(SentryTransaction transaction, Scope? scope, Sent
// Keep null entries so the null-attachment guard in Envelope.FromTransaction handles them
// (consistent with the event/feedback capture paths); dereferencing them here would throw.
var attachments = hint.Attachments.Where(a => a is null || a.AddToTransactions).ToList();
CaptureEnvelope(Envelope.FromTransaction(processedTransaction, _options.DiagnosticLogger, attachments));
CaptureEnvelope(Envelope.FromTransaction(processedTransaction, attachments, _options.DiagnosticLogger));
}

private SentryTransaction? BeforeSendTransaction(SentryTransaction transaction, SentryHint hint, int spanCount)
Expand Down Expand Up @@ -426,7 +426,7 @@ private SentryId DoSendEvent(SentryEvent @event, SentryHint? hint, Scope? scope)
}

var attachments = hint.Attachments.ToList();
var envelope = Envelope.FromEvent(processedEvent, _options.DiagnosticLogger, attachments, scope.SessionUpdate);
var envelope = Envelope.FromEvent(processedEvent, attachments, scope.SessionUpdate, _options.DiagnosticLogger);
if (CaptureEnvelope(envelope))
{
#if SENTRY_UNITY
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2047,10 +2047,10 @@ namespace Sentry.Protocol.Envelopes
public Sentry.SentryId? TryGetEventId() { }
public static System.Threading.Tasks.Task<Sentry.Protocol.Envelopes.Envelope> DeserializeAsync(System.IO.Stream stream, System.Threading.CancellationToken cancellationToken = default) { }
public static Sentry.Protocol.Envelopes.Envelope FromCheckIn(Sentry.SentryCheckIn checkIn) { }
public static Sentry.Protocol.Envelopes.Envelope FromEvent(Sentry.SentryEvent @event, Sentry.Extensibility.IDiagnosticLogger? logger = null, System.Collections.Generic.IReadOnlyCollection<Sentry.SentryAttachment>? attachments = null, Sentry.SessionUpdate? sessionUpdate = null) { }
public static Sentry.Protocol.Envelopes.Envelope FromFeedback(Sentry.SentryEvent @event, Sentry.Extensibility.IDiagnosticLogger? logger = null, System.Collections.Generic.IReadOnlyCollection<Sentry.SentryAttachment>? attachments = null, Sentry.SessionUpdate? sessionUpdate = null) { }
public static Sentry.Protocol.Envelopes.Envelope FromEvent(Sentry.SentryEvent @event, System.Collections.Generic.IReadOnlyCollection<Sentry.SentryAttachment>? attachments = null, Sentry.SessionUpdate? sessionUpdate = null, Sentry.Extensibility.IDiagnosticLogger? logger = null) { }
public static Sentry.Protocol.Envelopes.Envelope FromFeedback(Sentry.SentryEvent @event, System.Collections.Generic.IReadOnlyCollection<Sentry.SentryAttachment>? attachments = null, Sentry.SessionUpdate? sessionUpdate = null, Sentry.Extensibility.IDiagnosticLogger? logger = null) { }
public static Sentry.Protocol.Envelopes.Envelope FromSession(Sentry.SessionUpdate sessionUpdate) { }
public static Sentry.Protocol.Envelopes.Envelope FromTransaction(Sentry.SentryTransaction transaction, Sentry.Extensibility.IDiagnosticLogger? logger = null, System.Collections.Generic.IReadOnlyCollection<Sentry.SentryAttachment>? attachments = null) { }
public static Sentry.Protocol.Envelopes.Envelope FromTransaction(Sentry.SentryTransaction transaction, System.Collections.Generic.IReadOnlyCollection<Sentry.SentryAttachment>? attachments = null, Sentry.Extensibility.IDiagnosticLogger? logger = null) { }
}
public sealed class EnvelopeItem : Sentry.Protocol.Envelopes.ISerializable, System.IDisposable
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2047,10 +2047,10 @@ namespace Sentry.Protocol.Envelopes
public Sentry.SentryId? TryGetEventId() { }
public static System.Threading.Tasks.Task<Sentry.Protocol.Envelopes.Envelope> DeserializeAsync(System.IO.Stream stream, System.Threading.CancellationToken cancellationToken = default) { }
public static Sentry.Protocol.Envelopes.Envelope FromCheckIn(Sentry.SentryCheckIn checkIn) { }
public static Sentry.Protocol.Envelopes.Envelope FromEvent(Sentry.SentryEvent @event, Sentry.Extensibility.IDiagnosticLogger? logger = null, System.Collections.Generic.IReadOnlyCollection<Sentry.SentryAttachment>? attachments = null, Sentry.SessionUpdate? sessionUpdate = null) { }
public static Sentry.Protocol.Envelopes.Envelope FromFeedback(Sentry.SentryEvent @event, Sentry.Extensibility.IDiagnosticLogger? logger = null, System.Collections.Generic.IReadOnlyCollection<Sentry.SentryAttachment>? attachments = null, Sentry.SessionUpdate? sessionUpdate = null) { }
public static Sentry.Protocol.Envelopes.Envelope FromEvent(Sentry.SentryEvent @event, System.Collections.Generic.IReadOnlyCollection<Sentry.SentryAttachment>? attachments = null, Sentry.SessionUpdate? sessionUpdate = null, Sentry.Extensibility.IDiagnosticLogger? logger = null) { }
public static Sentry.Protocol.Envelopes.Envelope FromFeedback(Sentry.SentryEvent @event, System.Collections.Generic.IReadOnlyCollection<Sentry.SentryAttachment>? attachments = null, Sentry.SessionUpdate? sessionUpdate = null, Sentry.Extensibility.IDiagnosticLogger? logger = null) { }
public static Sentry.Protocol.Envelopes.Envelope FromSession(Sentry.SessionUpdate sessionUpdate) { }
public static Sentry.Protocol.Envelopes.Envelope FromTransaction(Sentry.SentryTransaction transaction, Sentry.Extensibility.IDiagnosticLogger? logger = null, System.Collections.Generic.IReadOnlyCollection<Sentry.SentryAttachment>? attachments = null) { }
public static Sentry.Protocol.Envelopes.Envelope FromTransaction(Sentry.SentryTransaction transaction, System.Collections.Generic.IReadOnlyCollection<Sentry.SentryAttachment>? attachments = null, Sentry.Extensibility.IDiagnosticLogger? logger = null) { }
}
public sealed class EnvelopeItem : Sentry.Protocol.Envelopes.ISerializable, System.IDisposable
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2047,10 +2047,10 @@ namespace Sentry.Protocol.Envelopes
public Sentry.SentryId? TryGetEventId() { }
public static System.Threading.Tasks.Task<Sentry.Protocol.Envelopes.Envelope> DeserializeAsync(System.IO.Stream stream, System.Threading.CancellationToken cancellationToken = default) { }
public static Sentry.Protocol.Envelopes.Envelope FromCheckIn(Sentry.SentryCheckIn checkIn) { }
public static Sentry.Protocol.Envelopes.Envelope FromEvent(Sentry.SentryEvent @event, Sentry.Extensibility.IDiagnosticLogger? logger = null, System.Collections.Generic.IReadOnlyCollection<Sentry.SentryAttachment>? attachments = null, Sentry.SessionUpdate? sessionUpdate = null) { }
public static Sentry.Protocol.Envelopes.Envelope FromFeedback(Sentry.SentryEvent @event, Sentry.Extensibility.IDiagnosticLogger? logger = null, System.Collections.Generic.IReadOnlyCollection<Sentry.SentryAttachment>? attachments = null, Sentry.SessionUpdate? sessionUpdate = null) { }
public static Sentry.Protocol.Envelopes.Envelope FromEvent(Sentry.SentryEvent @event, System.Collections.Generic.IReadOnlyCollection<Sentry.SentryAttachment>? attachments = null, Sentry.SessionUpdate? sessionUpdate = null, Sentry.Extensibility.IDiagnosticLogger? logger = null) { }
public static Sentry.Protocol.Envelopes.Envelope FromFeedback(Sentry.SentryEvent @event, System.Collections.Generic.IReadOnlyCollection<Sentry.SentryAttachment>? attachments = null, Sentry.SessionUpdate? sessionUpdate = null, Sentry.Extensibility.IDiagnosticLogger? logger = null) { }
public static Sentry.Protocol.Envelopes.Envelope FromSession(Sentry.SessionUpdate sessionUpdate) { }
public static Sentry.Protocol.Envelopes.Envelope FromTransaction(Sentry.SentryTransaction transaction, Sentry.Extensibility.IDiagnosticLogger? logger = null, System.Collections.Generic.IReadOnlyCollection<Sentry.SentryAttachment>? attachments = null) { }
public static Sentry.Protocol.Envelopes.Envelope FromTransaction(Sentry.SentryTransaction transaction, System.Collections.Generic.IReadOnlyCollection<Sentry.SentryAttachment>? attachments = null, Sentry.Extensibility.IDiagnosticLogger? logger = null) { }
}
public sealed class EnvelopeItem : Sentry.Protocol.Envelopes.ISerializable, System.IDisposable
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2047,10 +2047,10 @@ namespace Sentry.Protocol.Envelopes
public Sentry.SentryId? TryGetEventId() { }
public static System.Threading.Tasks.Task<Sentry.Protocol.Envelopes.Envelope> DeserializeAsync(System.IO.Stream stream, System.Threading.CancellationToken cancellationToken = default) { }
public static Sentry.Protocol.Envelopes.Envelope FromCheckIn(Sentry.SentryCheckIn checkIn) { }
public static Sentry.Protocol.Envelopes.Envelope FromEvent(Sentry.SentryEvent @event, Sentry.Extensibility.IDiagnosticLogger? logger = null, System.Collections.Generic.IReadOnlyCollection<Sentry.SentryAttachment>? attachments = null, Sentry.SessionUpdate? sessionUpdate = null) { }
public static Sentry.Protocol.Envelopes.Envelope FromFeedback(Sentry.SentryEvent @event, Sentry.Extensibility.IDiagnosticLogger? logger = null, System.Collections.Generic.IReadOnlyCollection<Sentry.SentryAttachment>? attachments = null, Sentry.SessionUpdate? sessionUpdate = null) { }
public static Sentry.Protocol.Envelopes.Envelope FromEvent(Sentry.SentryEvent @event, System.Collections.Generic.IReadOnlyCollection<Sentry.SentryAttachment>? attachments = null, Sentry.SessionUpdate? sessionUpdate = null, Sentry.Extensibility.IDiagnosticLogger? logger = null) { }
public static Sentry.Protocol.Envelopes.Envelope FromFeedback(Sentry.SentryEvent @event, System.Collections.Generic.IReadOnlyCollection<Sentry.SentryAttachment>? attachments = null, Sentry.SessionUpdate? sessionUpdate = null, Sentry.Extensibility.IDiagnosticLogger? logger = null) { }
public static Sentry.Protocol.Envelopes.Envelope FromSession(Sentry.SessionUpdate sessionUpdate) { }
public static Sentry.Protocol.Envelopes.Envelope FromTransaction(Sentry.SentryTransaction transaction, Sentry.Extensibility.IDiagnosticLogger? logger = null, System.Collections.Generic.IReadOnlyCollection<Sentry.SentryAttachment>? attachments = null) { }
public static Sentry.Protocol.Envelopes.Envelope FromTransaction(Sentry.SentryTransaction transaction, System.Collections.Generic.IReadOnlyCollection<Sentry.SentryAttachment>? attachments = null, Sentry.Extensibility.IDiagnosticLogger? logger = null) { }
}
public sealed class EnvelopeItem : Sentry.Protocol.Envelopes.ISerializable, System.IDisposable
{
Expand Down
6 changes: 3 additions & 3 deletions test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2023,10 +2023,10 @@ namespace Sentry.Protocol.Envelopes
public Sentry.SentryId? TryGetEventId() { }
public static System.Threading.Tasks.Task<Sentry.Protocol.Envelopes.Envelope> DeserializeAsync(System.IO.Stream stream, System.Threading.CancellationToken cancellationToken = default) { }
public static Sentry.Protocol.Envelopes.Envelope FromCheckIn(Sentry.SentryCheckIn checkIn) { }
public static Sentry.Protocol.Envelopes.Envelope FromEvent(Sentry.SentryEvent @event, Sentry.Extensibility.IDiagnosticLogger? logger = null, System.Collections.Generic.IReadOnlyCollection<Sentry.SentryAttachment>? attachments = null, Sentry.SessionUpdate? sessionUpdate = null) { }
public static Sentry.Protocol.Envelopes.Envelope FromFeedback(Sentry.SentryEvent @event, Sentry.Extensibility.IDiagnosticLogger? logger = null, System.Collections.Generic.IReadOnlyCollection<Sentry.SentryAttachment>? attachments = null, Sentry.SessionUpdate? sessionUpdate = null) { }
public static Sentry.Protocol.Envelopes.Envelope FromEvent(Sentry.SentryEvent @event, System.Collections.Generic.IReadOnlyCollection<Sentry.SentryAttachment>? attachments = null, Sentry.SessionUpdate? sessionUpdate = null, Sentry.Extensibility.IDiagnosticLogger? logger = null) { }
public static Sentry.Protocol.Envelopes.Envelope FromFeedback(Sentry.SentryEvent @event, System.Collections.Generic.IReadOnlyCollection<Sentry.SentryAttachment>? attachments = null, Sentry.SessionUpdate? sessionUpdate = null, Sentry.Extensibility.IDiagnosticLogger? logger = null) { }
public static Sentry.Protocol.Envelopes.Envelope FromSession(Sentry.SessionUpdate sessionUpdate) { }
public static Sentry.Protocol.Envelopes.Envelope FromTransaction(Sentry.SentryTransaction transaction, Sentry.Extensibility.IDiagnosticLogger? logger = null, System.Collections.Generic.IReadOnlyCollection<Sentry.SentryAttachment>? attachments = null) { }
public static Sentry.Protocol.Envelopes.Envelope FromTransaction(Sentry.SentryTransaction transaction, System.Collections.Generic.IReadOnlyCollection<Sentry.SentryAttachment>? attachments = null, Sentry.Extensibility.IDiagnosticLogger? logger = null) { }
}
public sealed class EnvelopeItem : Sentry.Protocol.Envelopes.ISerializable, System.IDisposable
{
Expand Down
16 changes: 6 additions & 10 deletions test/Sentry.Tests/Internals/Http/HttpTransportTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -551,8 +551,8 @@ public async Task SendEnvelopeAsync_AttachmentFail_DropsItem()

using var envelope = Envelope.FromEvent(
new SentryEvent(),
logger,
new[] { attachment });
new[] { attachment },
logger: logger);

// Act
await httpTransport.SendEnvelopeAsync(envelope);
Expand Down Expand Up @@ -603,7 +603,6 @@ public async Task SendEnvelopeAsync_AttachmentTooLarge_DropsItem()

using var envelope = Envelope.FromEvent(
new SentryEvent(),
null,
new[] { attachmentNormal, attachmentTooBig });

// Act
Expand Down Expand Up @@ -648,7 +647,6 @@ public async Task SendEnvelopeAsync_HeapDumpAttachmentTooLarge_FileIsDeleted()

using var envelope = Envelope.FromEvent(
new SentryEvent(),
null,
[heapDumpAttachment]);

try
Expand Down Expand Up @@ -703,7 +701,6 @@ public async Task SendEnvelopeAsync_HeapDumpAttachmentSentSuccessfully_FileIsDel

using var envelope = Envelope.FromEvent(
new SentryEvent(),
null,
[heapDumpAttachment]);

try
Expand Down Expand Up @@ -758,7 +755,6 @@ public async Task SendEnvelopeAsync_NonHeapDumpAttachment_FileIsNotDeleted()

using var envelope = Envelope.FromEvent(
new SentryEvent(),
null,
[normalAttachment]);

try
Expand Down Expand Up @@ -797,7 +793,7 @@ public async Task SendEnvelopeAsync_ItemRateLimit_PromotesNextSessionWithSameId(
await httpTransport.SendEnvelopeAsync(Envelope.FromEvent(new SentryEvent()));

// Send session update with init=true
await httpTransport.SendEnvelopeAsync(Envelope.FromEvent(new SentryEvent(), null, null, session.CreateUpdate(true, DateTimeOffset.Now)));
await httpTransport.SendEnvelopeAsync(Envelope.FromEvent(new SentryEvent(), null, session.CreateUpdate(true, DateTimeOffset.Now)));

// Pretend the rate limit has already passed
foreach (var (category, _) in httpTransport.CategoryLimitResets)
Expand All @@ -808,7 +804,7 @@ public async Task SendEnvelopeAsync_ItemRateLimit_PromotesNextSessionWithSameId(
// Act

// Send another update with init=false (should get promoted)
await httpTransport.SendEnvelopeAsync(Envelope.FromEvent(new SentryEvent(), null, null, session.CreateUpdate(false, DateTimeOffset.Now)));
await httpTransport.SendEnvelopeAsync(Envelope.FromEvent(new SentryEvent(), null, session.CreateUpdate(false, DateTimeOffset.Now)));

var lastRequest = httpHandler.GetRequests().Last();
var actualEnvelopeSerialized = await lastRequest.Content!.ReadAsStringAsync();
Expand Down Expand Up @@ -839,7 +835,7 @@ public async Task SendEnvelopeAsync_ItemRateLimit_DoesNotAffectNextSessionWithDi
await httpTransport.SendEnvelopeAsync(Envelope.FromEvent(new SentryEvent()));

// Send session update with init=true
await httpTransport.SendEnvelopeAsync(Envelope.FromEvent(new SentryEvent(), null, null, session.CreateUpdate(true, DateTimeOffset.Now)));
await httpTransport.SendEnvelopeAsync(Envelope.FromEvent(new SentryEvent(), null, session.CreateUpdate(true, DateTimeOffset.Now)));

// Pretend the rate limit has already passed
foreach (var (category, _) in httpTransport.CategoryLimitResets)
Expand All @@ -851,7 +847,7 @@ public async Task SendEnvelopeAsync_ItemRateLimit_DoesNotAffectNextSessionWithDi

// Send an update for different session with init=false (should NOT get promoted)
var nextSession = new SentrySession("foo2", "bar2", "baz2");
await httpTransport.SendEnvelopeAsync(Envelope.FromEvent(new SentryEvent(), null, null, nextSession.CreateUpdate(false, DateTimeOffset.Now)));
await httpTransport.SendEnvelopeAsync(Envelope.FromEvent(new SentryEvent(), null, nextSession.CreateUpdate(false, DateTimeOffset.Now)));

var lastRequest = httpHandler.GetRequests().Last();
var actualEnvelopeSerialized = await lastRequest.Content!.ReadAsStringAsync();
Expand Down
6 changes: 3 additions & 3 deletions test/Sentry.Tests/Protocol/Envelopes/EnvelopeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ public async Task Roundtrip_WithEvent_WithAttachment_Success()
"file.txt",
null);

using var envelope = Envelope.FromEvent(@event, null, new[] { attachment });
using var envelope = Envelope.FromEvent(@event, new[] { attachment });

using var stream = new MemoryStream();

Expand Down Expand Up @@ -771,7 +771,7 @@ public void FromTransaction_WithNullAttachment_SkipsItAndLogsWarning()
var logger = new InMemoryDiagnosticLogger();

// Act
using var envelope = Envelope.FromTransaction(transaction, logger, attachments);
using var envelope = Envelope.FromTransaction(transaction, attachments, logger);

// Assert
// Only the transaction item and the single valid attachment - the null is skipped.
Expand Down Expand Up @@ -801,7 +801,7 @@ public async Task Roundtrip_WithEvent_WithSession_Success()

var sessionUpdate = new SentrySession("foo", "bar", "baz").CreateUpdate(false, DateTimeOffset.Now);

using var envelope = Envelope.FromEvent(@event, null, new[] { attachment }, sessionUpdate);
using var envelope = Envelope.FromEvent(@event, new[] { attachment }, sessionUpdate);

using var stream = new MemoryStream();

Expand Down
Loading