getsentry / getsentry/sentry-dotnet

Refactor OnEvaluating event hook to avoid delegate allocation

Open
#4,253 0 comments 0 reactions 0 assignees View on GitHub
.NET Improvement Performance
Dominant language
C#
Stars
770
Forks
248
Avg merge
3d 4h
Merged PRs (30d)
49

Description

The outer `ConfigureScope` call no longer allocates a closure, but this `OnEvaluating` event handler still allocates unconditionally. One solution might be to store `KeyValuePair`s of the callback and its argument instead of using an event inside a `Stack`. Perhaps the `Stack` wouldn't even be necessary when the `Sentry.AspNetCore.Grpc` integration isn't loaded, as that seems to be the only other place (outside of tests) where this event handler is assigned.

_Originally posted by @KnapSac in https://github.com/getsentry/sentry-dotnet/pull/4244#discussion_r2124679960_

Worth reading through that whole thread on the other issue before coming up with a solution (and probably worth putting some benchmarks together - possibly some load tests as well).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.