Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BackgroundWorker: make types public #1450

Merged
merged 6 commits into from
Jan 29, 2022
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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

## Unreleased

## Features
### Features

- Add the delegate TransactionNameProvider to allow the name definition from Unknown transactions on ASP.NET Core ([#1421](https://github.com/getsentry/sentry-dotnet/pull/1421))
- SentrySDK.WithScope is now obsolete in favour of overloads of CaptureEvent, CaptureMessage, CaptureException ([#1412](https://github.com/getsentry/sentry-dotnet/pull/1412))
- Add Sentry to global usings when ImplicitUsings is enabled (`<ImplicitUsings>true</ImplicitUsings>`) ([#1398](https://github.com/getsentry/sentry-dotnet/pull/1398))
- The implementation of the background worker can now be changed ([#1450](https://github.com/getsentry/sentry-dotnet/pull/1450))

### Fixes

Expand Down
2 changes: 1 addition & 1 deletion src/Sentry/Envelopes/Envelope.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Sentry.Protocol.Envelopes
/// <summary>
/// Envelope.
/// </summary>
internal sealed class Envelope : ISerializable, IDisposable
public sealed class Envelope : ISerializable, IDisposable
{
private const string EventIdKey = "event_id";

Expand Down
6 changes: 5 additions & 1 deletion src/Sentry/Envelopes/EnvelopeItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Sentry.Protocol.Envelopes
/// <summary>
/// Envelope item.
/// </summary>
internal sealed class EnvelopeItem : ISerializable, IDisposable
public sealed class EnvelopeItem : ISerializable, IDisposable
{
private const string TypeKey = "type";
private const string TypeValueEvent = "event";
Expand Down Expand Up @@ -58,6 +58,10 @@ public EnvelopeItem(IReadOnlyDictionary<string, object?> header, ISerializable p
var value => Convert.ToInt64(value) // can be int, long, or another numeric type
};

/// <summary>
/// Returns the file name or null if no name exists.
/// </summary>
/// <returns>The file name or null.</returns>
public string? TryGetFileName() => Header.GetValueOrDefault(FileNameKey) as string;

private async Task<MemoryStream> BufferPayloadAsync(IDiagnosticLogger? logger, CancellationToken cancellationToken = default)
Expand Down
2 changes: 1 addition & 1 deletion src/Sentry/Envelopes/ISerializable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Sentry.Protocol.Envelopes
/// <summary>
/// Represents a serializable entity.
/// </summary>
internal interface ISerializable
public interface ISerializable
{
/// <summary>
/// Serializes the object to a stream.
Expand Down
2 changes: 1 addition & 1 deletion src/Sentry/Extensibility/IBackgroundWorker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Sentry.Extensibility
/// <summary>
/// A worker that queues envelopes synchronously and flushes async.
/// </summary>
internal interface IBackgroundWorker
public interface IBackgroundWorker
{
/// <summary>
/// Attempts to queue the envelope with the worker.
Expand Down
5 changes: 4 additions & 1 deletion src/Sentry/SentryOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ public bool IsGlobalModeEnabled

internal IExceptionFilter[]? ExceptionFilters { get; set; } = Array.Empty<IExceptionFilter>();

internal IBackgroundWorker? BackgroundWorker { get; set; }
/// <summary>
/// The worker used by the client to pass envelopes.
/// </summary>
public IBackgroundWorker? BackgroundWorker { get; set; }

internal ISentryHttpClientFactory? SentryHttpClientFactory { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ namespace Sentry
public bool AttachStacktrace { get; set; }
public bool AutoSessionTracking { get; set; }
public System.TimeSpan AutoSessionTrackingInterval { get; set; }
public Sentry.Extensibility.IBackgroundWorker? BackgroundWorker { get; set; }
public System.Func<Sentry.Breadcrumb, Sentry.Breadcrumb?>? BeforeBreadcrumb { get; set; }
public System.Func<Sentry.SentryEvent, Sentry.SentryEvent?>? BeforeSend { get; set; }
public string? CacheDirectoryPath { get; set; }
Expand Down Expand Up @@ -981,6 +982,12 @@ namespace Sentry.Extensibility
"nd CaptureException that provide a callback to a configurable scope.")]
public void WithScope(System.Action<Sentry.Scope> scopeCallback) { }
}
public interface IBackgroundWorker
{
int QueuedItems { get; }
bool EnqueueEnvelope(Sentry.Protocol.Envelopes.Envelope envelope);
System.Threading.Tasks.Task FlushAsync(System.TimeSpan timeout);
}
public interface IDiagnosticLogger
{
bool IsEnabled(Sentry.SentryLevel level);
Expand Down Expand Up @@ -1305,6 +1312,44 @@ namespace Sentry.Protocol
public static Sentry.Protocol.Trace FromJson(System.Text.Json.JsonElement json) { }
}
}
namespace Sentry.Protocol.Envelopes
{
public sealed class Envelope : Sentry.Protocol.Envelopes.ISerializable, System.IDisposable
{
public Envelope(System.Collections.Generic.IReadOnlyDictionary<string, object?> header, System.Collections.Generic.IReadOnlyList<Sentry.Protocol.Envelopes.EnvelopeItem> items) { }
public System.Collections.Generic.IReadOnlyDictionary<string, object?> Header { get; }
public System.Collections.Generic.IReadOnlyList<Sentry.Protocol.Envelopes.EnvelopeItem> Items { get; }
public void Dispose() { }
public System.Threading.Tasks.Task SerializeAsync(System.IO.Stream stream, Sentry.Extensibility.IDiagnosticLogger? logger, System.Threading.CancellationToken cancellationToken = default) { }
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 FromEvent(Sentry.SentryEvent @event, Sentry.Extensibility.IDiagnosticLogger? logger = null, System.Collections.Generic.IReadOnlyCollection<Sentry.Attachment>? attachments = null, Sentry.SessionUpdate? sessionUpdate = null) { }
public static Sentry.Protocol.Envelopes.Envelope FromSession(Sentry.SessionUpdate sessionUpdate) { }
public static Sentry.Protocol.Envelopes.Envelope FromTransaction(Sentry.Transaction transaction) { }
public static Sentry.Protocol.Envelopes.Envelope FromUserFeedback(Sentry.UserFeedback sentryUserFeedback) { }
}
public sealed class EnvelopeItem : Sentry.Protocol.Envelopes.ISerializable, System.IDisposable
{
public EnvelopeItem(System.Collections.Generic.IReadOnlyDictionary<string, object?> header, Sentry.Protocol.Envelopes.ISerializable payload) { }
public System.Collections.Generic.IReadOnlyDictionary<string, object?> Header { get; }
public Sentry.Protocol.Envelopes.ISerializable Payload { get; }
public void Dispose() { }
public System.Threading.Tasks.Task SerializeAsync(System.IO.Stream stream, Sentry.Extensibility.IDiagnosticLogger? logger, System.Threading.CancellationToken cancellationToken = default) { }
public string? TryGetFileName() { }
public long? TryGetLength() { }
public string? TryGetType() { }
public static System.Threading.Tasks.Task<Sentry.Protocol.Envelopes.EnvelopeItem> DeserializeAsync(System.IO.Stream stream, System.Threading.CancellationToken cancellationToken = default) { }
public static Sentry.Protocol.Envelopes.EnvelopeItem FromAttachment(Sentry.Attachment attachment) { }
public static Sentry.Protocol.Envelopes.EnvelopeItem FromEvent(Sentry.SentryEvent @event) { }
public static Sentry.Protocol.Envelopes.EnvelopeItem FromSession(Sentry.SessionUpdate sessionUpdate) { }
public static Sentry.Protocol.Envelopes.EnvelopeItem FromTransaction(Sentry.Transaction transaction) { }
public static Sentry.Protocol.Envelopes.EnvelopeItem FromUserFeedback(Sentry.UserFeedback sentryUserFeedback) { }
}
public interface ISerializable
{
System.Threading.Tasks.Task SerializeAsync(System.IO.Stream stream, Sentry.Extensibility.IDiagnosticLogger? logger, System.Threading.CancellationToken cancellationToken = default);
}
}
namespace Sentry.Reflection
{
public static class AssemblyExtensions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ namespace Sentry
public bool AttachStacktrace { get; set; }
public bool AutoSessionTracking { get; set; }
public System.TimeSpan AutoSessionTrackingInterval { get; set; }
public Sentry.Extensibility.IBackgroundWorker? BackgroundWorker { get; set; }
public System.Func<Sentry.Breadcrumb, Sentry.Breadcrumb?>? BeforeBreadcrumb { get; set; }
public System.Func<Sentry.SentryEvent, Sentry.SentryEvent?>? BeforeSend { get; set; }
public string? CacheDirectoryPath { get; set; }
Expand Down Expand Up @@ -981,6 +982,12 @@ namespace Sentry.Extensibility
"nd CaptureException that provide a callback to a configurable scope.")]
public void WithScope(System.Action<Sentry.Scope> scopeCallback) { }
}
public interface IBackgroundWorker
{
int QueuedItems { get; }
bool EnqueueEnvelope(Sentry.Protocol.Envelopes.Envelope envelope);
System.Threading.Tasks.Task FlushAsync(System.TimeSpan timeout);
}
public interface IDiagnosticLogger
{
bool IsEnabled(Sentry.SentryLevel level);
Expand Down Expand Up @@ -1305,6 +1312,44 @@ namespace Sentry.Protocol
public static Sentry.Protocol.Trace FromJson(System.Text.Json.JsonElement json) { }
}
}
namespace Sentry.Protocol.Envelopes
{
public sealed class Envelope : Sentry.Protocol.Envelopes.ISerializable, System.IDisposable
{
public Envelope(System.Collections.Generic.IReadOnlyDictionary<string, object?> header, System.Collections.Generic.IReadOnlyList<Sentry.Protocol.Envelopes.EnvelopeItem> items) { }
public System.Collections.Generic.IReadOnlyDictionary<string, object?> Header { get; }
public System.Collections.Generic.IReadOnlyList<Sentry.Protocol.Envelopes.EnvelopeItem> Items { get; }
public void Dispose() { }
public System.Threading.Tasks.Task SerializeAsync(System.IO.Stream stream, Sentry.Extensibility.IDiagnosticLogger? logger, System.Threading.CancellationToken cancellationToken = default) { }
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 FromEvent(Sentry.SentryEvent @event, Sentry.Extensibility.IDiagnosticLogger? logger = null, System.Collections.Generic.IReadOnlyCollection<Sentry.Attachment>? attachments = null, Sentry.SessionUpdate? sessionUpdate = null) { }
public static Sentry.Protocol.Envelopes.Envelope FromSession(Sentry.SessionUpdate sessionUpdate) { }
public static Sentry.Protocol.Envelopes.Envelope FromTransaction(Sentry.Transaction transaction) { }
public static Sentry.Protocol.Envelopes.Envelope FromUserFeedback(Sentry.UserFeedback sentryUserFeedback) { }
}
public sealed class EnvelopeItem : Sentry.Protocol.Envelopes.ISerializable, System.IDisposable
{
public EnvelopeItem(System.Collections.Generic.IReadOnlyDictionary<string, object?> header, Sentry.Protocol.Envelopes.ISerializable payload) { }
public System.Collections.Generic.IReadOnlyDictionary<string, object?> Header { get; }
public Sentry.Protocol.Envelopes.ISerializable Payload { get; }
public void Dispose() { }
public System.Threading.Tasks.Task SerializeAsync(System.IO.Stream stream, Sentry.Extensibility.IDiagnosticLogger? logger, System.Threading.CancellationToken cancellationToken = default) { }
public string? TryGetFileName() { }
public long? TryGetLength() { }
public string? TryGetType() { }
public static System.Threading.Tasks.Task<Sentry.Protocol.Envelopes.EnvelopeItem> DeserializeAsync(System.IO.Stream stream, System.Threading.CancellationToken cancellationToken = default) { }
public static Sentry.Protocol.Envelopes.EnvelopeItem FromAttachment(Sentry.Attachment attachment) { }
public static Sentry.Protocol.Envelopes.EnvelopeItem FromEvent(Sentry.SentryEvent @event) { }
public static Sentry.Protocol.Envelopes.EnvelopeItem FromSession(Sentry.SessionUpdate sessionUpdate) { }
public static Sentry.Protocol.Envelopes.EnvelopeItem FromTransaction(Sentry.Transaction transaction) { }
public static Sentry.Protocol.Envelopes.EnvelopeItem FromUserFeedback(Sentry.UserFeedback sentryUserFeedback) { }
}
public interface ISerializable
{
System.Threading.Tasks.Task SerializeAsync(System.IO.Stream stream, Sentry.Extensibility.IDiagnosticLogger? logger, System.Threading.CancellationToken cancellationToken = default);
}
}
namespace Sentry.Reflection
{
public static class AssemblyExtensions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ namespace Sentry
public bool AttachStacktrace { get; set; }
public bool AutoSessionTracking { get; set; }
public System.TimeSpan AutoSessionTrackingInterval { get; set; }
public Sentry.Extensibility.IBackgroundWorker? BackgroundWorker { get; set; }
public System.Func<Sentry.Breadcrumb, Sentry.Breadcrumb?>? BeforeBreadcrumb { get; set; }
public System.Func<Sentry.SentryEvent, Sentry.SentryEvent?>? BeforeSend { get; set; }
public string? CacheDirectoryPath { get; set; }
Expand Down Expand Up @@ -981,6 +982,12 @@ namespace Sentry.Extensibility
"nd CaptureException that provide a callback to a configurable scope.")]
public void WithScope(System.Action<Sentry.Scope> scopeCallback) { }
}
public interface IBackgroundWorker
{
int QueuedItems { get; }
bool EnqueueEnvelope(Sentry.Protocol.Envelopes.Envelope envelope);
System.Threading.Tasks.Task FlushAsync(System.TimeSpan timeout);
}
public interface IDiagnosticLogger
{
bool IsEnabled(Sentry.SentryLevel level);
Expand Down Expand Up @@ -1305,6 +1312,44 @@ namespace Sentry.Protocol
public static Sentry.Protocol.Trace FromJson(System.Text.Json.JsonElement json) { }
}
}
namespace Sentry.Protocol.Envelopes
{
public sealed class Envelope : Sentry.Protocol.Envelopes.ISerializable, System.IDisposable
{
public Envelope(System.Collections.Generic.IReadOnlyDictionary<string, object?> header, System.Collections.Generic.IReadOnlyList<Sentry.Protocol.Envelopes.EnvelopeItem> items) { }
public System.Collections.Generic.IReadOnlyDictionary<string, object?> Header { get; }
public System.Collections.Generic.IReadOnlyList<Sentry.Protocol.Envelopes.EnvelopeItem> Items { get; }
public void Dispose() { }
public System.Threading.Tasks.Task SerializeAsync(System.IO.Stream stream, Sentry.Extensibility.IDiagnosticLogger? logger, System.Threading.CancellationToken cancellationToken = default) { }
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 FromEvent(Sentry.SentryEvent @event, Sentry.Extensibility.IDiagnosticLogger? logger = null, System.Collections.Generic.IReadOnlyCollection<Sentry.Attachment>? attachments = null, Sentry.SessionUpdate? sessionUpdate = null) { }
public static Sentry.Protocol.Envelopes.Envelope FromSession(Sentry.SessionUpdate sessionUpdate) { }
public static Sentry.Protocol.Envelopes.Envelope FromTransaction(Sentry.Transaction transaction) { }
public static Sentry.Protocol.Envelopes.Envelope FromUserFeedback(Sentry.UserFeedback sentryUserFeedback) { }
}
public sealed class EnvelopeItem : Sentry.Protocol.Envelopes.ISerializable, System.IDisposable
{
public EnvelopeItem(System.Collections.Generic.IReadOnlyDictionary<string, object?> header, Sentry.Protocol.Envelopes.ISerializable payload) { }
public System.Collections.Generic.IReadOnlyDictionary<string, object?> Header { get; }
public Sentry.Protocol.Envelopes.ISerializable Payload { get; }
public void Dispose() { }
public System.Threading.Tasks.Task SerializeAsync(System.IO.Stream stream, Sentry.Extensibility.IDiagnosticLogger? logger, System.Threading.CancellationToken cancellationToken = default) { }
public string? TryGetFileName() { }
public long? TryGetLength() { }
public string? TryGetType() { }
public static System.Threading.Tasks.Task<Sentry.Protocol.Envelopes.EnvelopeItem> DeserializeAsync(System.IO.Stream stream, System.Threading.CancellationToken cancellationToken = default) { }
public static Sentry.Protocol.Envelopes.EnvelopeItem FromAttachment(Sentry.Attachment attachment) { }
public static Sentry.Protocol.Envelopes.EnvelopeItem FromEvent(Sentry.SentryEvent @event) { }
public static Sentry.Protocol.Envelopes.EnvelopeItem FromSession(Sentry.SessionUpdate sessionUpdate) { }
public static Sentry.Protocol.Envelopes.EnvelopeItem FromTransaction(Sentry.Transaction transaction) { }
public static Sentry.Protocol.Envelopes.EnvelopeItem FromUserFeedback(Sentry.UserFeedback sentryUserFeedback) { }
}
public interface ISerializable
{
System.Threading.Tasks.Task SerializeAsync(System.IO.Stream stream, Sentry.Extensibility.IDiagnosticLogger? logger, System.Threading.CancellationToken cancellationToken = default);
}
}
namespace Sentry.Reflection
{
public static class AssemblyExtensions
Expand Down
Loading