Add structured logging sample#122
Open
jamescrosswell wants to merge 1 commit into
Open
Conversation
Demonstrates enabling Sentry Logs via Experimental.EnableLogs and emitting messages at every severity level, including a templated message with structured parameters. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Contributor
|
vaind
reviewed
May 22, 2026
Comment on lines
+42
to
+44
| [Sentry.SentrySdk]::Logger.LogInfo( | ||
| 'User {0} ran send-logs.ps1 on {1} (PowerShell {2})', | ||
| ([object[]]@($user, $host_, $psVersion))) |
Collaborator
There was a problem hiding this comment.
Cases such as this - if we want to add the sample for - are worth a separate native PowerShell API
3 tasks
vaind
added a commit
that referenced
this pull request
May 22, 2026
Mirrors the sample from PR #122 but uses the new cmdlet, including the -Parameters and -Attributes flags. Also fixes the changelog entry to include the PR number so Danger picks it up. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
samples/send-logs.ps1to demonstrate sending structured logs to Sentry from PowerShell, using the Sentry Logs feature exposed by the underlying sentry-dotnet SDK.Logs are opted into via
Experimental.EnableLogs = $trueon the options block, then emitted with[Sentry.SentrySdk]::Logger.LogTrace/LogDebug/LogInfo/LogWarning/LogError/LogFatal. The sample also shows a templated message ({0},{1}, ...) with structured parameters that become searchable attributes on the log record in Sentry.A couple of PowerShell-specific notes baked into the sample:
Logger.LogInfooverload usesparams object[], which PowerShell doesn't auto-expand — arguments are wrapped in[object[]]@(...).{0}/{1}placeholders (matchingstring.Format), not named{user}style.Closes #115
#skip-changelog