Skip to content

Conversation

@Flash0ver
Copy link
Member

@Flash0ver Flash0ver commented Dec 2, 2025

fixes #4493
closes #4733

See docs: https://develop.sentry.dev/sdk/telemetry/logs/#default-attributes


Changes

  • Adds missing "default attributes" as per Sentry Developer Documentation.
  • Applying the values - if available - from the current Scope.
    • Changed the internal APIs for that

However, it seems that we're missing a lot of the Contexts on the Scope,
where we currently mostly apply them to Events.

TODO

  • Enrich the Scope with the data needed
    • or set the data directly for the time being
  • add CHANGELOG.md entry

@Flash0ver Flash0ver self-assigned this Dec 2, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 2, 2025

Fails
🚫 Please consider adding a changelog entry for the next release.
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Instructions and example for changelog

Please add an entry to CHANGELOG.md to the "Unreleased" section. Make sure the entry includes this PR's number.

Example:

## Unreleased

### Features

- apply default attributes from Scope ([#4784](https://github.com/getsentry/sentry-dotnet/pull/4784))

If none of the above apply, you can opt out of this check by adding #skip-changelog to the PR description or adding a skip-changelog label.

Generated by 🚫 dangerJS against 0e25afd

Comment on lines +196 to +202
if (scope.PropagationContext._dynamicSamplingContext is { } dynamicSamplingContext)
{
if (dynamicSamplingContext.Items.TryGetValue("replay_id", out var replayId))
{
SetAttribute("sentry.replay_id", replayId);
}
}
Copy link
Member Author

Choose a reason for hiding this comment

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

note: Could alternatively get from IReplaySession.ActiveReplayId.

But I guess reading it via the Scope unifies the source, and avoid a dependency to IReplaySession.

Comment on lines +204 to +215
if (scope.User.Id is { } userId)
{
SetAttribute("user.id", userId);
}
if (scope.User.Username is { } userName)
{
SetAttribute("user.name", userName);
}
if (scope.User.Email is { } userEmail)
{
SetAttribute("user.email", userEmail);
}
Copy link
Member Author

@Flash0ver Flash0ver Dec 2, 2025

Choose a reason for hiding this comment

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

question: PII

Do we need to check SentryOptions.SendDefaultPii?
Or do/can/should we assume that the data is set only when enabled already, or explicitly set by user code.

@codecov
Copy link

codecov bot commented Dec 2, 2025

Codecov Report

❌ Patch coverage is 94.87179% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.96%. Comparing base (8df9302) to head (0e25afd).

Files with missing lines Patch % Lines
src/Sentry/SentryLog.cs 93.93% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4784      +/-   ##
==========================================
+ Coverage   73.91%   73.96%   +0.05%     
==========================================
  Files         485      485              
  Lines       17682    17717      +35     
  Branches     3494     3510      +16     
==========================================
+ Hits        13069    13104      +35     
  Misses       3755     3755              
  Partials      858      858              

☔ 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add device attributes to Logs in the MAUI SDK server.address is missing from Structured Logs

2 participants