Skip to content

chore: simplify, modernize (Go 1.26), update deps#133

Merged
rustatian merged 1 commit into
masterfrom
chore/cleanup-modernize-deps
Jun 3, 2026
Merged

chore: simplify, modernize (Go 1.26), update deps#133
rustatian merged 1 commit into
masterfrom
chore/cleanup-modernize-deps

Conversation

@rustatian

@rustatian rustatian commented May 29, 2026

Copy link
Copy Markdown
Member

Applied fixes

R (Reliability)

  • writer.go: Add Unwrap() http.ResponseWriter so Hijacker, HTTP/2, and WebSocket promotion works through the metrics wrapper (was silently breaking those protocols)
  • writer.go: Default code to 200 inside Write() — handlers that write a body without calling WriteHeader now record status 200 instead of -1

S (Simplification)

  • plugin.go: *CounterVec with no labels replaced with prometheus.Counter for noFreeWorkers and uptime — cleaner API, no spurious With(nil) calls
  • plugin.go: Size-1 buffered stopCh replaced with unbuffered channel + close() idiom — the correct Go pattern for a one-shot stop signal
  • plugin.go: strconv.Itoa(rrWriter.code) captured once into statusCode; was evaluated twice (requestCounter + requestDuration)

M (Modernization)

  • plugin.go: var otelVal/tp zero-decls reordered to group related declarations before the if ok block — minor scope clarity improvement

Deps

  • go get -u all && go mod tidy

- writer: add Unwrap() so Hijacker/HTTP2/WebSocket promotion works through the wrapper
- writer: default code to 200 in Write() for handlers that skip WriteHeader
- plugin: CounterVec with no labels → prometheus.Counter (noFreeWorkers, uptime)
- plugin: size-1 buffered stopCh → unbuffered + close() idiom
- plugin: capture strconv.Itoa(rrWriter.code) once; drop duplicate call
- deps: go get -u all && go mod tidy
Copilot AI review requested due to automatic review settings May 29, 2026 12:43
@coderabbitai

coderabbitai Bot commented May 29, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@rustatian, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 32 minutes and 16 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9eac792a-3f7c-4ab3-a665-5889c73325df

📥 Commits

Reviewing files that changed from the base of the PR and between e4da73d and fe78e25.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (2)
  • plugin.go
  • writer.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/cleanup-modernize-deps

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Small reliability/cleanup pass on the http_metrics plugin: it makes the metrics ResponseWriter wrapper transparent to middleware that probes for http.Hijacker/HTTP/2 extensions, fixes the status label for handlers that only call Write, and simplifies a few internal patterns (label-less Counters, unbuffered stop channel via close, status string computed once). Also bumps OpenTelemetry contrib deps.

Changes:

  • writer.go: add Unwrap() to expose the inner http.ResponseWriter, and default code to 200 inside Write() when WriteHeader was not called.
  • plugin.go: replace label-less *CounterVec with Counter for noFreeWorkers/uptime, switch stopCh to unbuffered + close() in Stop, hoist strconv.Itoa(rrWriter.code) into a single statusCode, and minor declaration reorder.
  • go.sum: drop old entries for otelhttp v0.68.0 and jaeger v1.43.0, keep the upgraded v0.69.0/v1.44.0 lines.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.

File Description
writer.go Add Unwrap() for http.ResponseController and default status to 200 in Write().
plugin.go Use scalar Counters, simplify stop signaling with close(), cache status string.
go.sum Remove stale OTel contrib otelhttp/jaeger checksums superseded by the upgrade.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@rustatian rustatian self-assigned this Jun 3, 2026
@rustatian rustatian merged commit 3411559 into master Jun 3, 2026
6 checks passed
@rustatian rustatian deleted the chore/cleanup-modernize-deps branch June 3, 2026 19:38
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