Skip to content

chore(orch): add nbd read duration#2373

Open
jakubno wants to merge 6 commits intomainfrom
chore/add-nbd-read-duration
Open

chore(orch): add nbd read duration#2373
jakubno wants to merge 6 commits intomainfrom
chore/add-nbd-read-duration

Conversation

@jakubno
Copy link
Copy Markdown
Member

@jakubno jakubno commented Apr 13, 2026

Add a metric to

  • measure the time to read from nbd independently on the backend
  • measure concurrent reads

@cursor
Copy link
Copy Markdown

cursor bot commented Apr 13, 2026

PR Summary

Medium Risk
Touches the NBD read hot path and adds synchronous metric bookkeeping around each ReadAt, which could introduce overhead or skew counters if contexts cancel before decrement/recording.

Overview
Adds OpenTelemetry instrumentation to NBD read handling: records orchestrator.nbd.dispatch.read_duration (ms) with result attributes (success/failure/cancelled) and tracks orchestrator.nbd.dispatch.reads_in_flight by incrementing before the backend ReadAt and decrementing once the read completes or the request context is cancelled.

Reviewed by Cursor Bugbot for commit 5c6d057. Bugbot is set up for automated code reviews on this repo. Configure here.

@jakubno jakubno marked this pull request as draft April 13, 2026 12:09
Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

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

The histogram at dispatch.go line 263 records durations for both successful and failed reads with no distinguishing attribute. Since ReadAt respects context cancellation, cancelled reads can return almost instantly and appear as very-short-duration samples mixed with normal reads, making percentiles misleading. Consider adding an error attribute to allow segmentation.

Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

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

LGTM — simple observability addition.

Extended reasoning...

Overview

Single-file change to dispatch.go adding an Int64Histogram metric (orchestrator.nbd.dispatch.read_duration) and instrumenting the ReadAt call in cmdRead with time.Now() / time.Since. No behavioral changes.

Security risks

None. The change only adds a metrics recording call; it does not touch auth, crypto, permissions, or any external input paths.

Level of scrutiny

Low. This is a pure observability change — no logic is altered, the new histogram is package-level and initialized via the existing utils.Must pattern, and the two added lines are isolated inside an already-goroutined closure. The risk surface is essentially zero.

Other factors

The one flagged issue (missing outcome attribute on the histogram) is a nit around metric quality posted as an inline comment. It does not affect correctness or safety. The rest of the change is straightforward and follows established patterns in the codebase.

@jakubno jakubno marked this pull request as ready for review April 13, 2026 14:57
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.

2 participants