Skip to content

Commit

Permalink
backporting 2.1.8 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
bruno-garcia committed Nov 21, 2020
1 parent 27267e6 commit a98a7c9
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 13 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## vNext

* Add SentryScopeProcessor #603

## 3.0.0-alpha.5

* Replaced `BaseScope` with `IScope`. (#590) @Tyrrrz
Expand Down
2 changes: 1 addition & 1 deletion samples/Sentry.Samples.Console.Customized/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ private class MyCustomerScopeStateProcessor : ISentryScopeStateProcessor
{
private readonly ISentryScopeStateProcessor _fallback = new DefaultSentryScopeStateProcessor();

public void Apply(BaseScope scope, object state)
public void Apply(IScope scope, object state)
{
if (state is SpecialContextObject specialState)
{
Expand Down
7 changes: 0 additions & 7 deletions src/Sentry.Protocol/ISentryScopeProcessor.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@

namespace Sentry.Protocol
{
public class DefaultSentryScopeProcessor : ISentryScopeProcessor
/// <summary>
/// Defines the logic for applying state onto a scope.
/// </summary>
public class DefaultSentryScopeStateProcessor : ISentryScopeStateProcessor
{
public void Apply(BaseScope scope, object state)
/// <summary>
/// Applies state onto a scope.
/// </summary>
public void Apply(IScope scope, object state)
{
switch (state)
{
Expand All @@ -23,7 +29,7 @@ public void Apply(BaseScope scope, object state)
scope.SetTags(keyValStringObject
.Select(k => new KeyValuePair<string, string>(
k.Key,
k.Value?.ToString()))
k.Value?.ToString()!))
.Where(kv => !string.IsNullOrEmpty(kv.Value)));

break;
Expand Down
13 changes: 13 additions & 0 deletions src/Sentry/Protocol/ISentryScopeStateProcessor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace Sentry.Protocol
{
/// <summary>
/// Defines the logic for applying state onto a scope.
/// </summary>
public interface ISentryScopeStateProcessor
{
/// <summary>
/// Applies state onto a scope.
/// </summary>
void Apply(IScope scope, object state);
}
}
4 changes: 2 additions & 2 deletions src/Sentry/ScopeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using Sentry.Extensibility;
using System.Linq;
using Sentry.Internal;
using Sentry.Protocol;
using Constants = Sentry.Protocol.Constants;
Expand Down Expand Up @@ -354,7 +354,7 @@ public static void Apply(this IScope from, IScope to)
/// <param name="state">The state object to apply.</param>
public static void Apply(this IScope scope, object state)
{
var processor = scope.ScopeOptions.SentryScopeProcessor ?? new DefaultSentryScopeProcessor();
var processor = scope.ScopeOptions?.SentryScopeStateProcessor ?? new DefaultSentryScopeStateProcessor();
processor.Apply(scope, state);
}

Expand Down

0 comments on commit a98a7c9

Please sign in to comment.