Skip to content

Commit

Permalink
Calls to SentryTracingBuilder can now be chained correctly (#2726)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamescrosswell committed Oct 16, 2023
1 parent d6a5ba2 commit 34d65a2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Fixes

- Fixed chaining on the IApplicationBuilder for methods like UseRouting and UseEndpoints ([#2726](https://github.com/getsentry/sentry-dotnet/pull/2726))

### Dependencies

- Bump Cocoa SDK from v8.13.0 to v8.13.1 ([#2722](https://github.com/getsentry/sentry-dotnet/pull/2722))
Expand Down
6 changes: 4 additions & 2 deletions src/Sentry.AspNetCore/SentryTracingBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,13 @@ public IApplicationBuilder Use(Func<RequestDelegate, RequestDelegate> middleware
var instrumenter = options?.Value.Instrumenter ?? Instrumenter.Sentry;
if (instrumenter == Instrumenter.Sentry)
{
return InnerBuilder.Use(middleware).UseSentryTracing();
InnerBuilder.Use(middleware).UseSentryTracing();
return this; // Make sure we return the same builder (not the inner builder), for chaining
}
this.StoreInstrumenter(instrumenter); // Saves us from having to resolve the options to make this check again
}

return InnerBuilder.Use(middleware);
InnerBuilder.Use(middleware);
return this; // Make sure we return the same builder (not the inner builder), for chaining
}
}

0 comments on commit 34d65a2

Please sign in to comment.