Skip to content

feat!: replace GetInternalSentryOptions with a GetDiagnosticLogger extension on IHub - #5862

Merged
jamescrosswell merged 3 commits into
version7from
ai/sentry-dotnet-4641-21f52e
Nov 4, 2026
Merged

jamescrosswell merged 3 commits into
version7from
ai/sentry-dotnet-4641-21f52e

Conversation

@jamescrosswell

@jamescrosswell jamescrosswell commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

SentryClientExtensions.GetInternalSentryOptions was public only because Sentry.Hangfire isn't strong-named (#4099), so it can't see Sentry's internals, and it needed the diagnostic logger. It was marked [Obsolete] to discourage anyone else from using it, which misuses the attribute (see the discussion on #4619).

This removes it and adds what Hangfire actually needs, as a real public API:

namespace Sentry.Extensibility;

public static class HubDiagnosticExtensions
{
    public static IDiagnosticLogger? GetDiagnosticLogger(this IHub hub);
}

Any integration that can't use InternalsVisibleTo has the same need, third-party ones included, so this is a legitimate API rather than a "pubternal" one. It lives in Sentry.Extensibility with HubAdapter and IDiagnosticLogger, so app code that doesn't import that namespace won't see it.

Breaking: GetInternalSentryOptions is removed. Nothing in getsentry/sentry-unity calls it.

Changelog Entry

  • Remove GetInternalSentryOptions, which was only meant for Sentry's own integrations. Integrations that need the SDK's diagnostic logger can call the new GetDiagnosticLogger() extension on IHub, in Sentry.Extensibility.

Notes for review

  • I went with an extension method rather than a property on IHub. A new interface member would break every IHub implementer (netstandard2.0 has no default interface members), and a DiagnosticLogger next to the existing IHub.Logger (structured logs) would be easy to confuse. The trade-off: a custom IHub gets null, which is what GetInternalSentryOptions returned for one too.
  • SentryServerFilter now looks up the logger each time it logs instead of once in its constructor. Before, if UseSentry() ran before SentrySdk.Init, HubAdapter returned no options and the filter never logged.
  • ApiApprovalTests.Run.Net4_8.verified.txt was edited by hand (it can't be regenerated on macOS), to match the other TFMs.

Closes #4641

🤖 Generated with Claude Code

GetInternalSentryOptions was public only so Sentry.Hangfire, which isn't
strong-named and so can't see Sentry's internals, could read the
diagnostic logger. Replace it with a narrow, documented
GetDiagnosticLogger extension in Sentry.Extensibility and remove the
Obsolete-marked method.

The Hangfire server filter now resolves the logger when it logs instead
of once in its constructor, so it still logs when UseSentry() runs
before SentrySdk.Init.

Closes #4641

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 53.33333% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.65%. Comparing base (d28aa8b) to head (0f152b1).
⚠️ Report is 5 commits behind head on version7.

Files with missing lines Patch % Lines
src/Sentry.Hangfire/SentryServerFilter.cs 50.00% 1 Missing and 6 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           version7    #5862      +/-   ##
============================================
- Coverage     76.76%   76.65%   -0.12%     
============================================
  Files           539      540       +1     
  Lines         19694    19798     +104     
  Branches       3851     3886      +35     
============================================
+ Hits          15119    15177      +58     
- Misses         3703     3748      +45     
- Partials        872      873       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jamescrosswell
jamescrosswell marked this pull request as ready for review November 3, 2026 21:28
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Nov 3, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jamescrosswell
jamescrosswell merged commit 8a21164 into version7 Nov 4, 2026
49 checks passed
@jamescrosswell
jamescrosswell deleted the ai/sentry-dotnet-4641-21f52e branch November 4, 2026 20:20
ric-oliv added a commit to getsentry/sentry-docs that referenced this pull request Nov 13, 2026
## DESCRIBE YOUR PR

This gets the 6.x to 7.x migration guide for the Sentry SDK for .NET
ready for 7.0.0, following #20143. It targets `dotnet-v7`, so it goes
live with the rest of the 7.0.0 docs in #20641.

- Removes the release candidate alert. Its note about restore error
NU1605 still applies to .NET 11 apps on 7.0.0, so it moves to "Supported
.NET Versions and Platforms".
- Adds "Category Log Levels No Longer Filter Breadcrumbs and Events",
for getsentry/sentry-dotnet#5869. Entries under
`Logging:Sentry:LogLevel` now only filter logs, so an app that silenced
a category gets that category's breadcrumbs and events. The section
shows `AddLogEntryFilter` for apps that want the old filtering.
- Adds `GetInternalSentryOptions` to "Other Removed and Internal APIs",
for getsentry/sentry-dotnet#5862, and points to the new
`GetDiagnosticLogger()` extension on `IHub`.
- Links the Generic Host guide from #20311 and the MAUI guide's
supported versions from #20642, which are both on `dotnet-v7`.

These two SDK PRs are the only changes merged on `version7` since
7.0.0-rc.3 that affect people upgrading from 6.x.

Two things depend on how 7.0.0 ships:

- The NU1605 note assumes the `net11.0` builds depend on the stable .NET
11 packages. On `version7` today, they depend on .NET 11 RC 3.
- The `LogLevel` fix also landed on 6.x in getsentry/sentry-dotnet#5872,
which isn't released yet. The section says "6.12.1 and earlier", so it
stays correct whether or not a 6.x release ships first.

Refs getsentry/sentry-dotnet#5710

## IS YOUR CHANGE URGENT?

Help us prioritize incoming PRs by letting us know when the change needs
to go live.
Select exactly one option. For deadlines, replace `YYYY-MM-DD` with the
due date. You can update this information later by editing the PR
description.

- [x] Urgent deadline (GA date, etc.): 2026-10-10
- [ ] Other deadline: YYYY-MM-DD
- [ ] No deadline: Not urgent, can wait up to 1 week+

## SLA

- Teamwork makes the dream work, so please add a reviewer to your PRs.
- Please give the docs team up to 1 week to review your PR unless you've
supplied a deadline.

Thanks in advance for your help!

## PRE-MERGE CHECKLIST

_Make sure you've checked the following before merging your changes:_

- [ ] Checked Vercel preview for correctness, including links
- [ ] PR was reviewed and approved by any necessary SMEs (subject matter
experts)
- [ ] PR was reviewed and approved by a member of the [Sentry docs
team](https://github.com/orgs/getsentry/teams/docs)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: James Crosswell <jamescrosswell@users.noreply.github.com>
Co-authored-by: Alex Krawiec <alex.krawiec@sentry.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider alternative to ObsoleteAttribute on GetInternalSentryOptions

2 participants