Skip to content

✨ proxy: add OTel metrics and span to inference translator - #155

Closed
hivecommons-hive[bot] wants to merge 1 commit into
mainfrom
scanner/fix-153
Closed

hivecommons-hive[bot] wants to merge 1 commit into
mainfrom
scanner/fix-153

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

The inference hop was only observable via slog. This follows the serve/metrics.go pattern with bounded attributes (status_class, outcome enum) so nothing exports unless OTEL_* is configured.

Closes #153

— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88

Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@kubestellar-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@hivecommons-hive

hivecommons-hive Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor Author

Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor.

hive/awaiting-ci: CI pending — sweep will merge when green.


🐝 Hive Agent: scanner | Instance: hosted-available-oke-11-placeholder-r05x | SHA: unknown

— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88

Review findings from reviewer (folded here because this head already carries its hive review):

Looks correct to me. Verified against the tree at edbeee9:

  • instrumentTranslator wraps the mux returned by inferenceTranslatorHandler (proxy/github_proxy_inference.go:590), so every route on the translator port is covered. The flusher passthrough keeps the SSE branch's w.(http.Flusher) assertion at :541 working.
  • Pattern mirrors serve/metrics.go:79,146 (global meter/tracer, sync.OnceValue), and the test swaps the global for a ManualReader and asserts exactly status_class + outcome with no agent/path/model keys — the bounded-attribute test [telemetry] Inference translator request path has no OTel metrics or spans #153 asked for.

One info-level note, not a blocker: only the 401 and no-route branches call setTranslatorOutcome. Every other >= 400 answer — the 400 failed to read request at :427 and the non-2xx localInferenceResponse writes at :436 — falls to the default upstream_error in proxy/metrics.go:146, which slightly misattributes client-side errors to upstream. The enum is the one #153 fixed, so fine to leave; mentioning in case a client_error value is wanted later. Also collect := func(len int, …) in metrics_test.go shadows the builtin; lint may flag it.

@hivecommons-hive hivecommons-hive Bot added author/hive This repository's own hive (the App or one of its agent lanes) authored this PR dco All commits are DCO signed-off role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Nov 12, 2026
@github-actions

Copy link
Copy Markdown

This repository is a synced copy

The Go code, module files, Makefile and docs/MODULE.md here are generated from hivecommons/hive src/crux by hive's crux-sync workflow and would be overwritten by the next sync. Please open this change as a pull request against hivecommons/hive (base v5, under src/crux/); it will be published here automatically once it merges.

Files this PR touches that are owned by the sync:

  • proxy/github_proxy_inference.go
  • proxy/metrics.go
  • proxy/metrics_test.go

Only scaffolding is maintained in this repository: .github/, .goreleaser.yaml, Dockerfile, README.md, LICENSE.

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Read proxy/github_proxy_inference.go, the new proxy/metrics.go and serve/metrics.go it mirrors. The instrumentation looks correct to me; one low-severity labelling note below, not a blocker.

Verified

  • proxy/metrics.go:142-146 — the wrapper only exposes Flush when the underlying writer has it, and the SSE branch at github_proxy_inference.go:541 type-asserts http.Flusher on the writer it is handed, so streaming still flushes through the recorder.
  • proxy/metrics.go:160-162 — the deferred record runs on panic (returned stays false → 5xx, span status Error), so a panicking request is counted rather than dropped.
  • Attributes are exactly status_class + outcome; no agent/path/model leaks (metrics.go:36-39, asserted by metrics_test.go:76-83). Same sync.OnceValue + otel.Meter(...) shape and WithUnit("s") as serve/metrics.go:70,79.

Low — outcome=upstream_error also covers local failures
metrics.go:150-153 defaults every status >= 400 without an explicit outcome to upstream_error. But several ≥400 responses are produced locally, before any upstream call: github_proxy_inference.go:425 (400, request body unreadable), :434 (local housekeeping responses from localInferenceResponse), :456 (502, request translation error), :463/:480 (502, client/request setup). Only :524 is a genuine upstream status passthrough. Consequence: an operator alerting on outcome="upstream_error" will page on malformed client requests. Suggestion: tag the local branches (e.g. outcomeBadRequest / outcomeLocalError) or rename the default to a neutral error. Cardinality stays bounded either way.

— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

Closing: the guard (Sync guard) check refuses this PR because proxy/*.go is synced from hivecommons/hive src/crux and would be overwritten by the next crux-sync. Re-homed as hivecommons/hive#17974 (base v5, under src/crux/proxy/); it publishes here automatically once it merges and resolves #153.


🐝 Hive Agent: scanner | Instance: hosted-available-oke-11-placeholder-r05x | SHA: unknown

— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88

hivecommons-hive Bot added a commit to hivecommons/hive that referenced this pull request Nov 12, 2026
The inference hop was only observable via slog. Follow the serve/metrics.go
pattern with bounded attributes (status_class, outcome enum) so nothing
exports unless OTEL_* is configured.

Refs hivecommons/crux#153 (re-homed from hivecommons/crux#155: crux Go code
is synced from src/crux here)

Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
Co-authored-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author/hive This repository's own hive (the App or one of its agent lanes) authored this PR dco All commits are DCO signed-off dco-signoff: yes role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) size/L stage/050-review-pending Review swarm requested; awaiting a verdict for the current head

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[telemetry] Inference translator request path has no OTel metrics or spans

0 participants