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
2 changes: 1 addition & 1 deletion src/Sentry.AspNet/HttpContextExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public static ITransactionTracer StartSentryTransaction(this HttpContext httpCon
var transaction = SentrySdk.StartTransaction(transactionContext, customSamplingContext, dynamicSamplingContext);
transaction.Contexts.Trace.Origin = AspNetOrigin;

SentrySdk.ConfigureScope(scope => scope.Transaction = transaction);
SentrySdk.ConfigureScope(static (scope, transaction) => scope.Transaction = transaction, transaction);
httpContext.Items[HttpContextTransactionItemName] = transaction;

if (options?.SendDefaultPii is true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ public void Configure(SentryBlazorOptions options)
var previousUrl = _navigationManager.Uri;

// Set the initial scope request URL
_hub.ConfigureScope(scope =>
{
scope.Request.Url = ToRelativePath(previousUrl);
});
_hub.ConfigureScope(static (scope, url) => scope.Request.Url = url, ToRelativePath(previousUrl));

_navigationManager.LocationChanged += (_, args) =>
{
Expand All @@ -61,10 +58,10 @@ public void Configure(SentryBlazorOptions options)
{ "to", to }
}));

_hub.ConfigureScope(scope =>
_hub.ConfigureScope(static (scope, to) =>
{
scope.Request.Url = to;
});
}, to);

previousUrl = args.Location;
};
Expand Down
24 changes: 12 additions & 12 deletions src/Sentry.AspNetCore.Grpc/SentryGrpcInterceptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ public override async Task<TResponse> UnaryServerHandler<TRequest, TResponse>(

using (hub.PushAndLockScope())
{
hub.ConfigureScope(scope =>
hub.ConfigureScope(static (scope, state) =>
{
scope.OnEvaluating += (_, activeScope) => activeScope.Populate(context, request, _options);
});
scope.OnEvaluating += (_, activeScope) => activeScope.Populate(state.Context, state.Request, state.Options);
}, (Options: _options, Context: context, Request: request));

try
{
Expand Down Expand Up @@ -102,10 +102,10 @@ public override async Task ServerStreamingServerHandler<TRequest, TResponse>(TRe

using (hub.PushAndLockScope())
{
hub.ConfigureScope(scope =>
hub.ConfigureScope(static (scope, state) =>
{
scope.OnEvaluating += (_, activeScope) => activeScope.Populate(context, request, _options);
});
scope.OnEvaluating += (_, activeScope) => activeScope.Populate(state.Context, state.Request, state.Options);
}, (Options: _options, Context: context, Request: request));

try
{
Expand Down Expand Up @@ -140,10 +140,10 @@ public override async Task<TResponse> ClientStreamingServerHandler<TRequest, TRe

using (hub.PushAndLockScope())
{
hub.ConfigureScope(scope =>
hub.ConfigureScope(static (scope, state) =>
{
scope.OnEvaluating += (_, activeScope) => activeScope.Populate<TRequest>(context, null, _options);
});
scope.OnEvaluating += (_, activeScope) => activeScope.Populate<TRequest>(state.Context, null, state.Options);
}, (Options: _options, Context: context));

try
{
Expand Down Expand Up @@ -183,10 +183,10 @@ public override async Task DuplexStreamingServerHandler<TRequest, TResponse>(

using (hub.PushAndLockScope())
{
hub.ConfigureScope(scope =>
hub.ConfigureScope(static (scope, state) =>
{
scope.OnEvaluating += (_, activeScope) => activeScope.Populate<TRequest>(context, null, _options);
});
scope.OnEvaluating += (_, activeScope) => activeScope.Populate<TRequest>(state.Context, null, state.Options);
}, (Options: _options, Context: context));

try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ private void RelayCommandOnPropertyChanged(object? sender, PropertyChangedEventA
var span = hub.StartSpan(SpanName, SpanOp);
if (span is ITransactionTracer transaction)
{
hub.ConfigureScope(scope => scope.Transaction = transaction);
hub.ConfigureScope(static (scope, transaction) => scope.Transaction = transaction, transaction);
}

relay.SetFused(span);
Expand Down
2 changes: 1 addition & 1 deletion src/Sentry/Integrations/GlobalRootScopeIntegration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ public void Register(IHub hub, SentryOptions options)
return;
}

hub.ConfigureScope(scope => scope.User.Id ??= options.InstallationId);
hub.ConfigureScope(static (scope, options) => scope.User.Id ??= options.InstallationId, options);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ public void Register_GlobalModeDisabled_DoesNotConfigureScope()
integration.Register(hub, options);

// Assert
hub.DidNotReceive().ConfigureScope(Arg.Any<Action<Scope>>());
hub.DidNotReceive().ConfigureScope(
Arg.Any<Action<Scope, SentryOptions>>(),
Arg.Any<SentryOptions>());
scope.User.Id.Should().BeNull();
}

Expand All @@ -48,7 +50,9 @@ public void Register_GlobalModeEnabled_SetsInstallationIdOnRootScope()
integration.Register(hub, options);

// Assert
hub.Received(1).ConfigureScope(Arg.Any<Action<Scope>>());
hub.Received(1).ConfigureScope(
Arg.Any<Action<Scope, SentryOptions>>(),
Arg.Any<SentryOptions>());
scope.User.Id.Should().Be(options.InstallationId);
}

Expand Down Expand Up @@ -79,7 +83,9 @@ public void Register_GlobalModeEnabled_DoesNotOverwriteExistingUserId()
integration.Register(hub, options);

// Assert
hub.Received(1).ConfigureScope(Arg.Any<Action<Scope>>());
hub.Received(1).ConfigureScope(
Arg.Any<Action<Scope, SentryOptions>>(),
Arg.Any<SentryOptions>());
scope.User.Id.Should().Be(oldId);
}

Expand Down
Loading