Repository navigation
make sambrs logs filterable with structured fields and per-operation spans - #7
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Wrap every public operation in a debug span carrying its inputs, give all WNet call events a uniform operation/status shape, move per-entry enumeration events to trace with a finishing summary, log the access name connect_auto assigns, warn when a guard cannot disconnect on drop, drop the redundant resolved-user event, and document the logging in the README. Co-Authored-By: Claude Opus 5.5 <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.
sambrs's logs weren't usable at the level people actually run. Values were put into the message text, so a JSON or OpenTelemetry subscriber couldn't filter on them. Worse, the context for each call (which share, which user, which drive) was only logged at
trace. Atdebugyou'd seeWNetAddConnection2W returned status=1326with no idea which connection failed.This makes sambrs's logging structured and attaches the context to every event:
debugspan named after itself (connect_with,connect_auto,cancel_connection,get_connection,get_user,get_universal_name,connections,remembered,server_shares). Its inputs are fields:remote,user,local,flags,name,force,forget,drive,connection,path,server. Every event inside, including the extended-error lookup, inherits them. Enumeration iterators keep their span and re-enter it on eachnext()and on drop. The spans are created manually withdebug_span!, so this needs noattributesfeature and no proc-macro dependencies.debug!(operation = "WNet…", status, "WNet call returned"), sostatus != 0finds every failed call.WNetEnumResourceWevents moved totrace. Failures and buffer retries stay atdebug, and there's onedebugsummary withentrieswhen the enumeration finishes.connect_automaps. The access name Windows picked is now recorded, so a lingering drive can be traced back to sambrs.Connectionguard can't disconnect, the drop logswarn, because it has no other way to report the error.ERROR_NOT_CONNECTED(the drive is already gone) stays atdebug.WNetGetUserW resolved userevent, since that value is the function's return value.useris left out when connecting as the logged-on user, and usernames now appear atdebug(passwords are still never logged). The README has a new Logging section listing the span and field names.No public API changes. Bumps to 0.2.2 with an
(unreleased)changelog entry.Checked locally: rustfmt, clippy and rustdoc for the Windows target. The tests can't link without MSVC here, so the Windows CI job is the test run.
Created with Claude Opus 5.5 in Claude Code.