Skip to content

Conversation

alexsohn1126
Copy link
Member

@alexsohn1126 alexsohn1126 commented Sep 25, 2025

Fixes #4560, fixes #4618

Problem

According to our SDK specification, we have to set sentry.origin whenever a log is sent from an integration.

Solution

sentry-dotnet has a few integrations that send out logs. This PR affects the following integrations:

  • Sentry.Extensions.Logging
  • Sentry.Serilog

And affects other integrations that references Sentry.Extensions.Logging, or references it transitively.

Comparison

Before, logs from Sentry.Serilog didn't have sentry.origin:
image

After, logs from Sentry.Serilog has sentry.origin populated:
Screenshot 2025-09-25 at 4 14 59 PM

@alexsohn1126
Copy link
Member Author

@sentry review

@alexsohn1126
Copy link
Member Author

bugbot review

This comment has been minimized.

Copy link

cursor bot commented Sep 25, 2025

🚨 Bugbot couldn't run

Something went wrong. Try again by commenting "Cursor review" or "bugbot run", or contact support (requestId: serverGenReqId_8ec61e90-31f9-40d2-9718-56e6535d466d).

@alexsohn1126
Copy link
Member Author

bugbot review

cursor[bot]

This comment was marked as outdated.

@alexsohn1126
Copy link
Member Author

@sentry review

Copy link

codecov bot commented Sep 25, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.47%. Comparing base (e58a8f1) to head (84380b4).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4566   +/-   ##
=======================================
  Coverage   73.46%   73.47%           
=======================================
  Files         482      482           
  Lines       17678    17682    +4     
  Branches     3493     3493           
=======================================
+ Hits        12988    12992    +4     
  Misses       3800     3800           
  Partials      890      890           

☔ View full report in Codecov by Sentry.
📢 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.

@alexsohn1126 alexsohn1126 changed the title WIP fix: Ensure integration logs have sentry.origin set fix: Ensure integration logs have sentry.origin set Sep 26, 2025
@alexsohn1126 alexsohn1126 marked this pull request as ready for review September 26, 2025 00:01
cursor[bot]

This comment was marked as outdated.

Copy link
Member

@Flash0ver Flash0ver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100 % convinced of the origin names that we use right now, but also don't have a concrete suggestion in store ... if you don't mind, I'll let my mind wander a bit and will get back to you soon.
Also, feedback from other reviewers appreciated. @jamescrosswell what do you think?

@alexsohn1126 alexsohn1126 changed the title fix: Ensure integration logs have sentry.origin set fix: Ensure structured logs from an SDK integration has sentry.origin Sep 29, 2025
@jamescrosswell
Copy link
Collaborator

I'm not 100 % convinced of the origin names that we use right now, but also don't have a concrete suggestion in store ... if you don't mind, I'll let my mind wander a bit and will get back to you soon.
Also, feedback from other reviewers appreciated. @jamescrosswell what do you think?

From memory, we started setting the sentry.origin initially to support tracing... so the naming conventions for these were made with that in mind. It's even titled Trace Origin in the dev docs.

  • The first/type part of the origin is obvious (either manual or auto).
  • The second/category part is somewhat subjective (e.g. db or ui) and we try to match whatever the other SDKs are doing here... but some judgement required on our part since the specific databases etc. we're integrating with will often be .NET specific
  • The third part is the integration name. Ideally this would match the name we used for the integration in our source... so for example in the Sentry.EntityFramework integration we used the origin auto.db.entity_framework. The challenge is that our NuGet packages are optimised to minimise dependencies, so where we can integrate from the Sentry.nupkg without any extra dependencies, we do... which I think is why we ended up with stuff like auto.graphql (in the base Sentry NuGet).
  • I don't think we use the fourth part / integration-part anywhere in the .NET SDK...

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@alexsohn1126 alexsohn1126 marked this pull request as draft October 1, 2025 14:43
@alexsohn1126 alexsohn1126 changed the title fix: Ensure structured logs from an SDK integration has sentry.origin WIP fix: Ensure structured logs from an SDK integration has sentry.origin Oct 1, 2025
@alexsohn1126 alexsohn1126 marked this pull request as ready for review October 2, 2025 15:37
@alexsohn1126 alexsohn1126 requested a review from Flash0ver October 2, 2025 15:38
@alexsohn1126 alexsohn1126 marked this pull request as draft October 2, 2025 15:41
@alexsohn1126
Copy link
Member Author

Whoops, forgot to mention that we will be consolidating the category for sentry.origin across other Sentry SDKs! Once we have decided on what category, I'll mark this PR as ready..

@alexsohn1126
Copy link
Member Author

The Structured Logs spec was updated. See #4618 for more detail:

@alexsohn1126 alexsohn1126 marked this pull request as ready for review October 9, 2025 19:47
Copy link
Member

@Flash0ver Flash0ver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for aligning the value of "sentry.origin".
One final feedback to fix the CHANGELOG.md.
Then we could release this in 5.16.1.

CHANGELOG.md Outdated
- Upload linked PDBs to fix non-IL-stripped symbolication for iOS ([#4527](https://github.com/getsentry/sentry-dotnet/pull/4527))
- In MAUI Android apps, generate and inject UUID to APK and upload ProGuard mapping to Sentry with the UUID ([#4532](https://github.com/getsentry/sentry-dotnet/pull/4532))
- Fixed WASM0001 warning when building Blazor WebAssembly projects ([#4519](https://github.com/getsentry/sentry-dotnet/pull/4519))
- Structured Logs now have a `sentry.origin` attribute to so it's clearer where these come from ([#4566](https://github.com/getsentry/sentry-dotnet/pull/4566))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought: target branch version6 rather than main?

We now merge new PRs towards the version6 branch, which will be released in 6.0.0 (and pre-releases), unless it's a critical bug fix.

But ... on the other hand ... this is important for Sentry internally ... so I believe I am convincing myself to actually do merge this against main and release in 5.16.1 soon.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't say this is urgent, at most this is a "nice to have", because it doesn't really affect the functionality whole lot.

Not only that, it will also take time for the other SDK maintainers to follow the new spec for sentry.origin and update theirs.

Thoughts? @jamescrosswell

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be quite a while before the majority of SDK users move to version 6.0.0 so probably worth leaving this in main and making a 5.16.1 release.

It'll get merged into version6 from there (along with a bunch of other stuff).

@alexsohn1126 alexsohn1126 changed the title WIP fix: Ensure structured logs from an SDK integration has sentry.origin fix: Ensure structured logs from an SDK integration has sentry.origin Oct 11, 2025
@alexsohn1126 alexsohn1126 force-pushed the alexsohn/fix/sentry-origin-attached-to-sdk-integration-logs branch from 163dff3 to 6608542 Compare October 11, 2025 01:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants